Add CI action to upload html coverage report (#54) #738
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 4 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: | |
- 12.x | |
- 14.x | |
- 16.10.0 | |
- 16.16.0 | |
- 16.17.0 | |
- 16.x | |
- 17.x | |
- 18.5.0 | |
- 18.18.0 | |
- 18.19.0 | |
- 18.x | |
- 20.9.0 | |
- 20.x | |
- 21.x | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: npm install | |
- run: npm test | |
- run: npm run test:ts | |
if: (matrix.node-version != '12.x' && matrix.node-version != '14.x' && matrix.node-version != '16.10.0') | |
- name: Archive code coverage results | |
if: success() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage_${{ matrix.os }}_${{ matrix.node-version}} | |
if-no-files-found: ignore | |
path: coverage/lcov.info | |
coverage: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
# We need to check out the source in order for genhtml to work | |
- uses: actions/checkout@v4 | |
- name: Download reports' artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: downloaded_artifacts | |
- name: Install lcov | |
run: | | |
sudo apt update | |
sudo apt install -y lcov | |
- name: Combine all coverage data | |
run: | | |
find . -type f -name '*.info' -exec echo -a {} \; | xargs --verbose lcov -o all_lcov.info | |
- name: Report | |
run: > | |
lcov --summary all_lcov.info | |
lcov --summary all_lcov.info | grep lines | cut -d' ' -f 4 | cut -d% -f 1 | xargs node -e "x=process.argv[1];console.log(x);assert(+x >= 90)" | |
- name: Generate HTML report | |
run: | | |
mkdir html_report | |
genhtml -o html_report all_lcov.info | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: 00_html_coverage_report | |
if-no-files-found: ignore | |
path: html_report/ |