Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Use commit from Dafny feature branch for testing Rust support #368

Merged
merged 32 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c30cbf3
Feat: Integration of the latest generated code of Dafny Rust.
MikaelMayer May 15, 2024
83b2f0b
Generated StandardLibrary and SimpleString from rust, fixed generated…
MikaelMayer May 15, 2024
c62d6ca
No reading of objects, only borrows
MikaelMayer May 16, 2024
f2a0fe1
Ensure Standard Library has its own Makefile recipe
MikaelMayer May 16, 2024
36d2089
SimpleBlob as well
MikaelMayer May 16, 2024
f56d0a5
Partial impl
robin-aws May 21, 2024
aeb1d06
Merge branch 'main-1.x' of github.com:smithy-lang/smithy-dafny into r…
robin-aws May 21, 2024
4edd9a8
Checking out helps
robin-aws May 21, 2024
46dbdf2
Shell
robin-aws May 21, 2024
dd64603
Hard code DAFNY_VERSION for now
robin-aws May 21, 2024
13ffdb3
Debug
robin-aws May 21, 2024
7badb23
Absolute path in PATH
robin-aws May 21, 2024
d401cfb
Update patch files
robin-aws May 21, 2024
1876c80
Whitespace
robin-aws May 21, 2024
c3348fe
Restore the rest of the CI
robin-aws May 21, 2024
957cee6
Comment
robin-aws May 21, 2024
6726a5a
Lock down specific commit
robin-aws May 22, 2024
377745c
Merge branch 'main-1.x' of github.com:smithy-lang/smithy-dafny into r…
robin-aws May 22, 2024
867ba29
Update makefiles
robin-aws May 22, 2024
dec01ed
Clean up
robin-aws May 22, 2024
7c3e1de
Update patch
robin-aws May 22, 2024
5362cde
Update SimpleString patch
robin-aws May 22, 2024
1b0e5b5
Fix StandardLibrary transpile_rust to retain src
robin-aws May 22, 2024
6348a17
Merge branch 'main-1.x' of github.com:smithy-lang/smithy-dafny into l…
robin-aws May 22, 2024
f8644bd
Merge branch 'robin-aws/test-rust-with-dafny-feat-rust-branch' into l…
robin-aws May 22, 2024
c3e4762
Include rustfmt
robin-aws May 22, 2024
b4742df
Update/delete patch files
robin-aws May 22, 2024
bc74e68
Apply same changes to the other two test models
robin-aws May 22, 2024
aa3c373
Update patch files
robin-aws May 22, 2024
0dae48e
Missing dereference on wrapped booleans + typos
robin-aws May 22, 2024
546400a
update patch files
robin-aws May 22, 2024
fe794ce
remove dafny_benerate (since now transpile_rust does the same thing)
robin-aws May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/actions/build_dafny_from_source/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# This local action builds Dafny from source
# rather than using the setup-dafny-action.
# Currently it's only used to test Rust support
# against a feature branch of Dafny.
#

name: "Build Dafny from source"
description: "Drop-in replacement for setup-dafny-action that builds the given branch of Dafny from source"
inputs:
dafny:
description: "The Dafny branch to use"
required: true
type: string
runs:
using: "composite"
steps:
- name: Checkout Dafny
uses: actions/checkout@v4
with:
repository: dafny-lang/dafny
path: dafny
ref: ${{ inputs.dafny }}

- name: Load Z3
shell: bash
run: |
sudo apt-get install -qq libarchive-tools
mkdir -p dafny/Binaries/z3/bin
wget -qO- https://github.com/dafny-lang/solver-builds/releases/download/snapshot-2023-08-02/z3-4.12.1-x64-ubuntu-20.04-bin.zip | bsdtar -xf -
mv z3-4.12.1 dafny/Binaries/z3/bin/
chmod +x dafny/Binaries/z3/bin/z3-4.12.1
mkdir -p unzippedRelease/dafny/z3/bin
ln dafny/Binaries/z3/bin/z3-4.12.1 unzippedRelease/dafny/z3/bin/z3-4.12.1

- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

- name: Build Dafny
shell: bash
run: |
dotnet build dafny/Source/Dafny.sln

- name: Add dafny to PATH
shell: bash
run: |
echo ${{ github.workspace }}/dafny/Scripts >> $GITHUB_PATH

