File tree Expand file tree Collapse file tree 1 file changed +33
-3
lines changed
Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change 2727 - name : Install dependencies
2828 run : npm ci
2929
30- # Run tests and collect coverage
31- - name : Run tests and generate coverage
32- run : npm test
30+ # Run tests and capture output
31+ - name : Run tests
32+ id : run_tests
33+ run : |
34+ {
35+ echo 'tests_report<<EOF'
36+ npm test 2>&1
37+ echo EOF
38+ } >> "$GITHUB_OUTPUT"
39+
40+ # Post comment on PR
41+ - name : Add JEST results as a PR comment
42+ uses : actions/github-script@v7
43+ with :
44+ script : |
45+ const steps = ${{ toJSON(steps) }};
46+ const marker = 'to show where the warning was created)';
47+ const output = steps.run_tests.outputs.tests_report;
48+ const sanitized = output.split(marker);
49+ const msg = (sanitized.length > 1) ? sanitized[1] : sanitized[0];
50+
51+ const prNumber = context.payload.issue.number;
52+
53+ if (sanitized.length >= 1) {
54+ github.rest.issues.createComment({
55+ owner: context.repo.owner,
56+ repo: context.repo.repo,
57+ issue_number: prNumber,
58+ body: msg,
59+ });
60+ } else {
61+ core.setFailed('No tests report data available.')
62+ }
You can’t perform that action at this time.
0 commit comments