|
| 1 | +# This workflow performs tests in Rust. |
| 2 | +name: Library Rust tests |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + dafny: |
| 8 | + description: "The Dafny version to run" |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + regenerate-code: |
| 12 | + description: "Regenerate code using smithy-dafny" |
| 13 | + required: false |
| 14 | + default: false |
| 15 | + type: boolean |
| 16 | + |
| 17 | +jobs: |
| 18 | + testRust: |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + library: |
| 23 | + [ |
| 24 | + DynamoDbEncryption, |
| 25 | + TestVectors, |
| 26 | + ] |
| 27 | + # removed windows-latest because somehow it can't build aws-lc in CI |
| 28 | + os: [ubuntu-latest, macos-13] |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + permissions: |
| 31 | + id-token: write |
| 32 | + contents: read |
| 33 | + env: |
| 34 | + RUST_MIN_STACK: 104857600 |
| 35 | + steps: |
| 36 | + - name: Support longpaths on Git checkout |
| 37 | + run: | |
| 38 | + git config --global core.longpaths true |
| 39 | + - uses: actions/checkout@v3 |
| 40 | + - name: Init Submodules |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + git submodule update --init libraries |
| 44 | + git submodule update --init --recursive smithy-dafny |
| 45 | +
|
| 46 | + - name: Configure AWS Credentials |
| 47 | + uses: aws-actions/configure-aws-credentials@v2 |
| 48 | + with: |
| 49 | + aws-region: us-west-2 |
| 50 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2 |
| 51 | + role-session-name: RustTests |
| 52 | + |
| 53 | + - name: Setup Rust Toolchain for GitHub CI |
| 54 | + uses: actions-rust-lang/[email protected] |
| 55 | + with: |
| 56 | + components: rustfmt |
| 57 | + # TODO - uncomment this after Rust formatter works |
| 58 | + # - name: Rustfmt Check |
| 59 | + # uses: actions-rust-lang/rustfmt@v1 |
| 60 | + |
| 61 | + # TODO: Use setup-dafny-actions with correct version when Dafny releases 4.8.2 |
| 62 | + - name: Setup Dafny |
| 63 | + uses: dafny-lang/[email protected] |
| 64 | + with: |
| 65 | + dafny-version: 4.9.0 |
| 66 | + |
| 67 | + # TODO: Remove this after the formatting in Rust starts working |
| 68 | + - name: smithy-dafny Rust hacks |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 72 | + sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' smithy-dafny/SmithyDafnyMakefile.mk |
| 73 | + else |
| 74 | + sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' smithy-dafny/SmithyDafnyMakefile.mk |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Setup Java 17 for codegen |
| 78 | + uses: actions/setup-java@v3 |
| 79 | + with: |
| 80 | + distribution: "corretto" |
| 81 | + java-version: "17" |
| 82 | + |
| 83 | + - name: Setup NASM for Windows (aws-lc-sys) |
| 84 | + if: matrix.os == 'windows-latest' |
| 85 | + uses: ilammy/setup-nasm@v1 |
| 86 | + |
| 87 | + - name: Install Smithy-Dafny codegen dependencies |
| 88 | + uses: ./.github/actions/install_smithy_dafny_codegen_dependencies |
| 89 | + |
| 90 | + - name: Run make polymorph_rust |
| 91 | + shell: bash |
| 92 | + working-directory: ./${{ matrix.library }} |
| 93 | + run: | |
| 94 | + make polymorph_rust |
| 95 | +
|
| 96 | + - name: Compile ${{ matrix.library }} implementation |
| 97 | + shell: bash |
| 98 | + working-directory: ./${{ matrix.library }} |
| 99 | + run: | |
| 100 | + # This works because `node` is installed by default on GHA runners |
| 101 | + CORES=$(node -e 'console.log(os.cpus().length)') |
| 102 | + make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES |
| 103 | +
|
| 104 | + - name: Test ${{ matrix.library }} Rust |
| 105 | + shell: bash |
| 106 | + working-directory: ./${{ matrix.library }} |
| 107 | + run: | |
| 108 | + make test_rust |
0 commit comments