|
10 | 10 | test: |
11 | 11 | name: Test |
12 | 12 | runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + id-token: write |
13 | 16 | strategy: |
14 | 17 | matrix: |
15 | 18 | node-version: [18.x, 20.x] |
@@ -39,15 +42,37 @@ jobs: |
39 | 42 | - name: Run tests |
40 | 43 | run: npm run test:coverage |
41 | 44 |
|
42 | | - - name: Upload coverage to Codecov |
| 45 | + # 🔹 Always upload the coverage folder so you can inspect reports from CI runs |
| 46 | + - name: Upload coverage artifact |
| 47 | + if: always() |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: coverage-${{ matrix.node-version }} |
| 51 | + path: coverage/ |
| 52 | + retention-days: 7 |
| 53 | + |
| 54 | + # 🔹 Codecov upload using OIDC (skips forked PRs) |
| 55 | + - name: Upload coverage to Codecov (OIDC) |
| 56 | + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false }} |
43 | 57 | uses: codecov/codecov-action@v5 |
44 | 58 | with: |
45 | | - token: ${{ secrets.CODECOV_TOKEN }} # or set `use_oidc: true` + permissions |
| 59 | + use_oidc: true |
46 | 60 | files: ./coverage/lcov.info |
47 | 61 | flags: unittests |
48 | 62 | name: codecov-umbrella |
49 | 63 | fail_ci_if_error: true |
50 | 64 |
|
| 65 | + # 🔹 Best-effort Codecov on forked PRs (won't fail CI if upload is blocked) |
| 66 | + - name: Upload coverage to Codecov (best-effort on forks) |
| 67 | + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }} |
| 68 | + uses: codecov/codecov-action@v5 |
| 69 | + with: |
| 70 | + use_oidc: true |
| 71 | + files: ./coverage/lcov.info |
| 72 | + flags: unittests |
| 73 | + name: codecov-umbrella |
| 74 | + fail_ci_if_error: false |
| 75 | + |
51 | 76 | build: |
52 | 77 | name: Build |
53 | 78 | runs-on: ubuntu-latest |
@@ -142,4 +167,3 @@ jobs: |
142 | 167 | - name: Run dependency check |
143 | 168 | if: github.event_name == 'pull_request' |
144 | 169 | uses: actions/dependency-review-action@v4 |
145 | | - |
|
0 commit comments