Skip to content

Commit 0d92144

Browse files
authored
Merge pull request #994 from sir-gon/feature/html_report_test
[Github Actions] new test for HTML coverage report generation
2 parents 24e38ed + 5febd85 commit 0d92144

3 files changed

Lines changed: 76 additions & 8 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# yamllint disable rule:line-length
2+
# This workflow runs make coverage/html and verifies that the coverage HTML report is generated.
3+
# yamllint enable rule:line-length
4+
5+
---
6+
name: Make Coverage HTML
7+
8+
env:
9+
REPORT_DIR: "coverage/lcov-report"
10+
REPORT_FILE: "index.html"
11+
12+
on: # yamllint disable-line rule:truthy
13+
push:
14+
branches: ["main"]
15+
pull_request:
16+
branches: ["main"]
17+
workflow_dispatch:
18+
19+
jobs:
20+
make-coverage-html:
21+
name: "Run make coverage/html and verify coverage HTML"
22+
runs-on: ubuntu-24.04
23+
24+
steps:
25+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v6
28+
with:
29+
node-version: 24.x
30+
31+
- name: Tool test
32+
run: |
33+
echo "Node.js version:"
34+
node --version
35+
echo "GNU make version:"
36+
make --version
37+
38+
- name: Run coverage HTML target
39+
run: make coverage/html
40+
41+
- name: Verify coverage HTML artifact
42+
shell: bash
43+
run: |
44+
if [ ! -f $REPORT_DIR/$REPORT_FILE ]; then
45+
echo "Coverage HTML file not found: $REPORT_DIR/$REPORT_FILE"
46+
exit 1
47+
fi
48+
if [ ! -s $REPORT_DIR/$REPORT_FILE ]; then
49+
echo "Coverage HTML file is empty: $REPORT_DIR/$REPORT_FILE"
50+
exit 1
51+
fi
52+
53+
- name: Upload coverage HTML artifact
54+
uses: actions/upload-artifact@v7
55+
with:
56+
name: coverage-report-html
57+
path: ${{ env.REPORT_DIR }}

.github/workflows/node-coverage.js.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,26 @@ jobs:
2424
with:
2525
node-version: 24.x
2626

27-
- name: Install dependencies
28-
run: npm ci --verbose
27+
- name: Tool test
28+
run: |
29+
echo "Node.js version:"
30+
node --version
31+
echo "GNU make version:"
32+
make --version
2933
30-
- name: Lint
31-
run: npm run lint
34+
- name: Install dependencies
35+
run: make dependencies
3236

33-
- name: Run the tests
34-
run: npm run jest:ci -- --coverage
37+
- name: Run the tests with coverage
38+
run: make coverage
3539

3640
# Subir cobertura como artifact para que otros jobs lo usen
3741
- name: Upload coverage artifact
3842
uses: actions/upload-artifact@v7
43+
3944
with:
4045
name: coverage-report
41-
path: coverage # o la carpeta donde jest genera los reportes
46+
path: coverage
4247

4348

4449
codecov:

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ test: env dependencies
9494
coverage: test
9595

9696
coverage/html: coverage
97-
open coverage/lcov-report/index.html
97+
@if [ "$$(uname)" = "Darwin" ]; then \
98+
open ./coverage/lcov-report/index.htmll; \
99+
elif [ "$$(uname | tr '[:upper:]' '[:lower:]')" = "mingw32" ] || [ "$$(uname | tr '[:upper:]' '[:lower:]')" = "mingw64" ] || [ "$$(uname | tr '[:upper:]' '[:lower:]')" = "cygwin" ]; then \
100+
cmd /c start ./coverage/lcov-report/index.htmll; \
101+
else \
102+
echo "Coverage HTML generated: ./coverage/lcov-report/index.htmll"; \
103+
fi
98104

99105
outdated:
100106
-npm outdated

0 commit comments

Comments
 (0)