forked from smithy-lang/smithy-dafny
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add type descriptors for data constructors in Java, when necess…
…ary (smithy-lang#301) *Description of changes:* As part of the progress towards supporting traits on non-reference types, the Java backend in Dafny 4.2 changed datatype constructors to require type descriptors for any generic type parameters: dafny-lang/dafny#4240. This change fixes a big chunk of the failing nightly build failures by augmenting the Java code generation to conditionally provide these type descriptors when creating `Result` and `Option` values. In most cases this is handled by the new `nameresolver.Dafny.createSuccess/Failure/Some/None` helper methods, but in some cases some new Dafny helper methods are added to `StandardLibrary` or emitted as well, so that TestModels can provide the same Java code for any Dafny version. It also adds a parameter for the target Dafny version so it knows when to emit them, exposed both as a `--dafny-version` option for the CLI and a `dafnyVersion` configuration value on `smithy-build.json` file. This defaults to `4.1.0`, but the latter knob is actually required when using the latest "edition" of the Smithy plugin (now `2023.10` instead of `2023`), as this is exactly the kind of otherwise-breaking change editions are designed to support! Finally, it refactors the CI to test all Dafny-relevant things on multiple versions of Dafny. It follows the same workflow template as https://github.com/aws/aws-cryptographic-material-providers-library-java/tree/main/.github/workflows (and kudos to @texastony!). This exposed one verification regression on 4.3 that I'm looking into, and may factor out of this PR if it's not quick to fix. --------- Co-authored-by: Tony Knapp <5892063+texastony@users.noreply.github.com>
- Loading branch information
1 parent
420dac3
commit e027e4d
Showing
72 changed files
with
1,093 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This workflow invokes other workflows with the requested Dafny build. | ||
# It is primarily meant for manual compatibility testing, | ||
# such as trying out what the next pending nightly build will do ahead of time. | ||
name: Manual CI | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dafny: | ||
description: 'The Dafny version to use' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
manual-ci-verification: | ||
uses: ./.github/workflows/test_models_dafny_verification.yml | ||
with: | ||
dafny: ${{ inputs.dafny }} | ||
manual-ci-java: | ||
uses: ./.github/workflows/test_models_java_tests.yml | ||
with: | ||
dafny: ${{ inputs.dafny }} | ||
manual-ci-net: | ||
uses: ./.github/workflows/test_models_net_tests.yml | ||
with: | ||
dafny: ${{ inputs.dafny }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This workflow invokes other workflows with the nightly Dafny build | ||
name: Dafny Nightly | ||
|
||
on: | ||
schedule: | ||
# Nightly build against Dafny's nightly prereleases, | ||
# for early warning of verification issues or regressions. | ||
# Timing chosen to be adequately after Dafny's own nightly build, | ||
# but this might need to be tweaked: | ||
# https://github.com/dafny-lang/dafny/blob/master/.github/workflows/deep-tests.yml#L16 | ||
- cron: "30 16 * * *" | ||
|
||
jobs: | ||
dafny-nightly-verification: | ||
# Don't run the cron builds on forks | ||
if: github.event_name != 'schedule' || github.repository_owner == 'smithy-lang' | ||
uses: ./.github/workflows/test_models_dafny_verification.yml | ||
with: | ||
dafny: 'nightly-latest' | ||
dafny-nightly-java: | ||
if: github.event_name != 'schedule' || github.repository_owner == 'smithy-lang' | ||
uses: ./.github/workflows/test_models_java_tests.yml | ||
with: | ||
dafny: 'nightly-latest' | ||
dafny-nightly-net: | ||
if: github.event_name != 'schedule' || github.repository_owner == 'smithy-lang' | ||
uses: ./.github/workflows/test_models_net_tests.yml | ||
with: | ||
dafny: 'nightly-latest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This workflow runs for every pull request | ||
name: PR CI | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
pr-populate-dafny-versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Populate Dafny versions list | ||
id: populate-dafny-versions-list | ||
run: echo "dafny-versions-list=['4.1.0', '4.3.0']" >> $GITHUB_OUTPUT | ||
outputs: | ||
dafny-version-list: ${{ steps.populate-dafny-versions-list.outputs.dafny-versions-list }} | ||
|
||
pr-ci-verification: | ||
needs: pr-populate-dafny-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.dafny-version-list) }} | ||
uses: ./.github/workflows/test_models_dafny_verification.yml | ||
with: | ||
dafny: ${{ matrix.dafny-version }} | ||
pr-ci-java: | ||
needs: pr-populate-dafny-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.dafny-version-list) }} | ||
uses: ./.github/workflows/test_models_java_tests.yml | ||
with: | ||
dafny: ${{ matrix.dafny-version }} | ||
pr-ci-net: | ||
needs: pr-populate-dafny-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.dafny-version-list) }} | ||
uses: ./.github/workflows/test_models_net_tests.yml | ||
with: | ||
dafny: ${{ matrix.dafny-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This workflow runs for every push to main-1.x | ||
name: Push CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main-1.x | ||
|
||
jobs: | ||
pr-populate-dafny-versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Populate Dafny versions list | ||
id: populate-dafny-versions-list | ||
run: echo "dafny-versions-list=['4.1.0', '4.3.0']" >> $GITHUB_OUTPUT | ||
outputs: | ||
dafny-version-list: ${{ steps.populate-dafny-versions-list.outputs.dafny-versions-list }} | ||
|
||
push-ci-verification: | ||
needs: pr-populate-dafny-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.dafny-version-list) }} | ||
uses: ./.github/workflows/test_models_dafny_verification.yml | ||
with: | ||
dafny: ${{ matrix.dafny-version }} | ||
push-ci-java: | ||
needs: pr-populate-dafny-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.dafny-version-list) }} | ||
uses: ./.github/workflows/test_models_java_tests.yml | ||
with: | ||
dafny: ${{ matrix.dafny-version }} | ||
push-ci-net: | ||
needs: pr-populate-dafny-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dafny-version: ${{ fromJson(needs.pr-populate-dafny-versions.outputs.dafny-version-list) }} | ||
uses: ./.github/workflows/test_models_net_tests.yml | ||
with: | ||
dafny: ${{ matrix.dafny-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.