typestack / class-validator

Decorator-based property validation for classes.
MIT License
11k stars 795 forks source link

fix: codecov GitHub action is failing #2544

Open braaar opened 2 weeks ago

braaar commented 2 weeks ago

Description

The codecov github action seems to randomly fail, at least in PRs, even when the change in the PR doesn't affect source code or tests.

Minimal code-snippet showcasing the problem Make a PR and run the test action. See example: https://github.com/typestack/class-validator/actions/runs/11377772092/job/31656989112?pr=2542

Expected behavior

Codecov shouldn't start failing when it succeeded during the last push to main.

Actual behavior

Some string that we want to .split appears to be undefined. Here's the full log:

Run codecov -f ./coverage/clover.xml -t  --commit=$GITHUB_SHA --branch=${GITHUB_REF##*/}
  _____          _  
 / ____|        | |  
| |     ___   __| | ___  ___ _____   __  
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /  
| |___| (_) | (_| |  __/ (_| (_) \ V /  
 \_____\___/ \__,_|\___|\___\___/ \_/  
                                v3.8.2
==> Detecting CI Provider
    GitHub Actions CI Detected
==> Configuration: 
    Endpoint: https://codecov.io
{
  commit: '9d88728636805dd[4](https://github.com/typestack/class-validator/actions/runs/11377772092/job/31656989112?pr=2542#step:7:5)87072da397ef79[5](https://github.com/typestack/class-validator/actions/runs/11377772092/job/31656989112?pr=2542#step:7:6)6be25de2c',
  branch: 'merge',
  package: 'node-v3.8.2'
}
==> Building file structure
==> Generating gcov reports (skip via --disable=gcov)
    $ find /home/runner/work/class-validator/class-validator -type f -name '*.gcno'  -exec gcov  {} +
    Failed to run gcov command.
==> Targeting specific file
    + /home/runner/work/class-validator/class-validator/coverage/clover.xml
==> Uploading reports
(node:2022) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
/opt/hostedtoolcache/node/23.0.0/x[6](https://github.com/typestack/class-validator/actions/runs/11377772092/job/31656989112?pr=2542#step:7:7)4/lib/node_modules/codecov/lib/codecov.js:213
        var codecov_report_url = result.split('\n')[0]
                                        ^

TypeError: result.split is not a function
    at /opt/hostedtoolcache/node/23.0.0/x64/lib/node_modules/codecov/lib/codecov.js:213:41
    at /opt/hostedtoolcache/node/23.0.0/x64/lib/node_modules/codecov/node_modules/teeny-request/build/src/index.js:210:1[7](https://github.com/typestack/class-validator/actions/runs/11377772092/job/31656989112?pr=2542#step:7:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Node.js v23.0.0
Error: Process completed with exit code 1.
haiweilian commented 1 week ago

In the PR, secrets.CODECOV_TOKEN is missing, but it is required by codecov.

If using codecov-action@v4: https://github.com/codecov/codecov-action/issues/1431

V4 allows uploads from both forked as well as the base repo. PRs from forked repos don't need tokens for reports to be upload to codecov. PRs from the "upstream" repo, need a token today.

I can't perfectly resolve it unless I ignore PRs from base repo. (e.g.: dependabot[bot])