GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (istanbul)

Overview

GitHub Action: Report NYC coverage

GitHub Action that posts the report in a comment on a GitHub Pull Request from coverage data generated by nyc (istanbul).

See sample comment Sample comment image

Typical Usage

on: [pull_request]

jobs:
  my_app_job:
    runs-on: ubuntu-latest
    name: My App
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 1000 # Set this according to the size of your git history

      - name: Fetch base
        run: git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1000
        
      - name: Run tests
        run: npm run test

      - name: Generate NYC report
        run: |
          npx nyc report \
            --reporter json-summary \
            --report-dir nyc-coverage-report \
            --exclude-after-remap false

      - name: Report NYC coverage
        uses: sidx1024/[email protected]
        with:
          # Path to coverage output directory generated by "nyc report".
          coverage_output_directory: "nyc-coverage-report"

Usage

- uses: sidx1024/[email protected]
  with:
    # Path to coverage output directory generated by "nyc report".
    coverage_output_directory: ""

    # Template markdown file to be used for GitHub PR comment. Optional.
    # Default: comment-template.md
    comment_template_file: ""

    # "replace" or "new"
    # Default: replace
    comment_mode: ""

    # An alternative GitHub token, other than the default provided by GitHub Actions
    # runner. Optional.
    # Default: ${{ github.token }}
    github_token: ""

    # Absolute path to the source files. The path will be trimmed from the coverage
    # data. Optional. Default is the github workspace directory with a trailing slash.
    # Default: ${{ format('{0}/', github.workspace) }}
    sources_base_path: ""

    # Specify the order for coverage types to be included in the output table. (S:
    # statements, B: branches, F: functions, L: lines). Missing types will be
    # excluded.
    # Default: SBFL
    files_coverage_table_output_type_order: ""
Input Description Default Required
coverage_output_directory Path to coverage output directory generated by "nyc report". true
comment_template_file Template markdown file to be used for GitHub PR comment. Optional. comment-template.md false
comment_mode "replace" or "new" replace false
github_token An alternative GitHub token, other than the default provided by GitHub Actions runner. Optional. ${{ github.token }} false
sources_base_path Absolute path to the source files. The path will be trimmed from the coverage data. Optional. Default is the github workspace directory with a trailing slash. ${{ format('{0}/', github.workspace) }} false
files_coverage_table_output_type_order Specify the order for coverage types to be included in the output table. (S: statements, B: branches, F: functions, L: lines). Missing types will be excluded. SBFL false
Output Description Default Required
total_lines_coverage_percent Total lines coverage percent (XX.XX%) with level indicator
total_branches_coverage_percent Total branches coverage percent (XX.XX%) with level indicator
total_statements_coverage_percent Total statements coverage percent (XX.XX%) with level indicator
total_functions_coverage_percent Total functions coverage percent (XX.XX%) with level indicator
total_lines_coverage_percent_raw Total lines coverage percent (XX.XX) without percent and level indicator
total_branches_coverage_percent_raw Total branches coverage percent (XX.XX) without percent and level indicator
total_statements_coverage_percent_raw Total statements coverage percent (XX.XX) without percent and level indicator
total_functions_coverage_percent_raw Total functions coverage percent (XX.XX) without percent and level indicator
files_coverage_table HTML table content containing the file path and corresponding coverage percent for all files
changed_files_coverage_table HTML table content containing the file path and corresponding coverage percent for files changed in the PR
comment_body The comment body in HTML format
commit_sha Last commit SHA (commit due to which this action was executed)
short_commit_sha Last commit SHA in shorter format (6ef01b)
commit_link Relative link for the last commit
You might also like...

🔐 Protect your Smart Contract Proxy from storage collisions upon upgrading, by running this action in a CI on each of your Pull Requests!

🔥 🛠️ Foundry Storage Upgrade Seatbelt Protect your Smart Contract Proxy from storage collisions upon upgrading, by running this action in a CI on ea

Dec 24, 2022

Pull sensitive data from users on windows including discord tokens and chrome data.

Pull sensitive data from users on windows including discord tokens and chrome data.

⭐ For a 🍪 Pegasus Pull sensitive data from users on windows including discord tokens and chrome data. Features 🟩 Discord tokens 🟩 Geolocation data

Dec 24, 2022

🎩 Coverage for EcmaScript Modules

🎩 Coverage for EcmaScript Modules

🎩 ESCover Coverage for EcmaScript Modules based on 🐊 Putout and loaders. Why another coverage tool? When you want to use ESM in Node.js without tran

Jun 10, 2022

👋 Canyon is a JavaScript code coverage platform

👋 Canyon is a JavaScript code coverage platform

Canyon Welcome to the Canyon codebase, we are thrilled to have you here! What is Canyon? Canyon is a JavaScript code coverage platform. Canyon can rea

Oct 6, 2022

Coverage-guided, in-process fuzzing for the Node.js

