Skip to content

granodigital/report-annotate

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,080 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Report Annotate

Linter CI Check dist/ CodeQL Coverage

Easily add annotations to your GitHub pull requests based on reports from your tests, linters, etc.

Usage Example

permissions:
  pull-requests: write  # Required for creating comments on skipped annotations

steps:
  - name: Checkout
    id: checkout
    uses: actions/checkout@v4

  - name: Run Tests & Lint etc.
    run: npm install && npm run test:lint:etc

  - name: Report Annotate
    id: annotate
    if: always() # Run with test/lint failures.
    uses: granodigital/report-annotate@v3
    with:
      reports: |
        junit|reports/junit-generic.xml
        junit-eslint|reports/*-eslint.xml
        junit-jest|reports/junit-jest.xml
      ignore: node_modules/**,dist/** # Ignore patterns for the report search (default).

   - name: Annotations created
      if: always()
      run: |
         echo "Total: ${{ steps.annotate.outputs.total }}"
         echo "Errors: ${{ steps.annotate.outputs.errors }}"
         echo "Warnings: ${{ steps.annotate.outputs.warnings }}"
         echo "Notices: ${{ steps.annotate.outputs.notices }}"

Inputs

Name Description Default
reports Reports to annotate: "format|glob1, glob2, ..." E.g.: "junit-eslint|junit/lint.xml" ["junit|junit/*.xml"]
ignore Ignore files from report search: "[glob1, glob2...]" ['node_modules/**', 'dist/**']
max-annotations Maximum number of annotations per type (error/warning/notice). GitHub Actions limits annotations to 10 per type per step. 10
custom-matchers Custom matchers to use for parsing reports in JSON format: { "matcher-name": ReportMatcher } See ./src/matchers for examples
always-comment-errors When true, all errors are always included in the PR comment body regardless of annotation limits or diff membership true
comment-method How to handle previous bot comments: minimize hides old comments and creates a new one, update edits the last existing comment in-place minimize
token GitHub token for creating PR comments (used for error summaries, out-of-diff annotations, and skipped annotation comments) ${{ github.token }}

Skipped Annotations

When the maximum number of annotations per type is reached, additional annotations are not displayed as GitHub annotations to avoid clutter. Instead, they are added as a comment on the pull request.

PR Comment Summary

A PR comment is automatically created when any of the following conditions are met:

  • Errors exist (when always-comment-errors is true, the default): All errors are listed in the comment so they are visible without opening the Changes tab.
  • Out-of-diff annotations: When lint/tests run on all files (e.g., after ESLint config changes), annotations on files not included in the PR diff won't display as inline annotations. These are automatically detected and included in the PR comment with links to the blob view.
  • Skipped annotations: When the max-annotations limit is exceeded, additional annotations are listed in the comment.
  • No report files found: When none of the configured report patterns match, a warning comment is posted instead of treating previous annotations as resolved.

The behavior depends on comment-method:

  • When comment-method is minimize, a new comment is created and previous bot comments from this action are automatically minimized.
  • When comment-method is update, the latest existing bot comment from this action is updated in place and older comments are not minimized.

When report files are found but there is nothing to report (no errors, out-of-diff annotations, or skipped annotations) and a previous bot comment exists, the action replaces it with an "All issues resolved" status — minimizing the previous comment and posting a fresh all-clear (minimize), or updating the existing one in place (update). PRs with no previous bot comment are left untouched.

Note

For more information about GitHub Actions annotation limitations, see the official documentation.

Custom Matchers

You can define custom matchers to parse your reports and create annotations. Currently only XML reports are supported using XPath selectors.

Feel free to open a PR to add support for new report formats or matchers.

See matchers folder for examples.

---
- name: Report Annotate
  id: annotate
  if: always() # Run with test/lint failures.
  uses: granodigital/report-annotate@v3
  with:
    reports: my-matcher|reports/*.xml
    custom-matchers: |
      {
       "my-matcher": {
          "format": "xml",
          "item": "//testCase",
          "title": "oopsie-daisy/@message",
          "message": "oopsie-daisy/text()",
          "file": "parent::testFile/@filePath",
          "startLine": "oopsie-daisy/@line"
        }
      }

Development

  1. Install the dependencies

    npm install
  2. 🏗️ Package the TypeScript for distribution

    npm run bundle
  3. ✅ Run the tests

    $ npm test
    
    PASS  ./index.test.js
      ✓ throws invalid number (3ms)
      ✓ wait 500 ms (504ms)
      ✓ test runs (95ms)
    
    ...

Update the Action Metadata

The action.yml file defines metadata about your action, such as input(s) and output(s). For details about this file, see Metadata syntax for GitHub Actions.

When you copy this repository, update action.yml with the name, description, inputs, and outputs for your action.

Update the Action Code

The src/ directory is the heart of your action! This contains the source code that will be run when your action is invoked. You can replace the contents of this directory with your own code.

There are a few things to keep in mind when writing your action code:

  1. Create a new branch

    git checkout -b releases/v1
  2. Replace the contents of src/ with your action code

  3. Add tests to __tests__/ for your source code

  4. Format, test, and build the action

    npm run all

For information about versioning your action, see Versioning in the GitHub Actions toolkit.

Publishing a New Release

This project includes a helper script, script/release designed to streamline the process of tagging and pushing new releases for GitHub Actions.

GitHub Actions allows users to select a specific version of the action to use, based on release tags. This script simplifies this process by performing the following steps:

  1. Retrieving the latest release tag: The script starts by fetching the most recent SemVer release tag of the current branch, by looking at the local data available in your repository.
  2. Prompting for a new release tag: The user is then prompted to enter a new release tag. To assist with this, the script displays the tag retrieved in the previous step, and validates the format of the inputted tag (vX.X.X). The user is also reminded to update the version field in package.json.
  3. Tagging the new release: The script then tags a new release and syncs the separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0, v2.1.2). When the user is creating a new major release, the script auto-detects this and creates a releases/v# branch for the previous major version.
  4. Pushing changes to remote: Finally, the script pushes the necessary commits, tags and branches to the remote repository. From here, you will need to create a new release in GitHub so users can easily reference the new tags in their workflows.

About

Create Github PR annotations from report files e.g. junit

Resources

License

Stars

6 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 90.0%
  • Shell 7.0%
  • JavaScript 3.0%