diff --git a/.github/workflows/library_rust_tests.yml b/.github/workflows/library_rust_tests.yml new file mode 100644 index 000000000..f87fdc4f3 --- /dev/null +++ b/.github/workflows/library_rust_tests.yml @@ -0,0 +1,108 @@ +# This workflow performs tests in Rust. +name: Library Rust tests + +on: + workflow_call: + inputs: + dafny: + description: "The Dafny version to run" + required: true + type: string + regenerate-code: + description: "Regenerate code using smithy-dafny" + required: false + default: false + type: boolean + +jobs: + testRust: + strategy: + fail-fast: false + matrix: + library: + [ + DynamoDbEncryption, + TestVectors, + ] + # removed windows-latest because somehow it can't build aws-lc in CI + os: [ubuntu-latest, macos-13] + runs-on: ${{ matrix.os }} + permissions: + id-token: write + contents: read + env: + RUST_MIN_STACK: 104857600 + steps: + - name: Support longpaths on Git checkout + run: | + git config --global core.longpaths true + - uses: actions/checkout@v3 + - name: Init Submodules + shell: bash + run: | + git submodule update --init libraries + git submodule update --init --recursive smithy-dafny + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: us-west-2 + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2 + role-session-name: RustTests + + - name: Setup Rust Toolchain for GitHub CI + uses: actions-rust-lang/setup-rust-toolchain@v1.10.1 + with: + components: rustfmt + # TODO - uncomment this after Rust formatter works + # - name: Rustfmt Check + # uses: actions-rust-lang/rustfmt@v1 + + # TODO: Use setup-dafny-actions with correct version when Dafny releases 4.8.2 + - name: Setup Dafny + uses: dafny-lang/setup-dafny-action@v1.7.0 + with: + dafny-version: 4.9.0 + + # TODO: Remove this after the formatting in Rust starts working + - name: smithy-dafny Rust hacks + shell: bash + run: | + if [ "$RUNNER_OS" == "macOS" ]; then + sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' smithy-dafny/SmithyDafnyMakefile.mk + else + sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' smithy-dafny/SmithyDafnyMakefile.mk + fi + + - name: Setup Java 17 for codegen + uses: actions/setup-java@v3 + with: + distribution: "corretto" + java-version: "17" + + - name: Setup NASM for Windows (aws-lc-sys) + if: matrix.os == 'windows-latest' + uses: ilammy/setup-nasm@v1 + + - name: Install Smithy-Dafny codegen dependencies + uses: ./.github/actions/install_smithy_dafny_codegen_dependencies + + - name: Run make polymorph_rust + shell: bash + working-directory: ./${{ matrix.library }} + run: | + make polymorph_rust + + - name: Compile ${{ matrix.library }} implementation + shell: bash + working-directory: ./${{ matrix.library }} + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES + + - name: Test ${{ matrix.library }} Rust + shell: bash + working-directory: ./${{ matrix.library }} + run: | + make test_rust diff --git a/DynamoDbEncryption/runtimes/rust/Cargo.toml b/DynamoDbEncryption/runtimes/rust/Cargo.toml index ba379d0a4..e5da590bd 100644 --- a/DynamoDbEncryption/runtimes/rust/Cargo.toml +++ b/DynamoDbEncryption/runtimes/rust/Cargo.toml @@ -24,7 +24,7 @@ aws-sdk-kms = "1.47.0" aws-smithy-runtime-api = {version = "1.7.2", features = ["client"] } aws-smithy-types = "1.2.8" chrono = "0.4.38" -dafny_runtime = { path = "../../../submodules/smithy-dafny/TestModels/dafny-dependencies/dafny_runtime_rust"} +dafny_runtime = { path = "../../../submodules/MaterialProviders/smithy-dafny/TestModels/dafny-dependencies/dafny_runtime_rust"} dashmap = "6.1.0" pem = "3.0.4" tokio = {version = "1.41.0", features = ["full"] }