Coverage-guided, in-process fuzzing for the Node.js

Jazzer.js Jazzer.js is a coverage-guided, in-process fuzzer for the Node.js platform developed by Code Intelligence. It is based on libFuzzer and brin

Dec 26, 2022

This repository contains a basic example on how to set up and run test automation jobs with CircleCI and report results to Testmo.

CircleCI test automation example This repository contains a basic example on how to set up and run test automation jobs with CircleCI and report resul

Dec 23, 2021

Code Scanning/SAST/Static Analysis/Linting using many tools/Scanners with One Report - Scanmycode Community Edition (CE)

Code Scanning/SAST/Static Analysis/Linting using many tools/Scanners with One Report - Scanmycode Community Edition (CE)

Star it If you like it, please give it a GitHub star/fork/contribute. This will ensure continous development ⭐ TLDR; To install it. Install docker and

Dec 29, 2022

Allows the public to easily report and track the geolocation of anyone or anything they spot outside, using a mobile app or web frontend.

Allows the public to easily report and track the geolocation of anyone or anything they spot outside, using a mobile app or web frontend.

LIVE DEMO: https://armytracker.com/ (tracking the invading Russian army in Ukraine) Attention: - If you'd like to help the project either as a program

Mar 27, 2022

The project integrates workflow engine, report engine and organization authority management background, which can be applied to the development of OA, HR, CRM, PM and other systems. With tlv8 IDE, business system development, testing and deployment can be realized quickly.

The project integrates workflow engine, report engine and organization authority management background, which can be applied to the development of OA, HR, CRM, PM and other systems. With tlv8 IDE, business system development, testing and deployment can be realized quickly.

介绍 项目集成了工作流引擎、报表引擎和组织机构权限管理后台,可以应用于OA、HR、CRM、PM等系统开发。配合使用tlv8 ide可以快速实现业务系统开发、测试、部署。 后台采用Spring MVC架构简单方便,前端使用流行的layui界面美观大方。 采用组件开发技术,提高系统的灵活性和可扩展性;采