# Hard-coding this for now since it's a pain to extract from an arbitrary branch
- name: Export DAFNY_VERSION
shell: bash
run: |
echo "DAFNY_VERSION=4.7.0" >> $GITHUB_ENV
5 changes: 2 additions & 3 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ jobs:
fail-fast: false
matrix:
# Rust code generation is under development and depends on pending changes to the
# Dafny Rust code generation, so we only test on a relatively recent prerelease instead.
# This can be updated as needed when new features/fixes land in Dafny master.
# Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead.
dafny-version:
- nightly-2024-05-14-8da3ddd
- 00fe7ff70d3858d67d69a2b897a65c7f9d209e0a
uses: ./.github/workflows/test_models_rust_tests.yml
with:
dafny: ${{ matrix.dafny-version }}
5 changes: 2 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ jobs:
fail-fast: false
matrix:
# Rust code generation is under development and depends on pending changes to the
# Dafny Rust code generation, so we only test on a relatively recent prerelease instead.
# This can be updated as needed when new features/fixes land in Dafny master.
# Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead.
dafny-version:
- nightly-2024-05-14-8da3ddd
- 00fe7ff70d3858d67d69a2b897a65c7f9d209e0a
uses: ./.github/workflows/test_models_rust_tests.yml
with:
dafny: ${{ matrix.dafny-version }}
7 changes: 4 additions & 3 deletions .github/workflows/test_models_rust_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,17 @@ jobs:

- uses: actions/checkout@v3

- name: Setup Dafny
uses: dafny-lang/setup-dafny-action@v1.7.0
- name: Setup Dafny (build from source)
uses: ./.github/actions/build_dafny_from_source
with:
dafny-version: ${{ inputs.dafny }}
dafny: ${{ inputs.dafny }}

- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.74.1"
rustflags: ""
components: rustfmt

- name: Generate Polymorph Dafny
working-directory: ./${{ matrix.library }}
Expand Down
13 changes: 12 additions & 1 deletion SmithyDafnyMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ transpile_implementation:
-functionSyntax:3 \
-useRuntimeLib \
-out $(OUT) \
$(DAFNY_OPTIONS) \
$(if $(strip $(STD_LIBRARY)) , -library:$(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy, ) \
$(TRANSPILE_DEPENDENCIES)

Expand Down Expand Up @@ -505,12 +506,18 @@ transpile_rust: | transpile_implementation_rust transpile_dependencies_rust
transpile_implementation_rust: TARGET=rs
transpile_implementation_rust: OUT=implementation_from_dafny
transpile_implementation_rust: SRC_INDEX=$(RUST_SRC_INDEX)
# The Dafny Rust code generator is not complete yet,
# so we want to emit code even if there are unsupported features in the input.
transpile_implementation_rust: DAFNY_OPTIONS=-emitUncompilableCode
transpile_implementation_rust: _transpile_implementation_all _mv_implementation_rust

transpile_test_rust: TARGET=rs
transpile_test_rust: OUT=tests_from_dafny
transpile_test_rust: SRC_INDEX=$(RUST_SRC_INDEX)
transpile_test_rust: TEST_INDEX=$(RUST_TEST_INDEX)
# The Dafny Rust code generator is not complete yet,
# so we want to emit code even if there are unsupported features in the input.
transpile_test_rust: DAFNY_OPTIONS=-emitUncompilableCode
transpile_test_rust: _transpile_test_all _mv_test_rust

transpile_dependencies_rust: LANG=rust
Expand All @@ -519,12 +526,16 @@ transpile_dependencies_rust: transpile_dependencies
_mv_implementation_rust:
rm -rf runtimes/rust/dafny_impl/src
mkdir -p runtimes/rust/dafny_impl/src
mv implementation_from_dafny-rust/src/implementation_from_dafny.rs runtimes/rust/dafny_impl/src/implementation_from_dafny.rs
# TODO: Currently need to insert an import of the the StandardLibrary.
python -c "import sys; data = sys.stdin.buffer.read(); sys.stdout.buffer.write(data.replace(b'\npub mod', b'\npub use dafny_standard_library::implementation_from_dafny::*;\n\npub mod', 1) if b'\npub mod' in data else data)" \
< implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/dafny_impl/src/implementation_from_dafny.rs
rustfmt runtimes/rust/dafny_impl/src/implementation_from_dafny.rs
rm -rf implementation_from_dafny-rust
_mv_test_rust:
rm -rf runtimes/rust/dafny_impl/tests
mkdir -p runtimes/rust/dafny_impl/tests
mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/dafny_impl/tests/tests_from_dafny.rs
rustfmt runtimes/rust/dafny_impl/tests/tests_from_dafny.rs
rm -rf tests_from_dafny-rust

build_rust:
Expand Down
2 changes: 0 additions & 2 deletions TestModels/SharedMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,3 @@ _polymorph_dotnet: _polymorph
_polymorph_dotnet: OUTPUT_DOTNET_WRAPPED=\
$(if $(DIR_STRUCTURE_V2), --output-dotnet $(LIBRARY_ROOT)/runtimes/net/Generated/Wrapped/$(SERVICE)/, --output-dotnet $(LIBRARY_ROOT)/runtimes/net/Generated/Wrapped)
_polymorph_dotnet: _polymorph_wrapped


2 changes: 0 additions & 2 deletions TestModels/SimpleTypes/SimpleBlob/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ SMITHY_DEPS=dafny-dependencies/Model/traits.smithy

# This project has no dependencies
# DEPENDENT-MODELS:=

RUST_SRC_INDEX=src_for_rust
Loading
Loading