Skip to content

Commit 84de9f1

Browse files
committed
ci: fix coverage job failing on main
1 parent 49b0616 commit 84de9f1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/unit-tests.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,41 @@ jobs:
6161
npm ci
6262
npm run coverage
6363
mv coverage/coverage-summary.json ${{ runner.temp }}/coverage-main-summary.json
64+
65+
- name: Upload Artifact (main)
66+
uses: actions/upload-artifact@v4
67+
if: github.event_name != 'pull_request'
68+
with:
69+
name: coverage-report
70+
path: coverage
71+
retention-days: 14
6472

6573
- name: Checkout PR Branch
74+
if: github.event_name == 'pull_request'
6675
uses: actions/checkout@v4
6776
with:
6877
clean: true
6978

7079
- name: Install & Test (PR)
80+
if: github.event_name == 'pull_request'
7181
run: |
7282
npm ci
7383
npm run coverage
84+
85+
- name: Upload Artifact (PR)
86+
id: upload-artifact-pr
87+
uses: actions/upload-artifact@v4
88+
if: github.event_name == 'pull_request'
89+
with:
90+
name: coverage-report
91+
path: coverage
92+
retention-days: 14
7493

75-
- name: Report Coverage Delta
94+
- name: Post Comment
7695
uses: actions/github-script@v6
96+
if: github.event_name == 'pull_request'
97+
env:
98+
ARTIFACT_URL: ${{ steps.upload-artifact-pr.outputs.artifact-url }}
7799
with:
78100
script: |
79101
const fs = require('fs');
@@ -83,6 +105,7 @@ jobs:
83105
};
84106
85107
let markdown = `### 🧪 Code Coverage Delta\n\n`;
108+
markdown += `[⬇️ **Download HTML Report**](${artifactUrl})\n\n`;
86109
markdown += `| Metric | Main | PR | Delta |\n`;
87110
markdown += `| :--- | :---: | :---: | :---: |\n`;
88111

0 commit comments

Comments
 (0)