Dec 27, 2022
Comments
  • Get run ID with shell script

    Get run ID with shell script

    Run IDs greater than Java's max integer value are not found using GitHub REST APIs used in https://github.com/dawidd6/action-download-artifact/issues/147.

    Fetching run id using GitHub CLI.

    opened by sidx1024 1
  • Fix git diff

    Fix git diff

    Old behaviour: git diff was including changes between base branch and head branch. New behaviour: git diff will include changes that occurred on the base branch since when the head branch was started off it. Reference: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-Comparingbranches

    Changes

    • Added support for git fetching using shallow since argument for faster checkout and diffing.
    opened by sidx1024 1
  • Error

    Error "unexpected input coverage_file" when using example from README

    Tried using in my workflow, starting from the example in the README.

    My step looked like this (I tweaked the coverage folder name so that it was the default folder name used by nyc):

    - name: Report NYC coverage
      uses: sidx1024/[email protected]
      with:
        coverage_file: "coverage/coverage-summary.json"
    

    I get the following error:

    Unexpected input(s) 'coverage_file', valid inputs are ['coverage_output_directory', 'comment_template_file', 'comment_mode', 'github_token', 'sources_base_path', 'files_coverage_table_output_type_order']
    
    opened by mattwelke 0
  • Unable to find default comment_template.md

    Unable to find default comment_template.md

    The comment file isn't being found - this is because the source path for the search defaults to the application directory you're building, not the action runner directory:
    Error: Error: ENOENT: no such file or directory, open '/home/runner/work/JsFunctionAppTest/JsFunctionAppTest/comment-template.md'
    Providing the full comment template path to the action results in it working:

        - name: Report NYC coverage
          uses: sidx1024/[email protected]
          with:
            coverage_file: "coverage/coverage-summary.json"
            comment_template_file: "/home/runner/work/_actions/sidx1024/report-nyc-coverage-github-action/v1.2.6/comment-template.md"
    

    The rest of the error:

    Run sidx10[2](https://github.com/####/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:2)4/[email protected]
      with:
        coverage_file: coverage/coverage-summary.json
        comment_mode: new
        base_coverage_file: .base_nyc_output/coverage-summary.json
        comment_template_file: comment-template.md
        github_token: ***
        sources_base_path: /home/runner/work/JsFunctionAppTest/JsFunctionAppTest/
        files_coverage_table_output_type_order: SBFL
    Base coverage json was not readable.
    /usr/bin/git diff --name-only --diff-filter=ACMRT origin/master...4758df2bbd[3](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:3)0bc16c5a67a298d6caed260af9725
    fatal: ambiguous argument 'origin/master...[4](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:4)7[5](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:5)8df2bbd30bc1[6](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:6)c5a6[7](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:7)a29[8](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:8)d6caed260af[9](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:9)725': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'
    A non-fatal error occurred while performing git diff:  {
      exitCode: 128,
      stdout: '',
      stderr: "fatal: ambiguous argument 'origin/master...4758df2bbd30bc16c5a67a298d6caed260af9725': unknown revision or path not in the working tree.\n" +
        "Use '--' to separate paths from revisions, like this:\n" +
        "'git <command> [<revision>...] -- [<file>...]'\n"
    }
    Error: Error: ENOENT: no such file or directory, open '/home/runner/work/JsFunctionAppTest/JsFunctionAppTest/comment-template.md'
        at Object.openSync (node:fs:585:3)
        at Object.readFileSync (node:fs:453:35)
        at run (/home/runner/work/_actions/sidx[10](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:10)24/report-nyc-coverage-github-action/v1.2.6/dist/index.js:10[23](https://github.com/###/JsFunctionAppTest/runs/6453607763?check_suite_focus=true#step:9:23)1:32)
    
    opened by TaighHawkins 5
Releases(v1.2.6)
  • v1.2.6(Apr 4, 2022)

    What's Changed

    • Use file path instead of directory for coverage file by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/21
    • Add workflow for main branch by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/23
    • Fix workflow names by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/24

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1.2.5...v1.2.6

    Source code(tar.gz)
    Source code(zip)
  • v1.2.5(Apr 4, 2022)

  • v1.2.4(Mar 23, 2022)

    What's Changed

    • Remove shallow clone git strategy and update example by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/14
    • Update fetch depth by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/15

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1.2.3...v1.2.4

    Source code(tar.gz)
    Source code(zip)
  • v1.2.3(Mar 22, 2022)

    What's Changed

    • Fix git diff by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/11

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1.2.2...v1.2.3

    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Mar 22, 2022)

    What's Changed

    • Add coverage level indicators by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/10

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1.2.1...v1.2.2

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Mar 22, 2022)

    What's Changed

    • Fetch base internally by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/9

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1.2...v1.2.1

    Source code(tar.gz)
    Source code(zip)
  • v1.2(Mar 21, 2022)

    What's Changed

    • Minor fixes by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/8

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1.1...v1.2

    Source code(tar.gz)
    Source code(zip)
  • v1.1(Mar 21, 2022)

    What's Changed

    • Update repo name in readme by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/6
    • Support using existing comment by @sidx1024 in https://github.com/sidx1024/report-nyc-coverage-github-action/pull/7

    Full Changelog: https://github.com/sidx1024/report-nyc-coverage-github-action/compare/v1...v1.1

    Source code(tar.gz)
    Source code(zip)
Owner
Sid
Senior Frontend Engineer
Sid
An action intended to run on pull request and post a comment summarizing any changes to DevCycle variables.

Overview With this Github action, information on which DevCycle features have been added or removed in a code change will be shown directly on each Pu

DevCycle 20 Jun 14, 2022
Utility to automatically fill foreign income section of 3-NDFL report based on tax report from Tinkoff broker

Заполнение дохода за пределами РФ в декларации 3-НДФЛ Disclaimer Автор не несет ответственности за корректное заполнение налоговой декларации. Вы запу

Oleg Elifantiev 12 Dec 9, 2022
Contains html file showcasing Earthquake related data generated in the form of VR model, ArcGIS API with real-time earthquake feed and video of simulation of earthquake generated in blender

Module-EADGI-Project-All about Earthquakes Introduction Contains html file showcasing Earthquake related data generated in the form of VR model, ArcGI

Abhishek Rawat 2 Jun 9, 2022
Learn Basic of Node Express Server and Git & Github by creating Pull Request in this repository.

hacktoberfest-express-server-2022 Learn Basic of Node Express Server and Git & Github by creating Pull Request in this repository. Special Note For Ev

NetScape-Web 3 Oct 6, 2022
ETH NYC Winner (8 prizes)

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Stanley Zheng 39 Dec 21, 2022
Automatically code review with ktlint result for pull request

GitHub Actions - ktlint-auto-review ?? Automatically reviewed on Pull Request with ktlint Inspired by ScaCap/action-ktlint but without reviewdog. Gett

MinJun Kweon 6 Dec 20, 2022
Runs sfdx-scanner on a pull request and generates in-line comments with the findings.

sfdx-scan-pull-request Runs sfdx-scanner on a pull request and generates in-line comments with the findings. Inputs category Categor(ies) of rules to

Mitchell spano 27 Jan 7, 2023
Make your first Pull Request on Hacktoberfest 2022. Don't forget to spread love and if you like give us a star

Hacktoberfest2022 Make your first Pull Request on Hacktoberfest 2022. Don't forget to spread love and if you like give us a star Quality of Pull Reque

Google Developer Students Club - Galgotias University 12 Oct 30, 2022
A request library that returns promises, inspired by request

then-request A request library that returns promises and supports both browsers and node.js Installation npm install then-request Usage request(metho

then (Promises/A+ implementations) 241 Nov 29, 2022