Codecov not blocking PRs

Relevant posts

coverage:

  status:

    default_rules:

      flag_coverage_not_uploaded_behavior: exclude

    project:

      default: off

      client:

        target: auto

        threshold: 0.1%

        flags:

          - client

      backend:

        target: auto

        threshold: 0.1%

        flags:

          - backend

flags:

  backend:

    paths:

      - server/

    carryforward: true

  client:

    paths:

      - client/

    carryforward: true

comment:

  layout: 'reach, diff, flags, files'

  behavior: new

  require_changes: false # if true: only post the comment if coverage changes

  require_base: no # [yes :: must have a base report to post]

  require_head: no

github_checks:

  annotations: true

Description

codecov detects when coverage is dropped below the threshold but does not block a PR from being merged.

CI/CD or Build URL

Github Actions

Uploader

Bash.

Expected Results

The required check to fail and the PR from being blocked from emerging.

Actual Results

The client flag check is not started and the server flag is not available when setting branch protection rules.

@boris please provide a commit SHA and/or links to the CI runs

Hi Tom,

My repo is private so idk how a SHA will help you. I was about to send over logs from the CI run when I noticed they have an error message. The checkout’s fetch is already set to 0. Should I try changing the fetch depth?
image

I played around with the fetch depth. No errors when running the codecov bash, but in a PR that ads 16k lines of code, it measure the coverage differance as 0%.

