|
| 1 | +# build and test |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master |
| 11 | + |
| 12 | +jobs: |
| 13 | + # "checks" job runs on linux + 16 only and checks that install, build, lint and audit work |
| 14 | + # it also primes the pnpm store cache for linux, important for downstream tests |
| 15 | + checks: |
| 16 | + timeout-minutes: 5 |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + # pseudo-matrix for convenience, NEVER use more than a single combination |
| 21 | + node: [16] |
| 22 | + os: [ubuntu-latest] |
| 23 | + outputs: |
| 24 | + build_successful: ${{ steps.build.outcome == 'success' }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - uses: actions/setup-node@v3 |
| 28 | + with: |
| 29 | + node-version: ${{ matrix.node }} |
| 30 | + - run: npm i -g pnpm@6 |
| 31 | + - uses: actions/setup-node@v3 |
| 32 | + with: |
| 33 | + node-version: ${{ matrix.node }} |
| 34 | + cache: 'pnpm' |
| 35 | + cache-dependency-path: '**/pnpm-lock.yaml' |
| 36 | + - name: install |
| 37 | + run: pnpm install --frozen-lockfile --prefer-offline |
| 38 | +# reactivate this when there is a build step |
| 39 | +# - name: build |
| 40 | +# id: build |
| 41 | +# run: pnpm run build |
| 42 | + - name: lint |
| 43 | + if: (${{ success() }} || ${{ failure() }}) |
| 44 | + run: pnpm run lint |
| 45 | + - name: audit |
| 46 | + if: (${{ success() }} || ${{ failure() }}) |
| 47 | + run: pnpm audit |
| 48 | + |
| 49 | + # this is the test matrix |
| 50 | + # it is skipped if the build step of the checks job wasn't successful (still runs if lint or audit fail) |
| 51 | + test: |
| 52 | + needs: checks |
| 53 | + if: (${{ success() }} || ${{ failure() }}) && (${{ needs.checks.output.build_successful }}) |
| 54 | + timeout-minutes: 10 |
| 55 | + runs-on: ${{ matrix.os }} |
| 56 | + strategy: |
| 57 | + fail-fast: false |
| 58 | + matrix: |
| 59 | + os: [ ubuntu-latest, macos-latest ] |
| 60 | + node: [ 14, 16 ] |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v2 |
| 63 | + - uses: actions/setup-node@v3 |
| 64 | + with: |
| 65 | + node-version: ${{ matrix.node }} |
| 66 | + - run: npm i -g pnpm@6 |
| 67 | + - uses: actions/setup-node@v3 |
| 68 | + with: |
| 69 | + node-version: ${{ matrix.node }} |
| 70 | + cache: 'pnpm' |
| 71 | + cache-dependency-path: '**/pnpm-lock.yaml' |
| 72 | + - name: install |
| 73 | + run: pnpm install --frozen-lockfile --prefer-offline |
| 74 | + - name: run tests |
| 75 | + run: pnpm test |
0 commit comments