|
1 |
| -name: Lint & Test |
| 1 | +name: Test |
2 | 2 |
|
3 | 3 | on:
|
4 |
| - workflow_call: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - isn-renovate/** # branches generated by https://github.com/apps/isn-renovate |
5 | 7 | pull_request:
|
6 | 8 | branches:
|
7 | 9 | - main
|
| 10 | + workflow_call: |
| 11 | + secrets: |
| 12 | + CODECOV_TOKEN: |
| 13 | + required: true |
8 | 14 |
|
9 | 15 | jobs:
|
10 |
| - lint-and-test: |
11 |
| - runs-on: ${{ matrix.os }} |
| 16 | + test_matrix: |
12 | 17 | strategy:
|
13 | 18 | matrix:
|
14 | 19 | os: [ubuntu-latest, windows-latest, macos-latest]
|
| 20 | + node-version: [18, 20, 21] |
| 21 | + |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + timeout-minutes: 5 |
15 | 24 |
|
16 | 25 | steps:
|
17 | 26 | - name: Checkout project
|
18 | 27 | uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
19 | 28 | with:
|
20 | 29 | fetch-depth: 0
|
21 |
| - - name: Use Node.js |
| 30 | + |
| 31 | + - name: Use Node.js ${{ matrix.node-version }} |
22 | 32 | uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
|
23 | 33 | with:
|
24 |
| - node-version: 'lts/*' |
| 34 | + node-version: ${{ matrix.node-version }} |
| 35 | + cache: npm |
| 36 | + |
25 | 37 | - name: Install packages
|
26 | 38 | run: npm ci
|
| 39 | + |
| 40 | + - name: Audit npm signatures |
| 41 | + run: npm audit signatures |
| 42 | + |
27 | 43 | - name: Check codestyle compliance
|
28 | 44 | run: npm run lint
|
| 45 | + |
29 | 46 | - name: Run tests
|
30 | 47 | run: npm run test
|
31 | 48 |
|
32 |
| - # Ensure commitlint is working with HEAD version of our preset |
33 |
| - - name: Validate current commit (last commit) with commitlint |
| 49 | + - name: Ensure commitlint works with our current config (push event) |
34 | 50 | if: github.event_name == 'push'
|
35 | 51 | run: npx commitlint --from HEAD~1 --to HEAD --verbose
|
36 |
| - - name: Validate PR commits with commitlint |
| 52 | + - name: Ensure commitlint works with our current config (pull_request event) |
37 | 53 | if: github.event_name == 'pull_request'
|
38 | 54 | run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
|
39 | 55 |
|
40 | 56 | - name: Upload coverage reports to Codecov
|
41 |
| - if: ${{ matrix.os == 'ubuntu-latest' }} |
| 57 | + if: strategy.job-index == 0 |
42 | 58 | uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3
|
43 | 59 | with:
|
44 | 60 | token: ${{ secrets.CODECOV_TOKEN }}
|
45 | 61 | files: coverage/coverage-final.json
|
46 | 62 | fail_ci_if_error: true
|
| 63 | + |
| 64 | + # separate job to set as required status check in branch protection |
| 65 | + required_check: |
| 66 | + runs-on: ubuntu-latest |
| 67 | + needs: |
| 68 | + - test_matrix |
| 69 | + if: always() |
| 70 | + steps: |
| 71 | + - name: All required jobs and matrix versions passed |
| 72 | + if: ${{ !(contains(needs.*.result, 'failure')) }} |
| 73 | + run: exit 0 |
| 74 | + - name: Some required jobs or matrix versions failed |
| 75 | + if: ${{ contains(needs.*.result, 'failure') }} |
| 76 | + run: exit 1 |
0 commit comments