Generate code coverage annotation in pull request within Github Action Workflow environment. No data is sent to an external server.
NOTE:
- Test file and code file name should be same. (ie.
index.ts
should have test file namedindex.test.ts
, the test file may exist in any directory) - You must invoke the function/class at least once.
Key | Required | Default | Description |
---|---|---|---|
GITHUB_TOKEN |
yes | - | Github Token generated by Github Action workflow. You can pass this in as ${{secrets.GITHUB_TOKEN}} |
LCOV_FILE_PATH |
yes | - | Location of Lcov.info file that was generatedcommand |
- name: Code Coverage Annotation Line by Line
uses: shravan097/codecoverage@release/v0.5.1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
LCOV_FILE_PATH: "./coverage/lcov.info"
First, you'll need to have a reasonably modern version of
node
handy. This won't work with versions older than 9, for instance.
Install the dependencies
$ npm install
Build the typescript and package it for distribution
$ npm run build && npm run package
Run the tests ✔️
$ npm test
...
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run ncc and push the results:
$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
Note: We recommend using the --license
option for ncc, which will create a license file for all of the production node modules used in your project.
Your action is now published! 🚀
See the versioning documentation
You can now validate the action by referencing ./
in a workflow in your repo (see test.yml)
uses: ./
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
LCOV_FILE_PATH: "./coverage/lcov.info"
See the actions tab for runs of this action! 🚀