Ignore not working on a Go Project

Description

So I’ve been trying for some weeks now to ignore some files I don’t want to test, like example files and a file with a very simple mock implementation but I am not being able to make it work.

It’s an open-source project so you guys can see it:

The codecov bash script reports that it is finding the codecov.yml file which looks like this:

coverage:
  ignore:
    "internal/testtools"
    "internal/structs"
    "examples/example_service"
    "examples/**/*"

CI/CD URL

Here are the CI URLs:

Codecov Output

Please provide the full output of running the uploader on your CI/CD. This will typically have the Codecov logo as ASCII.

  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                              Bash-1.0.6


==> git version 2.34.1 found
==> curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
==> GitHub Actions detected.
    Env vars used:
      -> GITHUB_ACTIONS:    true
      -> GITHUB_HEAD_REF:   
      -> GITHUB_REF:        refs/heads/master
      -> GITHUB_REPOSITORY: VinGarcia/ksql
      -> GITHUB_RUN_ID:     1684882807
      -> GITHUB_SHA:        e48c8a0902e62cf1ea94a258ef9f0742d2c57610
      -> GITHUB_WORKFLOW:   CI
    current dir:  /home/runner/work/ksql/ksql
    project root: .
--> token set from env
    Yaml found at: codecov.yml
==> Running gcov in . (disable via -X gcov)
==> Python coveragepy not found
==> Searching for coverage reports in:
    + .
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + ./coverage.txt bytes=36936
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
    + Found adjustments
==> Gzipping contents
        12K	/tmp/codecov.e5d43Z.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=master&commit=e48c8a0902e62cf1ea94a258ef9f0742d2c57610&build=1684882807&build_url=https%3A%2F%2Fgithub.com%2FVinGarcia%2Fksql%2Factions%2Fruns%2F1684882807&name=&tag=&slug=VinGarcia%2Fksql&service=github-actions&flags=&pr=&job=CI&cmd_args=
->  Pinging Codecov
https://codecov.io/upload/v4?package=bash-1.0.6&token=<hidden>&package=bash-1.0.6&token=36be8ba6-7ef1-4ec2-b607-67c1055a62ad&branch=master&commit=e48c8a0902e62cf1ea94a258ef9f0742d2c57610&build=1684882807&build_url=https%3A%2F%2Fgithub.com%2FVinGarcia%2Fksql%2Factions%2Fruns%2F1684882807&name=&tag=&slug=VinGarcia%2Fksql&service=github-actions&flags=&pr=&job=CI&cmd_args=
->  Uploading to
https://storage.googleapis.com/codecov/v4/raw/2022-01-11/8025F8AB1BE791408244BC37A1D783AC/e48c8a0902e62cf1ea94a258ef9f0742d2c57610/bf98f5a7-4162-40b1-848c-a729943cbb13.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EKKHVKCKHW7KBCGM7IHR55T63V2PAVJWLVFNITJHDU5G6R5IRN3LMWJA%2F20220111%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20220111T221807Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=4adb74034a9b81365ab6dd5df26d2057fbbd2e3e844e84c2ca22ec3df77a8de6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 10085    0     0  100 10085      0  44232 --:--:-- --:--:-- --:--:-- 44232
    -> Reports have been successfully queued for processing at https://codecov.io/github/VinGarcia/ksql/commit/e48c8a0902e62cf1ea94a258ef9f0742d2c57610

Expected Results

I expected everything inside the internal/ and examples/ directories to be ignored.

Actual Results

As I refactor my code moving more code to the internal/ package my test coverage is dropping which makes no sense since these are not public functions.

Aditional details

I found another issue about files not being ignored in a Go project, but the issue was unrelated to what I am doing, here is the link: Ignore is not working for go project

Thank you for this great project, I hope you guys can help me with this issue.

Regards, Vinícius Garcia

@VinGarcia I don’t think the codecov.yml snippet is valid yaml

coverage:
  ignore:
    - "internal/testtools"
    - "internal/structs"
    - "examples/example_service"
    - "examples/**/*"

You can always validate the yaml with these steps.

Let me know if that fixes your problem!

Yeah indeed, that was the problem, after changing to what you proposed it worked as expected.

Thank you.

1 Like