|
| 1 | +name: Noir tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + MINIMUM_NOIR_VERSION: v1.0.0-beta.3 |
| 12 | + |
| 13 | +jobs: |
| 14 | + noir-version-list: |
| 15 | + name: Query supported Noir versions |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + noir_versions: ${{ steps.get_versions.outputs.versions }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout sources |
| 22 | + id: get_versions |
| 23 | + run: | |
| 24 | + # gh returns the Noir releases in reverse chronological order so we keep all releases published after the minimum supported version. |
| 25 | + VERSIONS=$(gh release list -R noir-lang/noir --exclude-pre-releases --json tagName -q 'map(.tagName) | index(env.MINIMUM_NOIR_VERSION) as $index | if $index then .[0:$index+1] else [env.MINIMUM_NOIR_VERSION] end') |
| 26 | + echo "versions=$VERSIONS" |
| 27 | + echo "versions=$VERSIONS" >> $GITHUB_OUTPUT |
| 28 | + env: |
| 29 | + GH_TOKEN: ${{ github.token }} |
| 30 | + |
| 31 | + test: |
| 32 | + needs: [noir-version-list] |
| 33 | + name: Test on Nargo ${{matrix.toolchain}} |
| 34 | + runs-on: ubuntu-latest |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + toolchain: ${{ fromJson( needs.noir-version-list.outputs.noir_versions )}} |
| 39 | + include: |
| 40 | + - toolchain: nightly |
| 41 | + steps: |
| 42 | + - name: Checkout sources |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Install Nargo |
| 46 | + |
| 47 | + with: |
| 48 | + toolchain: ${{ matrix.toolchain }} |
| 49 | + |
| 50 | + - name: Run Noir tests |
| 51 | + run: nargo test |
| 52 | + |
| 53 | + format: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Checkout sources |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Install Nargo |
| 60 | + |
| 61 | + with: |
| 62 | + toolchain: ${{env.MINIMUM_NOIR_VERSION}} |
| 63 | + |
| 64 | + - name: Run formatter |
| 65 | + run: nargo fmt --check |
| 66 | + |
| 67 | + # This is a job which depends on all test jobs and reports the overall status. |
| 68 | + # This allows us to add/remove test jobs without having to update the required workflows. |
| 69 | + tests-end: |
| 70 | + name: Noir End |
| 71 | + runs-on: ubuntu-latest |
| 72 | + # We want this job to always run (even if the dependant jobs fail) as we want this job to fail rather than skipping. |
| 73 | + if: ${{ always() }} |
| 74 | + needs: |
| 75 | + - test |
| 76 | + - format |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Report overall success |
| 80 | + run: | |
| 81 | + if [[ $FAIL == true ]]; then |
| 82 | + exit 1 |
| 83 | + else |
| 84 | + exit 0 |
| 85 | + fi |
| 86 | + env: |
| 87 | + # We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole. |
| 88 | + FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }} |
0 commit comments