|
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | build: |
| 11 | + name: Lint, test & build |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 |
|
13 | 14 | steps: |
14 | 15 | - uses: actions/checkout@v5 |
15 | 16 |
|
16 | 17 | - uses: actions/setup-node@v5 |
17 | 18 | with: |
18 | | - node-version: 22 |
| 19 | + node-version: 24 |
19 | 20 | cache: npm |
20 | 21 |
|
21 | 22 | - run: npm ci |
|
28 | 29 |
|
29 | 30 | - name: Build |
30 | 31 | run: npm run build |
| 32 | + |
| 33 | + # Catches an omission that would otherwise only surface after publishing. |
| 34 | + - name: Verify package contents |
| 35 | + run: npm run verify:package |
| 36 | + |
| 37 | + # The compatibility matrix consumes exactly what would be published, |
| 38 | + # so pack once here instead of rebuilding per Angular version. |
| 39 | + - name: Pack |
| 40 | + run: | |
| 41 | + npm pack --pack-destination "$RUNNER_TEMP" --silent |
| 42 | + mv "$RUNNER_TEMP"/*.tgz "$GITHUB_WORKSPACE/package.tgz" |
| 43 | + working-directory: dist/ngx-api-client |
| 44 | + |
| 45 | + - uses: actions/upload-artifact@v4 |
| 46 | + with: |
| 47 | + name: package-tarball |
| 48 | + path: package.tgz |
| 49 | + retention-days: 1 |
| 50 | + |
| 51 | + versions: |
| 52 | + # Derived from the library's `@angular/core` peer range so the matrix cannot |
| 53 | + # drift from what the package claims to support. |
| 54 | + name: Resolve supported Angular versions |
| 55 | + runs-on: ubuntu-latest |
| 56 | + outputs: |
| 57 | + angular: ${{ steps.derive.outputs.angular }} |
| 58 | + |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v5 |
| 61 | + |
| 62 | + - id: derive |
| 63 | + run: echo "angular=$(node scripts/check-angular-compat.mjs --list)" >> "$GITHUB_OUTPUT" |
| 64 | + |
| 65 | + compat: |
| 66 | + # The workspace builds on the newest Angular, but the package supports a |
| 67 | + # range of majors. Install the packed tarball into a throwaway consumer |
| 68 | + # project per combination and type-check, bundle and run it there, so the |
| 69 | + # supported range is verified rather than asserted. |
| 70 | + name: Angular ${{ matrix.angular }} / Node ${{ matrix.node }} |
| 71 | + needs: [build, versions] |
| 72 | + runs-on: ubuntu-latest |
| 73 | + |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + angular: ${{ fromJSON(needs.versions.outputs.angular) }} |
| 78 | + node: [22, 24] |
| 79 | + |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v5 |
| 82 | + |
| 83 | + - uses: actions/setup-node@v5 |
| 84 | + with: |
| 85 | + node-version: ${{ matrix.node }} |
| 86 | + |
| 87 | + - uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + name: package-tarball |
| 90 | + |
| 91 | + - name: Verify against Angular ${{ matrix.angular }} |
| 92 | + run: | |
| 93 | + npm run compat -- ${{ matrix.angular }} \ |
| 94 | + --tarball package.tgz \ |
| 95 | + --report "compat-${{ matrix.angular }}-node${{ matrix.node }}.json" |
| 96 | +
|
| 97 | + # `always()`: a failed combination still belongs in the summary table. |
| 98 | + - if: always() |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: compat-result-${{ matrix.angular }}-node${{ matrix.node }} |
| 102 | + path: compat-*.json |
| 103 | + retention-days: 1 |
| 104 | + if-no-files-found: ignore |
| 105 | + |
| 106 | + report: |
| 107 | + name: Compatibility report |
| 108 | + needs: compat |
| 109 | + if: always() |
| 110 | + runs-on: ubuntu-latest |
| 111 | + |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v5 |
| 114 | + |
| 115 | + - uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + pattern: compat-result-* |
| 118 | + path: compat-results |
| 119 | + |
| 120 | + - name: Publish compatibility table |
| 121 | + run: node scripts/compat-report.mjs compat-results >> "$GITHUB_STEP_SUMMARY" |
0 commit comments