|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + merge_group: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ci-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +env: |
| 13 | + CARGO_TERM_COLOR: always |
| 14 | + |
| 15 | +jobs: |
| 16 | + maybe-expedite: |
| 17 | + outputs: |
| 18 | + value: ${{ steps.expedite.outputs.value }} |
| 19 | + |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Log github refs |
| 24 | + run: | |
| 25 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 26 | + echo 'github.ref: ${{ github.ref }}' >> "$GITHUB_STEP_SUMMARY" |
| 27 | + echo 'github.sha: ${{ github.sha }}' >> "$GITHUB_STEP_SUMMARY" |
| 28 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 29 | +
|
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + |
| 34 | + - name: Check if merging an up-to-date branch |
| 35 | + if: ${{ github.event_name == 'merge_group' }} |
| 36 | + id: expedite |
| 37 | + run: | |
| 38 | + N="$(expr "${{ github.ref }}" : '.*-\([0-9]\+\)-[^-]*$')" |
| 39 | + BASE_SHA="$(gh api /repos/${{ github.repository }}/pulls/"$N" | jq -r '.base.sha')" |
| 40 | + if git diff --quiet ${{ github.event.merge_group.base_sha }} "$BASE_SHA"; then |
| 41 | + echo "value=1" >> "$GITHUB_OUTPUT" |
| 42 | + fi |
| 43 | + env: |
| 44 | + GH_TOKEN: ${{ github.token }} |
| 45 | + |
| 46 | + test: |
| 47 | + needs: [maybe-expedite] |
| 48 | + |
| 49 | + if: ${{ ! needs.maybe-expedite.outputs.value }} |
| 50 | + |
| 51 | + strategy: |
| 52 | + fail-fast: ${{ github.event_name == 'merge_group' }} |
| 53 | + matrix: |
| 54 | + environment: [ubuntu-latest, macos-latest] |
| 55 | + |
| 56 | + runs-on: ${{ matrix.environment }} |
| 57 | + |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - uses: actions/cache@v4 |
| 62 | + with: |
| 63 | + path: | |
| 64 | + ~/.cargo/bin/ |
| 65 | + ~/.cargo/registry/index/ |
| 66 | + ~/.cargo/registry/cache/ |
| 67 | + ~/.cargo/git/db/ |
| 68 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 69 | + |
| 70 | + - name: Install tools |
| 71 | + run: | |
| 72 | + rustup install nightly |
| 73 | + rustup +nightly component add clippy |
| 74 | + cargo install cargo-dylint dylint-link || true |
| 75 | + cargo install cargo-hack || true |
| 76 | + cargo install cargo-udeps --locked || true |
| 77 | + cargo install group-runner || true |
| 78 | +
|
| 79 | + - name: Build |
| 80 | + run: cargo test --no-run |
| 81 | + |
| 82 | + - name: Test |
| 83 | + run: cargo test --config "target.'cfg(all())'.runner = 'group-runner'" |
| 84 | + |
| 85 | + all-checks: |
| 86 | + needs: [test] |
| 87 | + |
| 88 | + if: ${{ always() }} |
| 89 | + |
| 90 | + runs-on: ubuntu-latest |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Check results |
| 94 | + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |
| 95 | + run: exit 1 |
0 commit comments