|
| 1 | +# This workflow performs tests in Go. |
| 2 | +name: Library Go 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 | + testGo: |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + library: |
| 23 | + [ |
| 24 | + StandardLibrary, |
| 25 | + ] |
| 26 | + go-version: ["1.23"] |
| 27 | + os: [ |
| 28 | + # TODO fix Dafny-generated tests on Windows; |
| 29 | + # the sys.path workaround for generated Dafny doesn't work on Windows. |
| 30 | + # Note: only tests use the sys.path workaround, not source code. |
| 31 | + # Windows source code is tested downstream (ex. ESDK-Python CI). |
| 32 | + # windows-latest, |
| 33 | + ubuntu-latest, |
| 34 | + macos-13, |
| 35 | + ] |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + defaults: |
| 38 | + run: |
| 39 | + shell: bash |
| 40 | + permissions: |
| 41 | + id-token: write |
| 42 | + contents: read |
| 43 | + steps: |
| 44 | + - name: Support longpaths on Git checkout |
| 45 | + run: | |
| 46 | + git config --global core.longpaths true |
| 47 | +
|
| 48 | + - name: Configure AWS Credentials |
| 49 | + uses: aws-actions/configure-aws-credentials@v4 |
| 50 | + with: |
| 51 | + aws-region: us-west-2 |
| 52 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2 |
| 53 | + role-session-name: GoTests |
| 54 | + |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + # The specification submodule is private so we don't have access, but we don't need |
| 57 | + # it to verify the Dafny code. Instead we manually pull the submodules we DO need. |
| 58 | + - run: git submodule update --init libraries |
| 59 | + - run: git submodule update --init smithy-dafny |
| 60 | + |
| 61 | + - name: Setup Dafny |
| 62 | + uses: dafny-lang/setup-dafny-action@v1.7.0 |
| 63 | + with: |
| 64 | + dafny-version: ${{ inputs.dafny }} |
| 65 | + |
| 66 | + - name: Install Go |
| 67 | + uses: actions/setup-go@v2 |
| 68 | + with: |
| 69 | + go-version: ${{ matrix.go-version }} |
| 70 | + |
| 71 | + - name: Install Go imports |
| 72 | + run: | |
| 73 | + go install golang.org/x/tools/cmd/goimports@latest |
| 74 | +
|
| 75 | + - name: Build ${{ matrix.library }} implementation |
| 76 | + working-directory: ./${{ matrix.library }} |
| 77 | + run: | |
| 78 | + # This works because `node` is installed by default on GHA runners |
| 79 | + CORES=$(node -e 'console.log(os.cpus().length)') |
| 80 | + make transpile_go CORES=$CORES |
| 81 | +
|
| 82 | + - name: Test ${{ matrix.library }} |
| 83 | + working-directory: ./${{ matrix.library }} |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + make test_go |
0 commit comments