codecov-action icon indicating copy to clipboard operation
codecov-action copied to clipboard

"Ignore paths" not working with custom Codecov config file location

Open Splines opened this issue 9 months ago • 1 comments

With these lines in our GitHub actions workflow, we report our test coverage to codecov.

      - name: Report test coverage to codecov
        uses: codecov/codecov-action@v4
        with:
          fail_ci_if_error: true
          files: ./coverage/coverage.xml
          token: ${{ secrets.CODECOV_TOKEN }}
          verbose: true
          codecov_yml_path: ./.config/codecov.yml

Note that we're using codecov_yml_path to refer to a custom location of the codecov.yml file inside a .config/ folder. The file is recognized as can be seen in the last GitHub Actions run here:

debug - 2024-06-01 14:01:52,870 -- Loading config from .config/codecov.yml

Inside the .config/codecov.yml file, we specify that the spec/ folder should be ignored entirely by codecov as we don't want our test files themselves to contribute to the coverage statistics.

# Ignore test files themselves in the Codecov report
# see: https://about.codecov.io/blog/should-i-include-test-files-in-code-coverage-calculations/
ignore:
  - "../spec/**/*"
  - "**/*_spec.rb"

However, in the codecov dashboard, we still see the spec/ folder and all of its contents in the code tree.

Some questions

  • From the "Ignoring paths" documentation page, it's not clear whether we should use ../spec/**/* or ./spec/**/* when a custom location for the codecov.yml file is set up. Both variants don't seem to work for us. Maybe it's something obvious that I can't see?
  • Should the file coverage.xml only contain results that are not ignored by Codecov? Or is Codecov smart enough to filter this according to the ignore key in the codecov.yml file?

Splines avatar Jun 01 '24 14:06 Splines