Skip to content

Commit a52ed40

Browse files
committed
chore: consolidate CI workflows and enhance coverage reporting logic
1 parent 448d77f commit a52ed40

File tree

2 files changed

+107
-130
lines changed

2 files changed

+107
-130
lines changed

.github/workflows/ci.yml

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@ on:
1717

1818
permissions:
1919
contents: read
20+
pull-requests: write
2021

2122
jobs:
2223
build:
2324
name: Build, Lint, Test, Type Check
2425
runs-on: ubuntu-latest
26+
timeout-minutes: 15
27+
if: >
28+
(
29+
github.event_name != 'pull_request' ||
30+
(
31+
github.event.pull_request.draft == false &&
32+
!contains(github.event.pull_request.title, 'WIP') &&
33+
!contains(github.event.pull_request.title, 'Work in progress') &&
34+
!contains(github.event.pull_request.title, '🚧')
35+
)
36+
)
37+
38+
env:
39+
NODE_OPTIONS: --max-old-space-size=4096
40+
41+
outputs:
42+
coverage_generated: ${{ steps.coverage_check.outputs.coverage_generated }}
2543

2644
steps:
2745
- name: Checkout repository
@@ -39,12 +57,12 @@ jobs:
3957
- name: Run linting
4058
run: npm run lint
4159

42-
- name: Run tests
43-
run: npm test
44-
4560
- name: Build application and start
4661
run: npm run build:start
4762

63+
- name: Run tests with coverage
64+
run: npm run test
65+
4866
- name: TypeScript type check
4967
run: npx tsc --noEmit
5068

@@ -59,3 +77,89 @@ jobs:
5977
else
6078
echo "All dependencies are up to date."
6179
fi
80+
81+
- name: Check if coverage file exists
82+
id: coverage_check
83+
run: |
84+
if [ -f coverage/lcov.info ]; then
85+
echo "coverage_generated=true" >> $GITHUB_OUTPUT
86+
else
87+
echo "coverage_generated=false" >> $GITHUB_OUTPUT
88+
fi
89+
90+
- name: Upload coverage artifacts
91+
if: steps.coverage_check.outputs.coverage_generated == 'true'
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: coverage-reports
95+
path: coverage/
96+
97+
pr-coverage-comment:
98+
name: PR Coverage Summary
99+
needs: build
100+
runs-on: ubuntu-latest
101+
if: github.event_name == 'pull_request' && needs.build.outputs.coverage_generated == 'true'
102+
103+
permissions:
104+
pull-requests: write
105+
contents: read
106+
107+
steps:
108+
- name: Checkout repository
109+
uses: actions/checkout@v4
110+
111+
- name: Download coverage artifacts
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: coverage-reports
115+
path: coverage/
116+
117+
- name: Generate coverage summary
118+
uses: irongut/CodeCoverageSummary@v1.3.0
119+
with:
120+
filename: coverage/cobertura-coverage.xml
121+
badge: true
122+
format: markdown
123+
output: both
124+
indicators: true
125+
126+
- name: Post PR coverage comment
127+
uses: marocchino/sticky-pull-request-comment@v2
128+
with:
129+
header: "pr-coverage-summary"
130+
recreate: true
131+
path: code-coverage-results.md
132+
133+
codecov-upload:
134+
name: Upload Coverage to Codecov
135+
needs: build
136+
runs-on: ubuntu-latest
137+
if: >
138+
needs.build.outputs.coverage_generated == 'true' &&
139+
(
140+
github.event_name != 'pull_request' ||
141+
(
142+
!contains(github.event.pull_request.title, 'WIP') &&
143+
!contains(github.event.pull_request.title, 'Work in progress') &&
144+
!contains(github.event.pull_request.title, '🚧') &&
145+
!contains(github.event.pull_request.title, '!COV')
146+
)
147+
)
148+
149+
steps:
150+
- name: Checkout repository
151+
uses: actions/checkout@v4
152+
153+
- name: Download coverage artifacts
154+
uses: actions/download-artifact@v4
155+
with:
156+
name: coverage-reports
157+
path: coverage/
158+
159+
- name: Upload coverage to Codecov
160+
uses: codecov/codecov-action@v5
161+
with:
162+
token: ${{ secrets.CODECOV_TOKEN }}
163+
files: coverage/lcov.info
164+
flags: unittests
165+
name: codecov-coverage-report

.github/workflows/coverage-workflow.yml

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)