Skip to content

rosslight/pr-code-coverage-visualizer

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

pr-code-coverage-visualizer ts

This is a github action which is supposed to be run for a PR and visualizes the test coverage.

Everytime this action is run, we add a comment to the PR showing the current coverage.

If the trigger is not pull_request, this action does nothing. Also, if the length of the comment would exceed the GitHub limit, lines are trunctuated.

Features

  • Accepts code coverage as one or multiple cobertura.xml files
  • Visualizes coverage summary and per-file annotated snippets in the pull request

Specification

To run this action, create a workflow as follows:

on: pull_request

permissions:
  contents: read
  pull-requests: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # Generate coverage files
      - name: Attach code-coverage comment
        uses: rosslight/[email protected]
        with:
          files: |
            coverage/coverage1.xml
            coverage/coverage2.xml
          update-comment: true
          show-changed-lines-only: true
          exclude-files: |
            some_generated_files/*.rs

Inputs

Name Default Description
files (required) One or multiple files. Can be multiple lines. Glob is supported
update-comment true TODO: Update
show-changed-lines-only true If part of a PR, filter coverage data against changed lines
exclude-files '' Glob patterns for files to exclude. Can be multiple lines. If empty, no files are excluded

Outputs

Name Description
line-coverage The line coverage
function-coverage The function coverage
branch-coverage The branch coverage

Example output

Repo Coverage

Line Coverage Branch Coverage


PR Coverage

2/3 changed lines covered (Lines: 66.67%, Branches: 50%)

TestPackage
🔴 uncovered.ts2/3 changed lines covered (Lines: 66.67%, Branches: 50%)
  1 🟨 if (true) {
  2 🟩   return "true";
  3  else {
  4 🟥   return "false";
  5  }
✓ 🟢 covered.ts1/1 changed lines covered

Legend: 🟥 uncovered · 🟨 partial branch · 🟩 covered · ⬛ non-executable/blank
Generated by coverage-pr-comment

Development

Release workflow

Releases are generated from conventional commits and aggregated using release-please.

When the release-please pull request is merged into main branch, a new release is created by GitHub Actions which includes the dist/ folder.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •