|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | +env: |
| 11 | + # we call `pnpm playwright install` instead |
| 12 | + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' |
| 13 | + |
| 14 | +# cancel in-progress runs on new commits to same PR (gitub.event.number) |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.number || github.sha }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +# use min permissions |
| 20 | +permissions: |
| 21 | + contents: read # to fetch code (actions/checkout) |
| 22 | + |
| 23 | +jobs: |
| 24 | + # "checks" job runs on linux + node lts only and checks that install, build, lint and audit work |
| 25 | + # it also primes the pnpm store cache for linux, important for downstream tests |
| 26 | + checks: |
| 27 | + timeout-minutes: 5 |
| 28 | + runs-on: ${{ matrix.os }} |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + # pseudo-matrix for convenience, NEVER use more than a single combination |
| 32 | + node: [22] |
| 33 | + os: [ubuntu-latest] |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + - uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: ${{ matrix.node }} |
| 39 | + - name: install pnpm |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json) |
| 43 | + echo installing pnpm version $PNPM_VER |
| 44 | + npm i -g pnpm@$PNPM_VER |
| 45 | + - uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version: ${{ matrix.node }} |
| 48 | + cache: 'pnpm' |
| 49 | + cache-dependency-path: '**/pnpm-lock.yaml' |
| 50 | + - name: install |
| 51 | + run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts |
| 52 | + - name: format |
| 53 | + run: pnpm check:format |
| 54 | + - name: lint |
| 55 | + if: (${{ success() }} || ${{ failure() }}) |
| 56 | + run: pnpm check:lint |
| 57 | + - name: types |
| 58 | + if: (${{ success() }} || ${{ failure() }}) |
| 59 | + run: pnpm check:types |
| 60 | + - name: audit |
| 61 | + if: (${{ success() }} || ${{ failure() }}) |
| 62 | + run: pnpm check:audit |
| 63 | + - name: publint |
| 64 | + if: (${{ success() }} || ${{ failure() }}) |
| 65 | + run: pnpm check:publint |
| 66 | + - name: generated types are up to date |
| 67 | + if: (${{ success() }} || ${{ failure() }}) |
| 68 | + run: pnpm generate:types && [ "`git status --porcelain=v1`" == "" ] |
| 69 | + |
| 70 | + # "test" job runs on linux, windows, mac with node active lts and linux with node maintenance lts |
| 71 | + test: |
| 72 | + timeout-minutes: 10 |
| 73 | + runs-on: ${{ matrix.os }} |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + node: [22] |
| 78 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 79 | + include: |
| 80 | + - node: 18 |
| 81 | + os: ubuntu-latest |
| 82 | + - node: 20 |
| 83 | + os: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + - uses: actions/setup-node@v4 |
| 87 | + with: |
| 88 | + node-version: ${{ matrix.node }} |
| 89 | + - name: install pnpm |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json) |
| 93 | + echo installing pnpm version $PNPM_VER |
| 94 | + npm i -g pnpm@$PNPM_VER |
| 95 | + - uses: actions/setup-node@v4 |
| 96 | + with: |
| 97 | + node-version: ${{ matrix.node }} |
| 98 | + cache: 'pnpm' |
| 99 | + cache-dependency-path: '**/pnpm-lock.yaml' |
| 100 | + - name: install |
| 101 | + run: pnpm install --frozen-lockfile --ignore-scripts |
| 102 | + - name: install playwright chromium |
| 103 | + run: pnpm playwright install chromium |
| 104 | + - name: run tests |
| 105 | + run: pnpm test |
| 106 | + - name: archive tests temp directory |
| 107 | + if: failure() |
| 108 | + shell: bash |
| 109 | + run: tar -cvf test-temp.tar --exclude="node_modules" temp/ |
| 110 | + - uses: actions/upload-artifact@v4 |
| 111 | + if: failure() |
| 112 | + with: |
| 113 | + name: test-failure-${{github.run_id}}-${{ matrix.os }}-${{ matrix.node }} |
| 114 | + path: | |
| 115 | + test-temp.tar |
| 116 | + pnpm-debug.log |
0 commit comments