GitHub Actions PR Comment With Test Results

Matthew Thomas
2 min readAug 14, 2024

--

A reporter that adds a comment to pull requests with test results from GitHub Actions using a single command in your workflow file. Compatible with many popular testing frameworks.

GitHub Actions does not provide a built-in feature for alerting and visualizing test results. If tests fail, you can search through the console output or download and examine the results file — a frustrating process.

Using the github-actions-ctrf package, you can view test results directly in your pull request, so it’s easier for developers to quickly see the outcome of tests from the GitHub Actions workflow.

It works with most testing frameworks and because it’s cross-compatible, it means the same reporting no matter which framework you use. All you need to do is add the following stage to your GitHub Actions workflow after running your tests:

- name: Post PR Comment
run: npx github-actions-ctrf ctrf-report.json --pr-comment
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

When your Github Action runs on a PR, it will add a comment with test results. The comment includes a link to the GitHub Actions summary, where you will find more details about the tests.

View test results in Github Actions Summary

The github-actions-ctrf package is also great for publishing and viewing test results directly in the Github Action summary, making it easier to understand your test results.

It’s easy to implement, you don’t need to use a custom action or worry about permissions or tokens, there are no limitations on report size and you can apply to any branch, even publicly forked repositories.

Just add the following to your workflow yaml, replacing the path argument placeholder with the path of your report:

- name: Publish Test Summary Results
run: npx github-actions-ctrf ctrf/ctrf-report.json

--

--

Matthew Thomas

platform engineering, devops, software development and I travel sometimes