Run cd ./client && bash <(curl -s https://codecov.io/bash) -t *** -c -F client

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


==> git version 2.31.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:   covtest
      -> GITHUB_REF:        refs/pull/1732/merge
      -> GITHUB_REPOSITORY: remo-co/remo-conference
      -> GITHUB_RUN_ID:     861056289
      -> GITHUB_SHA:        f5d3449843c53f2795ec4b8fd73683e94e4e4c6d
      -> GITHUB_WORKFLOW:   Run Tests
    Fixing merge commit SHA f5d3449843c53f2795ec4b8fd73683e94e4e4c6d -> d263fd2d9072d15c62d5d6b78f8535c39346aa6f
    project root: /home/runner/work/remo-conference/remo-conference
    Yaml found at: codecov.yml
==> Running gcov in /home/runner/work/remo-conference/remo-conference (disable via -X gcov)
==> Python coveragepy not found
==> Searching for coverage reports in:
    + /home/runner/work/remo-conference/remo-conference
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + /home/runner/work/remo-conference/remo-conference/coverage/coverage-final.json bytes=2679020
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
    + Found adjustments
==> Gzipping contents
        348K	/tmp/codecov.PcxwCR.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=covtest&commit=d263fd2d9072d15c62d5d6b78f8535c39346aa6f&build=861056289&build_url=http%3A%2F%2Fgithub.com%2Fremo-co%2Fremo-conference%2Factions%2Fruns%2F861056289&name=&tag=&slug=remo-co%2Fremo-conference&service=github-actions&flags=client&pr=1732&job=Run%20Tests&cmd_args=t,c,F
->  Pinging Codecov
https://codecov.io/upload/v4?package=bash-1.0.2&token=secret&branch=covtest&commit=d263fd2d9072d15c62d5d6b78f8535c39346aa6f&build=861056289&build_url=http%3A%2F%2Fgithub.com%2Fremo-co%2Fremo-conference%2Factions%2Fruns%2F861056289&name=&tag=&slug=remo-co%2Fremo-conference&service=github-actions&flags=client&pr=1732&job=Run%20Tests&cmd_args=t,c,F
->  Uploading to
https://storage.googleapis.com/codecov/v4/raw/2021-05-20/7322BE1301D351472BD266A98261C4C5/d263fd2d9072d15c62d5d6b78f8535c39346aa6f/30175029-ca0b-4365-b092-a03941a90ce3.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EQM3VGPYSAFECJRMNAFIPCV2R3P2BOORCJC7NM537NPJQSFLHUDNIDWA%2F20210520%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20210520T161757Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=fc51ace540fb546340bd0c23bdc4f6769959d402d636bef7500827a12525c864
  % 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  347k    0     0  100  347k      0  1465k --:--:-- --:--:-- --:--:-- 1465k
    -> Reports have been successfully queued for processing at https://codecov.io/github/remo-co/remo-conference/commit/d263fd2d9072d15c62d5d6b78f8535c39346aa6f

@boris the latest commit SHA (in the uploader text) looks like it was deleted (rebased/merged perhaps?). Do you have another example of this?

@tom I was able to narrow down the source of this problem further. The incorrect calculations were caused by jest being misconfigured. PRs are now blocked if the coverage drops in my client project. However I’m still having issues with the server projects. I’m unable to add it as a required check in the PR. The client is available (and I’ve already added it), but server is not.

What is patch and why is codecov/project/server missing?

My codecov.yml

coverage:
  status:
    default_rules:
      flag_coverage_not_uploaded_behavior: exclude
    project:
      default: off
      client:
        target: auto
        threshold: 0.1%
        flags:
          - client
      backend:
        target: auto
        threshold: 0.1%
        flags:
          - backend

flags:
  backend:
    paths:
      - server/
    carryforward: true

  client:
    paths:
      - client/
    carryforward: true

comment:
  layout: 'reach, diff, flags, files'
  behavior: new
  require_changes: false # if true: only post the comment if coverage changes
  require_base: no # [yes :: must have a base report to post]
  require_head: no

github_checks:
  annotations: true

The logs from the bash uploader on a PR where coverage for the server project is uploaded. In this commit, there’s a 30% drop in coverage.

==> git version 2.31.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:   del-tests
      -> GITHUB_REF:        refs/pull/1744/merge
      -> GITHUB_REPOSITORY: remo-co/remo-conference
      -> GITHUB_RUN_ID:     872211434
      -> GITHUB_SHA:        869fa3d9cdb0ae9c3b836e363d6af239139fbefd
      -> GITHUB_WORKFLOW:   Run Tests
    Fixing merge commit SHA 869fa3d9cdb0ae9c3b836e363d6af239139fbefd -> 34fef86e49c852258c1f1933e766c960908a89c2
    project root: /home/runner/work/remo-conference/remo-conference
    Yaml found at: codecov.yml
==> Running gcov in /home/runner/work/remo-conference/remo-conference (disable via -X gcov)
==> Python coveragepy not found
==> Searching for coverage reports in:
    + /home/runner/work/remo-conference/remo-conference
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + /home/runner/work/remo-conference/remo-conference/coverage/coverage-final.json bytes=1137592
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
    + Found adjustments
==> Gzipping contents
        148K	/tmp/codecov.Et74tO.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=del-tests&commit=34fef86e49c852258c1f1933e766c960908a89c2&build=872211434&build_url=http%3A%2F%2Fgithub.com%2Fremo-co%2Fremo-conference%2Factions%2Fruns%2F872211434&name=&tag=&slug=remo-co%2Fremo-conference&service=github-actions&flags=server&pr=1744&job=Run%20Tests&cmd_args=t,c,F
->  Pinging Codecov
https://codecov.io/upload/v4?package=bash-1.0.3&token=secret&branch=del-tests&commit=34fef86e49c852258c1f1933e766c960908a89c2&build=872211434&build_url=http%3A%2F%2Fgithub.com%2Fremo-co%2Fremo-conference%2Factions%2Fruns%2F872211434&name=&tag=&slug=remo-co%2Fremo-conference&service=github-actions&flags=server&pr=1744&job=Run%20Tests&cmd_args=t,c,F
->  Uploading to
https://storage.googleapis.com/codecov/v4/raw/2021-05-24/7322BE1301D351472BD266A98261C4C5/34fef86e49c852258c1f1933e766c960908a89c2/b2deea6e-10e5-4304-a62d-5559d1052e29.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EQM3VGPYSAFECJRMNAFIPCV2R3P2BOORCJC7NM537NPJQSFLHUDNIDWA%2F20210524%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20210524T174830Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=82b6a219b6a4d4409fb37f73f2059786c9325459c20f5fbbf1e280a989a4292a
  % 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  145k    0     0  100  145k      0   478k --:--:-- --:--:-- --:--:--  478k
    -> Reports have been successfully queued for processing at https://codecov.io/github/remo-co/remo-conference/commit/34fef86e49c852258c1f1933e766c960908a89c2
0

@boris, have you uploaded a coverage report with the backend (I think you meant backend, there is no server status in your yaml) flag? If that has never happened, it might explain why GitHub is unaware of the status check.

The patch check deals with coverage on new code changes detailed here (as opposed to project which is meant to encompass the entire repository).

1 Like

It was starting me in the face and I still didn’t see it. Once I renamed the flag from backend to server everything started working correctly. Thank you Tom!

1 Like