Skip to content

Commit e293cc7

Browse files
ci: streamline frontend workflow
1 parent 26b9ddc commit e293cc7

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

.github/workflows/frontend-test.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
jobs:
1313
test-and-coverage:
1414
runs-on: ubuntu-latest
15+
permissions:
16+
pull-requests: write # to add comments to the PRs
17+
contents: read
18+
1519
steps:
1620
- uses: actions/checkout@v4
1721

@@ -23,15 +27,24 @@ jobs:
2327
- name: Install dependencies
2428
run: npm ci
2529
working-directory: frontend
26-
30+
31+
# 1. RUN ONLY TESTS ON PUSH
32+
- name: Run frontend tests
33+
if: github.event_name == 'push'
34+
run: npm test
35+
working-directory: frontend
36+
37+
# 2. RUN COVERAGE ON PRs
2738
- name: Run jest with coverage
28-
run: npm run coverage
39+
if: github.event_name == 'pull_request'
40+
run: npx jest --coverage --coverageReporters json-summary
2941
working-directory: frontend
3042

31-
- name: Save coverage Artifact for the Workflow
43+
# 3. POST COMMENT ON PR
44+
- name: Jest Coverage Comment
3245
if: >
3346
github.event_name == 'pull_request'
34-
uses: actions/upload-artifact@v4
47+
uses: MishaKav/jest-coverage-comment@main
3548
with:
36-
name: jest-coverage
37-
path: frontend/coverage
49+
coverage-summary-path: ./frontend/coverage/coverage-summary.json
50+
title: Frontend Coverage Report

0 commit comments

Comments
 (0)