hokify / code-coverage-assistant-ts

fork of code-coverage-assistant, rewrite in typescript and optimized for monorepos with external storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code Coverage Assistant

CI

GitHub Action to assist the pull request with code coverage stats

  • ✅  Code coverage comment for monorepo
  • ✅  Code coverage comment for single repo
  • ✅  Code coverage diff from base branch

The report is based on the lcov coverage report generated by your test runner.

Usage

Just add this action to one of your workflow files:

- name: Add coverage comment
  uses: hokify/code-coverage-assistant-ts@v1

Action inputs

The possible inputs for this action are:

Parameter Description Default
github-token (Required) Github token used for posting the comment. To use the key provided by the GitHub action runner, use ${{ secrets.GITHUB_TOKEN }}.
monorepo-base-path (Required) The location of your monrepo packages path
s3-config Configuration for uploading lcov files to s3. Json Encoded. e.g. '{ credentials: { accessKeyId: "", secretAccessKey: "" }, region: "", Bucket: "repository-code-coverage" }'
threshold Sets the threshold before the action fails if coverage of a package decreases 0.05%
mode collect: upload lcov files to s3, report: generate report, merge: set new base (auto)

Examples

Code coverage comment for monorepo

uses: hokify/code-coverage-assistant-ts@v1
with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    s3-config: '{ credentials: { accessKeyId: "", secretAccessKey: "" }, region: "", Bucket: "repository-code-coverage" }'
    monorepo-base-path: "./packages"

Code coverage comment with diff

⚠️  Note: This config needs an additional github action when the PR is closed. And you need to set s3-config parameter!

name: Upload Coverage Files

on:
  pull_request:
    types:
      - closed
    branches:
      - master

env:
  NODE_VERSION: '16'

jobs:
  upload-coverage:
    if: ${{ github.event.pull_request.draft == false && github.event.pull_request.merged }}
    runs-on: ubuntu-latest
    name: Upload New Code Coverage Files
    uses: hokify/code-coverage-assistant-ts@v1
    with:
      github-token: ${{ secrets.GITHUB_TOKEN }}
      s3-config: ${{ secrets.CODECOV_S3_CONFIG }}
      monorepo-base-path: './packages'

required permissions for S3:

Development

Contributing

Contributions are encouraged! Fork this repo and open a pull request.

Commands

command description
test Run the unit tests
lint Run eslint on all applicable files
format Run prettier on all applicable files
build build the dist file. You are required to run this locally in order to build the dist before opening a PR.

Releasing

This action follows semantic versioning.

Creating a release

  • Ensure master is up to date with all the changes for the next release
  • In the GitHub releases page, click "draft a new release"
    • Choose a tag matching this pattern: vX.X.X
    • Choose master as the target
    • Use the exact tag as the release title
    • Write a description containing all the changes since the last release, and detailing any breaking changes
    • Choose "Publish Release"
  • Github will create the release and add the appropriate tag

Acknowledgements

The initial code is based on romeovs/lcov-reporter-action.

Thanks to:

License

MIT

About

fork of code-coverage-assistant, rewrite in typescript and optimized for monorepos with external storage

License:MIT License


Languages

Language:TypeScript 99.6%Language:Shell 0.2%Language:JavaScript 0.2%