Skip to content

Instantly share code, notes, and snippets.

@dvins
Created May 3, 2025 20:35
Show Gist options
  • Save dvins/ef9f79b849ed0767e90f01cbc160b403 to your computer and use it in GitHub Desktop.
Save dvins/ef9f79b849ed0767e90f01cbc160b403 to your computer and use it in GitHub Desktop.
Workaround For Monorepos And Buggy Sentry Codecov Test Results GitHub Action

Workaround For Monorepos And Buggy Sentry Codecov Test Results GitHub Action

This explains how to workaround bugs in the Sentry Codecov Test Results GitHub Action when using a monorepo and a folder containing consolidated test result files.

Background

As of the time of this writing there is a bug in the Sentry Codecov Test Results Action for GitHub Workflows. It does not properly use the directory attribute nor do globs presently work for the file or files attribute.

There are a couple issues at play:

  • BUG: Not detecting reports even though they contain junit in the name #110
  • BUG: Files argument is not used #107
  • UNMERGED PR Mention wildcard pattern in documentation1 #97

Consequently, the only way for the action to find junit.xml test result files is to scavange across the entire folder structure, which can be woefully inefficient.

Solution

This solution assumes you area already gathering all your monorepo test results into a single folder. Otherwise, you will need to customize it accordingly.

The workaround is to add a step to enumerate the list of junit.xml files into a variable, and then explicitly pass that list into the Codecov Test Results action via the files attribute:

steps:
  - name: Collect Test Coverage & Results
    run: |
      pnpm turbo coverage:gather
      pnpm turbo coverage:merge
      pnpm turbo coverage:report
  
  - name: "Generate Test Results File List (See: https://github.com/codecov/test-results-action/issues/110)"
    id: test-results
    run: |
      FILES=$(find ./coverage/raw/junit -type f -name "*.junit.xml" | paste -sd "," -)
      echo "file_list=$FILES" >> $GITHUB_OUTPUT
      echo "file_list=$FILES"
  
  - name: Upload Test Results to Sentry Codecov
    if: ${{ !cancelled() }}
    uses: codecov/test-results-action@v1
    timeout-minutes: 10
    with:
      directory: coverage/raw/junit
      files: ${{ steps.test-results.outputs.file_list }}
      flags: unit
      token: ${{ secrets.CODECOV_TOKEN }}

Note, you will still have to add the directory attribute, because otherwise the Codecov Test Results action still scavenges files from everywhere else, resulting in duplicates that are uploaded.

Also, the action when executed will emit a cryptic warning in the logs, "Some files being explicitly added are found in the list of excluded files for upload. But your files will still upload.

Other Observations

At the moment the Tests tab in the Codecov UI remains quite underwhelming. It doesn't even rollup by test suite let alone module and folder.

Footnotes

  1. This missing documentation doesn't matter anyway, as it doesn't work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment