Skip to content

Commit

Permalink
code coverage reporting (sidorares#1425)
Browse files Browse the repository at this point in the history
Upload coverage from test jobs, merge and report coverage from "coverage" job.
  • Loading branch information
sidorares authored Oct 18, 2021
1 parent 29f2217 commit 3c300a8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
49 changes: 48 additions & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ env:
MYSQL_DATABASE: test

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Delete artifacts
uses: jimschubert/delete-artifacts-action@v1
with:
log_level: 'debug'
min_bytes: '0'
pattern: '\.xml'

tests-linux:
needs: [ cleanup ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -71,5 +82,41 @@ jobs:
run: npm ci
- name: Wait mysql server is ready
run: node tools/wait-up.js

- name: Run tests
run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm test
run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm run coverage-test

- 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
- uses: actions/upload-artifact@v2
with:
name: coverage-${{env.coverage-artifact-name}}
path: coverage/cobertura-coverage.xml

coverage:
needs: [ tests-linux ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Restore coverage
uses: actions/download-artifact@v2
with:
path: coverage

- name: get list of coverage files
run: echo "coverage-files=`find coverage | grep xml | paste -s -d\; -`" >> $GITHUB_ENV

- name: ReportGenerator
uses: danielpalme/[email protected]
with:
reports: "${{ env.coverage-files }}"
targetdir: '.'
reporttypes: 'Cobertura'

- name: Debug
run: cat Cobertura.xml

- name: Display coverage
uses: ewjoachim/coverage-comment-action@v1
with:
COVERAGE_FILE: "Cobertura.xml"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
"lint:docs": "eslint Contributing.md \"documentation/**/*.md\" \"examples/*.js\"",
"test": "node ./test/run.js",
"coverage-test": "c8 -r lcov -r text node ./test/run.js",
"coverage-test": "c8 -r cobertura -r lcov -r text node ./test/run.js",
"benchmark": "node ./benchmarks/benchmark.js",
"prettier": "prettier --single-quote --trailing-comma none --write \"{lib,examples,test}/**/*.js\"",
"prettier:docs": "prettier --single-quote --trailing-comma none --write README.md documentation/*",
Expand Down

0 comments on commit 3c300a8

Please sign in to comment.