@cats-cradle/rush-coverage
v1.2.11
Published
[](https://badge.fury.io/js/@cats-cradle%2Frush-coverage) [](LICENSE) [ to generate
**/**/coverage/coverage-final.json coverage reports for each project.
Now that it's ready, run the script to merge coverage files from all projects into a single report:
npx @cats-cradle/[email protected]Note Make sure the version of @microsoft/rush-lib specified in
rush.jsonmatches the dependencies specified in this package.
That's it! The consolidated code coverage reports are generated to cwd
./coverage. Reports can reviewed manually or integrated into CI.
Github Action
This is an example of how to use a Github Action, RushCoverage, and third party -- in this case Codacy -- to generate code coverage in CI.
See vendor specific documentation for instructions on coverage submission, badging, pr feedback, etc.
name: CodeCoverage
on:
workflow_call:
secrets:
CODACY_PROJECT_TOKEN:
required: true
jobs:
rush-coverage:
name: rush coverage
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.12.0'
- name: Rush install
run: node common/scripts/install-run-rush.js install
- name: Rush build
run: node common/scripts/install-run-rush.js build
- name: Rush test with coverage
run: node common/scripts/install-run-rush.js test:cov
- name: Merge coverage reports
run: npx @cats-cradle/[email protected]
- name: Submit merged coverage report
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage/lcov.infoNote Change
test:covcommand as specific to your monorepo setup. Set secrets, in this caseCODACY_PROJECT_TOKEN, as necessary in Github.
How it Works
RushCoverage works by obtaining a list of all projects from rush.json. Then
gather a list of all coverage files from each project with a compatible
./coverage/coverage-final.json . It then combines all the coverage files found
into one consolidated coverage report.
