|
1 | | -name: CI Checks |
| 1 | +name: CI |
| 2 | + |
2 | 3 | on: |
3 | 4 | pull_request: |
4 | | - push: |
| 5 | + # merge queue is required so all commits on target branches trigger this workflow |
| 6 | + # despite lack of the push event trigger here |
| 7 | + merge_group: |
5 | 8 | branches: |
6 | 9 | - main |
7 | 10 |
|
8 | 11 | permissions: |
9 | | - contents: write |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.sha }} |
| 16 | + cancel-in-progress: true |
10 | 17 |
|
11 | 18 | jobs: |
12 | | - ci-checks: |
| 19 | + build: |
| 20 | + name: Build |
13 | 21 | runs-on: ubuntu-latest |
14 | 22 | steps: |
15 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 23 | + - name: Check out repo |
| 24 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
16 | 25 | with: |
17 | | - fetch-depth: 2 |
18 | | - - name: Use Node.js |
19 | | - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 |
| 26 | + persist-credentials: false |
| 27 | + |
| 28 | + - uses: ./.github/actions/ci-setup |
| 29 | + |
| 30 | + - name: Build |
| 31 | + run: pnpm build |
| 32 | + |
| 33 | + lint: |
| 34 | + name: Lint |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: Check out repo |
| 38 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
20 | 39 | with: |
21 | | - node-version: 24.x |
22 | | - - name: Extract pnpm version and install |
23 | | - run: | |
24 | | - VERSION=$(cat package.json | grep '"packageManager": "pnpm@' | sed 's/.*"pnpm@\([^"]*\)".*/\1/') |
25 | | - npm install -g pnpm@$VERSION |
26 | | - - uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 |
| 40 | + persist-credentials: false |
| 41 | + |
| 42 | + - uses: ./.github/actions/ci-setup |
| 43 | + |
| 44 | + - name: Codegen |
| 45 | + run: pnpm codegen:github |
| 46 | + |
| 47 | + - name: Lint |
| 48 | + run: pnpm lint |
| 49 | + |
| 50 | + - name: Format |
| 51 | + run: pnpm format:check |
| 52 | + |
| 53 | + test: |
| 54 | + name: Test |
| 55 | + runs-on: ubuntu-latest |
| 56 | + timeout-minutes: 20 |
| 57 | + # Integration tests push to the repo, which requires a token with write |
| 58 | + # access. Fork PRs only get a read-only GITHUB_TOKEN, so skip them here |
| 59 | + # and rely on merge_group to gate the merge. |
| 60 | + if: >- |
| 61 | + github.event_name != 'pull_request' || |
| 62 | + github.event.pull_request.head.repo.full_name == github.repository |
| 63 | + permissions: |
| 64 | + contents: write # integration tests create and push temporary branches |
| 65 | + steps: |
| 66 | + - name: Check out repo |
| 67 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 68 | + with: |
| 69 | + fetch-depth: 2 # integration tests read the two most recent local commits |
| 70 | + persist-credentials: false |
| 71 | + |
| 72 | + - uses: ./.github/actions/ci-setup |
27 | 73 | with: |
28 | | - path: ~/.pnpm-store |
29 | | - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} |
30 | | - - run: pnpm install --frozen-lockfile |
31 | | - - run: pnpm build |
32 | | - - run: pnpm lint |
33 | | - - run: pnpm format:check |
34 | | - - run: pnpm test:integration |
| 74 | + skip-cache: true # avoid cache poisoning from this only job with write access, just in case |
| 75 | + |
| 76 | + - name: Build |
| 77 | + run: pnpm build |
| 78 | + |
| 79 | + - name: Integration tests |
| 80 | + run: pnpm test:integration |
35 | 81 | env: |
36 | 82 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | | - HEAD_OID: ${{ github.base_ref }} |
| 83 | + |
| 84 | + ci-ok: |
| 85 | + name: CI OK |
| 86 | + runs-on: ubuntu-latest |
| 87 | + if: always() |
| 88 | + needs: [build, lint, test] |
| 89 | + steps: |
| 90 | + - name: Exit with error if some jobs are not successful |
| 91 | + if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} |
| 92 | + run: exit 1 |
0 commit comments