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 Tests

By 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.

go test -v ./... 2>&1 | go-junit-report > junit.xml
gotestsum --junitfile junit.xml

2. Update Your GitHub Actions Workflow

Section titled 2. Update Your GitHub Actions Workflow

After 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 Insights

After pushing these changes:

  1. Your GitHub Actions workflow will execute your Go tests.
  2. A JUnit report (junit.xml) is generated.
  3. 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.

  • 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.