gotestsum icon indicating copy to clipboard operation
gotestsum copied to clipboard

Implement error reporter format for GitHub Actions

Open Tonkpils opened this issue 1 month ago • 1 comments

  • https://github.com/gotestyourself/gotestsum/issues/540

Not sure how else to showcase it without having failing CI builds but here's an output example

image

This pull request adds support for emitting GitHub Actions error annotations for failed tests in the githubActionsFormat output. The main changes include parsing test output for failure locations, handling panics specially, and generating error annotations with file and line information for easier debugging in CI environments.

GitHub Actions error annotation support:

  • Added regex-based parsing of test output to extract file and line information for failed tests and panics (fileLinePattern, panicStackPattern in testjson/format.go). [1] [2]
  • Introduced the writeGitHubActionsError function to emit error annotations in GitHub Actions format, including special handling for panics and regular failures, with proper sanitization of annotation fields (testjson/format.go).
  • Modified the test formatter to call writeGitHubActionsError on failed test events, resulting in error annotations for each failure (testjson/format.go).

Test output updates:

  • Updated expected output in testjson/testdata/format/github-actions.out to include new error annotations for each failed test, showing file, line, and test name information. [1] [2] [3] [4] [5] [6]

Tonkpils avatar Nov 21 '25 19:11 Tonkpils

@dnephin 👋 sorry for the direct ping, just wanted to make sure you didn't miss this PR. Do you have any feedback on whether this is good to be merged or if you'd like to see any changes? 🙇

Tonkpils avatar Dec 12 '25 18:12 Tonkpils