Skip to content

Latest commit

 

History

History
84 lines (58 loc) · 2.91 KB

README.md

File metadata and controls

84 lines (58 loc) · 2.91 KB

Coverage Status

Build Status

Code Coverage Annotation

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 named index.test.ts, the test file may exist in any directory)
  • You must invoke the function/class at least once.

Sample PR Annotation

Screen Shot 2022-06-26 at 7 11 21 PM

Inputs

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

Example

- 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"

Code in Main

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
...

Publish to a distribution branch

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

Validate

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! 🚀