Documentation

GitHub Actions integration for JUnit XML uploads

The TestNod uploader action sends your JUnit XML reports to TestNod from a GitHub Actions workflow. Adding it takes one step in your workflow, and the action makes the upload and finalize calls for you.

The Quickstart covers creating a project and adding your first upload step with this action. This page goes further into the action's inputs and the patterns for matrix builds, parallel runners, and pull requests from forks.

Add the project token as a GitHub secret

In your repository, open Settings → Secrets and variables → Actions and add a repository secret named TESTNOD_PROJECT_TOKEN, using the project token from your project's settings page in TestNod as the value. The workflow reads it through ${{ secrets.TESTNOD_PROJECT_TOKEN }}, so the token never appears in your workflow YAML or in workflow logs.

GitHub Actions secrets page showing the new TESTNOD_PROJECT_TOKEN repository secret

For more information on GitHub secrets, see "Using secrets in GitHub Actions" in GitHub's documentation.

Add the upload step

Add the upload step after your test step. The if: ${{ !cancelled() }} directive runs the upload on both passing and failing test runs while still letting a cancelled workflow stop cleanly.

The following workflow snippet shows an example of a test job that runs RSpec and uploads the JUnit XML report to TestNod:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run tests
        run: bundle exec rspec --format progress \
          --format RspecJunitFormatter --out tmp/rspec.xml

      - name: Upload test results to TestNod
        if: ${{ !cancelled() }}
        uses: testnod/testnod-uploader-action@v1
        with:
          file: tmp/rspec.xml
          token: ${{ secrets.TESTNOD_PROJECT_TOKEN }}
          tags: ci,rspec
          ignore-failures: true

That single step covers the whole upload. By default the action uploads the file and finalizes the run in one pass, so a workflow that produces one JUnit XML file needs nothing else.

Action inputs

Input Required Default What it does
token Yes None The project token. Read it from the secret you created above.
file Conditional "" Path to the JUnit XML report. Required unless finalize is set to only.
tags No "" Comma-separated tags applied to the run. Tags group runs in the dashboard and scope TestNod's analysis to comparable runs.
ignore-failures No false When true, an upload error logs a warning instead of failing the step.
build-id No ${{ github.run_id }} The identifier that groups uploads into one TestNod run. Override it to split runs apart or merge them.
finalize No true true uploads the file and finalizes the run, false uploads without closing the run, and only finalizes without uploading.
uploader-version No latest Pins the underlying uploader to a specific version instead of tracking the latest release.
retry No false When true, marks the upload as a rerun of tests that failed earlier in the same build, and tests that pass in it are recorded as passed on retry. Works with the default latest uploader, and a pinned uploader-version needs v0.1.0 or later.

Metadata attached automatically

The action reads the branch name, commit SHA, and build ID from the workflow environment and builds a link back to the GitHub Actions run. It sends all of this with the upload without you passing anything by hand, and the TestNod run page links straight back to the CI run that produced it.

Why if: ${{ !cancelled() }}

The directive does two things:

  • It runs the upload step even when bundle exec rspec exits non-zero, so a failing run still reaches TestNod.
  • It's preferred over if: always() because GitHub's own docs warn that always() can keep a workflow from being cancelled in a timely manner, since cancellation signals get swallowed alongside failure signals.

Matrix and parallel builds

Matrix jobs and parallel runners share the same github.run_id, which the action uses as the default build-id, so every shard that uploads with it joins the same TestNod run, with one upload per shard.

Each shard uploads with finalize: false so the run stays open while the others are still reporting, and a follow-up job finalizes once with finalize: only:

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        ruby: ["3.2", "3.3"]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run tests
        run: bundle exec rspec --format RspecJunitFormatter --out tmp/rspec.xml

      - name: Upload test results to TestNod
        if: ${{ !cancelled() }}
        uses: testnod/testnod-uploader-action@v1
        with:
          file: tmp/rspec.xml
          token: ${{ secrets.TESTNOD_PROJECT_TOKEN }}
          tags: ci,rspec
          ignore-failures: true
          finalize: false

  finalize-testnod:
    needs: test
    if: ${{ !cancelled() }}
    runs-on: ubuntu-latest
    steps:
      - name: Finalize TestNod run
        uses: testnod/testnod-uploader-action@v1
        with:
          token: ${{ secrets.TESTNOD_PROJECT_TOKEN }}
          finalize: only

needs: test together with if: ${{ !cancelled() }} on the finalize job means it runs after the matrix on both success and failure, while still stopping cleanly if the workflow is canceled. Setting fail-fast: false stops the first failing shard from canceling the rest of the matrix, which would skip their uploads.

If you'd rather track each matrix combination as its own TestNod run, with separate history and alerts per combination, give each shard a distinct build-id and let each finalize on its own with the default finalize: true. For example, build-id: ${{ github.run_id }}-ruby-${{ matrix.ruby }} keeps the runs apart, and the separate finalize job is no longer needed. Each of those runs counts toward your organization's monthly test runs.

Rerun failed tests and upload the retry report

If your workflow reruns failed tests into a second report, upload that report with retry: true so TestNod can tell the rerun from the first attempt. Tests that passed in the rerun show up as passed on retry and keep their first failure on record for the flakiness alert. Upload both reports with finalize: false and finalize once at the end:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run tests
        run: bundle exec rspec --format RspecJunitFormatter --out tmp/rspec.xml || true

      - name: Rerun failed tests
        run: bundle exec rspec --only-failures --format RspecJunitFormatter --out tmp/rspec-retry.xml

      - name: Upload test results to TestNod
        if: ${{ !cancelled() }}
        uses: testnod/testnod-uploader-action@v1
        with:
          file: tmp/rspec.xml
          token: ${{ secrets.TESTNOD_PROJECT_TOKEN }}
          finalize: false

      - name: Upload rerun results to TestNod
        if: ${{ !cancelled() }}
        uses: testnod/testnod-uploader-action@v1
        with:
          file: tmp/rspec-retry.xml
          token: ${{ secrets.TESTNOD_PROJECT_TOKEN }}
          retry: true
          finalize: false

      - name: Finalize TestNod run
        if: ${{ !cancelled() }}
        uses: testnod/testnod-uploader-action@v1
        with:
          token: ${{ secrets.TESTNOD_PROJECT_TOKEN }}
          finalize: only

The || true after the first test command leaves the pass or fail decision to the rerun. When nothing failed, --only-failures has nothing to run and writes an empty report, and uploading that changes nothing in TestNod. RSpec needs config.example_status_persistence_file_path set before --only-failures works. The Retries and reruns guide explains that setting and gives the pytest and Playwright equivalents.

Pull requests from forks

GitHub Actions does not expose secrets to workflows triggered by pull requests from forks. On those runs the token input is empty, and the TestNod API rejects the upload with a 404. With ignore-failures: true the step won't fail your workflow, but the upload still won't land. There are two ways to handle it:

  • Gate the upload step so it only runs for pushes and internal pull requests by adding github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository to the step's if condition, alongside the !cancelled() check.
  • Run external-fork tests in a separate workflow that does not attempt an upload.

Reusable workflow

If you maintain many repositories, factor the upload step into a reusable workflow and call it from each project. The action's contract is small enough that a short reusable workflow covers the common cases, and every repository then picks up changes from one place.

What's next

Push a commit to trigger the workflow, then open the new run in TestNod alongside the Test run page tour, which explains each part of the run page. If the run never appears or shows the wrong status, work through Troubleshooting uploads.

Start tracking your test runs

The Solo plan is free for one project and 250 test runs a month, and you don't need a credit card to sign up.

Sign up free