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.

Description

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)
061f907235a28dcf38e9c874ac7b333607abd329

Repository

CI/CD or Build URL

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

Uploader

Codecov Github Action

Codecov Output

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

  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                              Bash-20210129-7c25fce


==> 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
    https://docs.codecov.io/docs/fixing-reports
    -> No adjustments found
==> Gzipping contents
        76K	/tmp/codecov.358oT3.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=integrate_codecov&commit=061f907235a28dcf38e9c874ac7b333607abd329&build=579021027&build_url=http%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgapic-generator-java%2Factions%2Fruns%2F579021027&name=actions%208&tag=&slug=googleapis%2Fgapic-generator-java&service=github-actions&flags=&pr=660&job=ci&cmd_args=n,F,Q,f
->  Pinging Codecov
https://codecov.io/upload/v4?package=github-action-20210129-7c25fce&token=secret&branch=integrate_codecov&commit=061f907235a28dcf38e9c874ac7b333607abd329&build=579021027&build_url=http%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgapic-generator-java%2Factions%2Fruns%2F579021027&name=actions%208&tag=&slug=googleapis%2Fgapic-generator-java&service=github-actions&flags=&pr=660&job=ci&cmd_args=n,F,Q,f
->  Uploading to
https://storage.googleapis.com/codecov/v4/raw/2021-02-18/C88D155125E0E5C12EAEC40D1D1E6279/061f907235a28dcf38e9c874ac7b333607abd329/e2eae404-a590-4b8f-93d5-2dc6da929cb8.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EQX6OZVJGHKK3633AAFGLBUCOOATRACRQRQF6HMSMLYUP6EAD6XSWAAY%2F20210218%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20210218T182040Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=403d56a1e08a4a5ab78c390f58676187e4894d9f90b03c133e1fc507e0e7e621
  % 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 https://codecov.io/github/googleapis/gapic-generator-java/commit/061f907235a28dcf38e9c874ac7b333607abd329

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:

    steps:
    - 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:

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

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