Go Integration with CI Insights
Report your test results from Go tests to CI Insights
This guide shows how to generate JUnit reports from your Go tests and upload them to CI Insights using a GitHub Actions workflow.
1. Generate a JUnit Report with Go Tests
Section titled 1. Generate a JUnit Report with Go TestsBy default, go test
does not output JUnit-format reports. To generate one,
pipe the verbose test output into a tool like
go-junit-report or use
gotestsum.
Using go-junit-report
Section titled Using go-junit-reportgo test -v ./... 2>&1 | go-junit-report > junit.xml
Using gotestsum
Section titled Using gotestsumgotestsum --junitfile junit.xml
2. Update Your GitHub Actions Workflow
Section titled 2. Update Your GitHub Actions WorkflowAfter generating the JUnit report, add a step to upload the results to CI Insights using the mergifyio/gha-mergify-ci action.
For example, in your workflow file:
- name: Run Go Tests and Generate JUnit Report
run: go test -v ./... 2>&1 | go-junit-report > junit.xml
- name: Mergify CI Upload
if: success() || failure()
uses: mergifyio/gha-mergify-ci@v4
with:
token: ${{ secrets.MERGIFY_TOKEN }}
report_paths: junit.xml
3. Verify and Review in CI Insights
Section titled 3. Verify and Review in CI InsightsAfter pushing these changes:
- Your GitHub Actions workflow will execute your Go tests.
- A JUnit report (junit.xml) is generated.
- The Mergify CI action uploads the report to CI Insights.
You can then review your test results, including any failures or flaky tests, directly in the CI Insights dashboard.
Troubleshooting Tips
Section titled Troubleshooting Tips-
File Paths: Double-check that the JUnit output file matches the path used in
report_paths
. -
Permissions: Make sure the
MERGIFY_TOKEN
is valid and setup in your GitHub Actions secrets as explained in the docs. -
Workflow Conditions: If your step is not running, confirm the if condition is actually triggered in your job.