Skip to content

Commit 3c300a8

Browse files
authored
code coverage reporting (#1425)
Upload coverage from test jobs, merge and report coverage from "coverage" job.
1 parent 29f2217 commit 3c300a8

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

.github/workflows/ci-linux.yml

+48-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ env:
1313
MYSQL_DATABASE: test
1414

1515
jobs:
16+
cleanup:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Delete artifacts
20+
uses: jimschubert/delete-artifacts-action@v1
21+
with:
22+
log_level: 'debug'
23+
min_bytes: '0'
24+
pattern: '\.xml'
25+
1626
tests-linux:
27+
needs: [ cleanup ]
1728
runs-on: ubuntu-latest
1829
strategy:
1930
fail-fast: false
@@ -71,5 +82,41 @@ jobs:
7182
run: npm ci
7283
- name: Wait mysql server is ready
7384
run: node tools/wait-up.js
85+
7486
- name: Run tests
75-
run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm test
87+
run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm run coverage-test
88+
89+
- run: echo "coverage-artifact-name=`echo -n "${{github.run_id}}-${{ matrix.node-version }}-${{ matrix.mysql-version }}-${{matrix.use-tls}}-${{matrix.use-compression}}" | shasum | cut -d " " -f 1`" >> $GITHUB_ENV
90+
- uses: actions/upload-artifact@v2
91+
with:
92+
name: coverage-${{env.coverage-artifact-name}}
93+
path: coverage/cobertura-coverage.xml
94+
95+
coverage:
96+
needs: [ tests-linux ]
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v2
100+
- name: Restore coverage
101+
uses: actions/download-artifact@v2
102+
with:
103+
path: coverage
104+
105+
- name: get list of coverage files
106+
run: echo "coverage-files=`find coverage | grep xml | paste -s -d\; -`" >> $GITHUB_ENV
107+
108+
- name: ReportGenerator
109+
uses: danielpalme/[email protected]
110+
with:
111+
reports: "${{ env.coverage-files }}"
112+
targetdir: '.'
113+
reporttypes: 'Cobertura'
114+
115+
- name: Debug
116+
run: cat Cobertura.xml
117+
118+
- name: Display coverage
119+
uses: ewjoachim/coverage-comment-action@v1
120+
with:
121+
COVERAGE_FILE: "Cobertura.xml"
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
1212
"lint:docs": "eslint Contributing.md \"documentation/**/*.md\" \"examples/*.js\"",
1313
"test": "node ./test/run.js",
14-
"coverage-test": "c8 -r lcov -r text node ./test/run.js",
14+
"coverage-test": "c8 -r cobertura -r lcov -r text node ./test/run.js",
1515
"benchmark": "node ./benchmarks/benchmark.js",
1616
"prettier": "prettier --single-quote --trailing-comma none --write \"{lib,examples,test}/**/*.js\"",
1717
"prettier:docs": "prettier --single-quote --trailing-comma none --write README.md documentation/*",

0 commit comments

Comments
 (0)