Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0

Please check the troubleshooting guide before creating a ticket.
All fields below are required.


Use Codecov Github Action to upload the bazel-generated code coverage report.
I saw red highlight say

==> GitHub Actions detected.
Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0

Commit SHAs

Please include the commit SHA(s)


CI/CD or Build URL

Please provide which CI/CD you are using or a link to the build where coverage is being uploaded.


Codecov Github Action

Codecov Output

Run codecov/codecov-action@v1
/usr/bin/docker exec  4771c96c1fbe7dc72670959cf01532ee634cff9567d19ed135e0bb3a5aa6f163 sh -c "cat /etc/*release | grep ^ID"
/bin/bash -n actions 8 -F  -Q github-action -f ./bazel-out/_coverage/_coverage_report.dat

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

==> git version 2.20.1 found
==> curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
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 IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 
==> GitHub Actions detected.
->  Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0
    project root: .
    Yaml found at: codecov.yml
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + ./bazel-out/_coverage/_coverage_report.dat bytes=647120
==> Appending adjustments
    -> No adjustments found
==> Gzipping contents
        76K	/tmp/codecov.358oT3.gz
==> Uploading reports
    query: branch=integrate_codecov&commit=061f907235a28dcf38e9c874ac7b333607abd329&build=579021027&,F,Q,f
->  Pinging Codecov,F,Q,f
->  Uploading to
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 75083    0     0  100 75083      0   328k --:--:-- --:--:-- --:--:--  327k
    -> View reports at

Expected Results

Please provide what you expect to have happened (e.g. a file that has missing coverage on a particular line).

Actual Results

Please provide what actually happened.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

@summer-ji-eng, as mentioned by the error, you will need to set fetch-depth to greater than 1 or 0 in order for the commit SHA to be properly set. In particular, this line

@tom Sorry for butting in on someone else’s support request, but I just wanted to ask for a clarification: Does that message mean that we need to explicitly set fetch-depth, in order for Codecov to function properly?

I’m getting this same error, but our workflow never specifies fetch-depth — not as 1, or any other value. The entire step is just:

    - uses: actions/checkout@v2

Is that, in effect, “the problem”, then? (If not, then I’ll be happy to open a new request with full details. It just wasn’t clear to me whether my question is already answered, and the answer is “Start setting fetch-depth in your workflow (and not to 1).”)

To follow up on my own question, looking at the Github Actions console output, the default git fetch command used by actions/checkout does include --depth=1.

So, the answer is yes: If using actions/checkout in a workflow, fetch-depth needs to be explicitly set to override the default value of 1. Our workflow now contains this step:

    - uses: actions/checkout@v2
        fetch-depth: 0

Which cleared up the Codecov error message regarding the commit SHA.