| 1 | name: CI |
| 2 | |
| 3 | # Deploy waits for this workflow to pass on main. The end-to-end suite is its own |
| 4 | # workflow (e2e.yml), so deploys don't wait for it too. |
| 5 | # |
| 6 | # Every job of this repository's workflows runs on the label in the repository variable |
| 7 | # DIFFINERY_RUNS_ON, else on `diffinery` (diffinery.com's GitHub runners) in |
| 8 | # codician-team/diffinery, else ubuntu-latest (a hosted runner on Diffinery too). GitHub passes |
| 9 | # no variables to pull requests from forks, so without that middle default they would run on |
| 10 | # GitHub's own runners. Other copies of the repository need nothing. |
| 11 | |
| 12 | on: |
| 13 | push: |
| 14 | branches: [main] |
| 15 | pull_request: |
| 16 | |
| 17 | permissions: |
| 18 | contents: read |
| 19 | |
| 20 | concurrency: |
| 21 | group: ci-${{ github.ref }} |
| 22 | cancel-in-progress: true |
| 23 | |
| 24 | jobs: |
| 25 | # Two jobs in parallel: each needs the install and build, but typecheck and the unit |
| 26 | # tests together took longer than either does alone. |
| 27 | typecheck: |
| 28 | name: Typecheck and bundle |
| 29 | runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }} |
| 30 | timeout-minutes: 20 |
| 31 | steps: |
| 32 | - uses: actions/checkout@v4 |
| 33 | - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 |
| 34 | - uses: actions/setup-node@v4 |
| 35 | with: |
| 36 | node-version: 22 |
| 37 | cache: pnpm |
| 38 | - run: pnpm install --frozen-lockfile |
| 39 | - name: Build |
| 40 | run: pnpm -r --if-present build |
| 41 | - name: Typecheck |
| 42 | run: pnpm -r --if-present typecheck |
| 43 | - name: Bundle the Worker (dry run) |
| 44 | working-directory: apps/diffinery |
| 45 | run: pnpm exec wrangler deploy --dry-run --env dev --outdir dist |
| 46 | |
| 47 | test: |
| 48 | name: Unit tests (${{ matrix.shard }}/2) |
| 49 | runs-on: ${{ vars.DIFFINERY_RUNS_ON || (github.repository == 'codician-team/diffinery' && 'diffinery') || 'ubuntu-latest' }} |
| 50 | timeout-minutes: 20 |
| 51 | # Two halves of every package's test files, side by side: CI is the first step of a deploy. |
| 52 | strategy: |
| 53 | fail-fast: false |
| 54 | matrix: |
| 55 | shard: [1, 2] |
| 56 | steps: |
| 57 | - uses: actions/checkout@v4 |
| 58 | - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 |
| 59 | - uses: actions/setup-node@v4 |
| 60 | with: |
| 61 | node-version: 22 |
| 62 | cache: pnpm |
| 63 | - run: pnpm install --frozen-lockfile |
| 64 | - name: Build |
| 65 | run: pnpm -r --if-present build |
| 66 | - name: Unit tests |
| 67 | run: pnpm -r --if-present run test --shard=${{ matrix.shard }}/2 |