Skip to content

Commit

Permalink
fix: prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamChaturvedi7 committed Sep 4, 2024
1 parent 61cc564 commit ac8a6a4
Show file tree
Hide file tree
Showing 46 changed files with 10,640 additions and 7,216 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
manual-ci-go:
uses: ./.github/workflows/test_models_go_tests.yml
with:
dafny: ${{ inputs.dafny }}
dafny: ${{ inputs.dafny }}
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ jobs:
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.only-new-dafny-version-list) }}
uses: ./.github/workflows/test_models_go_tests.yml
with:
dafny: ${{ matrix.dafny-version }}
dafny: ${{ matrix.dafny-version }}
10 changes: 5 additions & 5 deletions .github/workflows/test_models_go_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.21'
go-version: "1.21"

- name: Install Go imports
run: |
Expand All @@ -67,10 +67,10 @@ jobs:
- name: Add go mod to Dafny Runtime Go
shell: bash
working-directory: ./DafnyRuntimeGo
run: |
run: |
go mod init github.com/dafny-lang/DafnyRuntimeGo
go mod tidy
- name: Setup Java 17 for codegen
uses: actions/setup-java@v3
with:
Expand All @@ -91,12 +91,12 @@ jobs:
with:
arguments: :smithy-dafny-codegen:pTML
build-root-directory: codegen

- name: Execute smithy-dafny-codegen-test tests
uses: gradle/gradle-build-action@v2
env:
JUNIT_SHARD: ${{ matrix.shard }}
JUNIT_SHARD_COUNT: ${{ inputs.num_shards }}
with:
arguments: :smithy-dafny-codegen-test:test --tests '*smithygo*' --info
build-root-directory: codegen
build-root-directory: codegen
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.loader.ModelAssembler;

import software.amazon.polymorph.CodegenEngine.TargetLanguage;
import software.amazon.polymorph.smithydafny.DafnyVersion;
import software.amazon.polymorph.smithyjava.generator.CodegenSubject.AwsSdkVersion;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.loader.ModelAssembler;
import software.amazon.smithy.model.validation.ValidatedResult;
import software.amazon.smithy.model.validation.ValidationEvent;

Expand Down Expand Up @@ -235,12 +233,12 @@ private static Options getCliOptionsForBuild() {
.build()
)
.addOption(
Option
.builder()
.longOpt("output-go")
.desc("<optional> output directory for generated Go files")
.hasArg()
.build()
Option
.builder()
.longOpt("output-go")
.desc("<optional> output directory for generated Go files")
.hasArg()
.build()
)
.addOption(
Option
Expand Down Expand Up @@ -354,8 +352,7 @@ private static Options getCliOptionsForBuild() {
.valueSeparator(',')
.build()
);
}

}

private static Options getCliOptionsForPatchAfterTranspile() {
return new Options()
Expand Down Expand Up @@ -557,8 +554,8 @@ static Optional<CliArguments> parse(String[] args) throws ParseException {
.ofNullable(commandLine.getOptionValue("output-dotnet"))
.map(Paths::get);
final Optional<Path> outputGoDir = Optional
.ofNullable(commandLine.getOptionValue("output-go"))
.map(Paths::get);
.ofNullable(commandLine.getOptionValue("output-go"))
.map(Paths::get);
final Optional<Path> outputRustDir = Optional
.ofNullable(commandLine.getOptionValue("output-rust"))
.map(Paths::get);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import software.amazon.polymorph.smithydotnet.localServiceWrapper.LocalServiceWrappedConversionCodegen;
import software.amazon.polymorph.smithydotnet.localServiceWrapper.LocalServiceWrappedShimCodegen;
import software.amazon.polymorph.smithygo.awssdk.DafnyGoAwsSdkClientCodegenPlugin;
import software.amazon.polymorph.smithygo.localservice.DafnyLocalServiceCodegenPlugin;
import software.amazon.polymorph.smithyjava.generator.CodegenSubject.AwsSdkVersion;
import software.amazon.polymorph.smithyjava.generator.awssdk.v1.JavaAwsSdkV1;
import software.amazon.polymorph.smithyjava.generator.awssdk.v2.JavaAwsSdkV2;
Expand All @@ -66,7 +67,6 @@
import software.amazon.smithy.model.node.ObjectNode;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.utils.IoUtils;
import software.amazon.polymorph.smithygo.localservice.DafnyLocalServiceCodegenPlugin;
import software.amazon.smithy.utils.Pair;

public class CodegenEngine {
Expand Down Expand Up @@ -815,25 +815,36 @@ private void handlePatching(TargetLanguage targetLanguage, Path outputDir) {

private void generateGo() {
if (libraryName.isEmpty()) {
throw new IllegalArgumentException("Python codegen requires a module name");
throw new IllegalArgumentException("Go codegen requires a library name");
}

ObjectNode.Builder goSettingsBuilder = ObjectNode.builder()
.withMember("service", serviceShape.getId().toString())
.withMember("moduleName", libraryName.get());
ObjectNode.Builder goSettingsBuilder = ObjectNode
.builder()
.withMember("service", serviceShape.getId().toString())
.withMember("moduleName", libraryName.get());

final PluginContext pluginContext = PluginContext.builder()
.model(model)
.fileManifest(FileManifest.create(targetLangOutputDirs.get(TargetLanguage.GO)))
.settings(goSettingsBuilder.build())
.build();
final PluginContext pluginContext = PluginContext
.builder()
.model(model)
.fileManifest(
FileManifest.create(targetLangOutputDirs.get(TargetLanguage.GO))
)
.settings(goSettingsBuilder.build())
.build();

final Map<String, String> smithyNamespaceToGoModuleNameMap = new HashMap<>(dependencyLibraryNames);
smithyNamespaceToGoModuleNameMap.put(serviceShape.getId().getNamespace(), libraryName.get());
final Map<String, String> smithyNamespaceToGoModuleNameMap = new HashMap<>(
dependencyLibraryNames
);
smithyNamespaceToGoModuleNameMap.put(
serviceShape.getId().getNamespace(),
libraryName.get()
);
if (this.awsSdkStyle) {
new DafnyGoAwsSdkClientCodegenPlugin(smithyNamespaceToGoModuleNameMap).run(pluginContext);
new DafnyGoAwsSdkClientCodegenPlugin(smithyNamespaceToGoModuleNameMap)
.run(pluginContext);
} else {
new DafnyLocalServiceCodegenPlugin(smithyNamespaceToGoModuleNameMap).run(pluginContext);
new DafnyLocalServiceCodegenPlugin(smithyNamespaceToGoModuleNameMap)
.run(pluginContext);
}
}

Expand Down
Loading

0 comments on commit ac8a6a4

Please sign in to comment.