|
8 | 8 | branches: |
9 | 9 | - main |
10 | 10 |
|
| 11 | +# Superseded runs on the same PR/branch waste runners and delay feedback; |
| 12 | +# cancel them. Push runs to main group by commit ref as well, so an in-flight |
| 13 | +# main run is cancelled only by a newer main push. |
| 14 | +concurrency: |
| 15 | + group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
11 | 18 | jobs: |
12 | 19 | filter: |
13 | 20 | runs-on: ubuntu-latest |
|
56 | 63 | steps: |
57 | 64 | - name: Checkout repository |
58 | 65 | uses: actions/checkout@v7 |
| 66 | + with: |
| 67 | + # Full history so `turbo --affected` can diff against the PR base. |
| 68 | + fetch-depth: 0 |
59 | 69 |
|
60 | 70 | - name: Setup Node.js |
61 | 71 | uses: actions/setup-node@v6 |
@@ -93,13 +103,29 @@ jobs: |
93 | 103 | - name: Install dependencies |
94 | 104 | run: pnpm install --frozen-lockfile |
95 | 105 |
|
96 | | - - name: Run all tests |
97 | | - run: pnpm turbo run test |
| 106 | + # PRs: only test packages affected by the diff against the PR base. |
| 107 | + # spec sits at the root of the dependency graph, so spec-touching PRs |
| 108 | + # still run (close to) everything — but the many PRs that don't touch |
| 109 | + # spec skip the bulk of the 75-package matrix. |
| 110 | + - name: Run affected tests (PR) |
| 111 | + if: github.event_name == 'pull_request' |
| 112 | + env: |
| 113 | + TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }} |
| 114 | + run: pnpm turbo run test --affected |
| 115 | + |
| 116 | + # Push to main: full run, but exclude spec's plain test task — the |
| 117 | + # coverage step below executes the exact same 250-file spec suite once, |
| 118 | + # with coverage. Previously the spec suite ran twice per push. |
| 119 | + - name: Run all tests (push) |
| 120 | + if: github.event_name == 'push' |
| 121 | + run: pnpm turbo run test --filter=!@objectstack/spec |
98 | 122 |
|
99 | 123 | - name: Generate coverage report |
| 124 | + if: github.event_name == 'push' |
100 | 125 | run: pnpm --filter @objectstack/spec test:coverage |
101 | 126 |
|
102 | 127 | - name: Upload coverage reports |
| 128 | + if: github.event_name == 'push' |
103 | 129 | uses: actions/upload-artifact@v7 |
104 | 130 | with: |
105 | 131 | name: coverage-report |
|
0 commit comments