codeclimate-action: Failing unit tests does not abort the action

I was wondering why my unit tests seemingly passed, but no coverage report was generated. I noticed in the job logs that my unit tests failed, but the action continued, making it seem that the check passed. But there’s an error that gets ignored:

FAIL
coverage: 48.1% of statements
FAIL	1.210s
FAIL
(node:2733) UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function
    at escapeData (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/node_modules/@actions/core/lib/command.js:66:10)
    at Command.toString (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/node_modules/@actions/core/lib/command.js:60:35)
    at issueCommand (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/node_modules/@actions/core/lib/command.js:23:30)
    at Object.issue (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/node_modules/@actions/core/lib/command.js:27:5)
    at Object.error (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/node_modules/@actions/core/lib/core.js:120:15)
    at /home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/lib/main.js:89:20
    at Generator.throw (<anonymous>)
    at rejected (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.3/lib/main.js:6:65)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2733) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2733) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

See here: https://github.com/ccremer/znapzend-exporter/runs/475913996?check_suite_focus=true

For now, I’ll have to run the unit tests twice I guess, so the job gets properly aborted.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@markkevans @andreipislariu @ccremer @jasonkarns I’ve finally root-caused the issue and fixed it!

Can you folks test v2.5.7?

EDIT: Please hold off on using it as I’m validating it currently again a hobby project of mine.

EDIT 2: Should work now! phew

Same error. My coverage file is generated successfully but I received this error because the coverageLocation was empty.

Error: could not find a formatter of type undefined
Usage:
  cc-test-reporter format-coverage [coverage file] [flags]

Flags:
      --add-prefix string   add this prefix to file paths
  -t, --input-type string   type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov, xccov]
  -o, --output string       output path (default "coverage/codeclimate.json")
  -p, --prefix string       the root directory where the coverage analysis was performed (default "/home/runner/work/scripty/scripty")

Global Flags:
  -d, --debug   run in debug mode
(node:2717) UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function
    at escapeData (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/node_modules/@actions/core/lib/command.js:66:10)
    at Command.toString (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/node_modules/@actions/core/lib/command.js:60:35)
    at issueCommand (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/node_modules/@actions/core/lib/command.js:23:30)
    at Object.issue (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/node_modules/@actions/core/lib/command.js:27:5)
    at Object.error (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/node_modules/@actions/core/lib/core.js:127:15)
    at /home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/lib/main.js:124:28
    at Generator.throw (<anonymous>)
    at rejected (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.6/lib/main.js:6:65)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2717) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2717) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

However, the whole action still reported a successful exit so there was no indication that anything was wrong 😦

run: https://github.com/testdouble/scripty/runs/543450243?check_suite_focus=true

@jasonkarns can you test something and add the coverageLocations to the github actions workflow file, this fixes the issue for my test repository I think see this example

If anyone needs a working solution, I moved the test command (with coverage generation) outside of this action in the meantime (in .goreleasers before.hooks to be exactly) and using 2.5.0, which seems to be stable:

    - name: Test & Publish Code Coverage
      uses: paambaati/codeclimate-action@v2.5.0
      env:
        CC_TEST_REPORTER_ID: asdf
      with:
        coverageCommand: true
        prefix: (go repo name)

The 2.5.0 version still has some problems: I don’t get the right Branch name and Commit SHA in CodeClimate, if it is getting triggered by a pull request.

I see the problem with the in 2.5.5, but just the branch name, I still have problems with the commit sha.

If anyone needs a working solution, I moved the test command (with coverage generation) outside of this action in the meantime (in .goreleasers before.hooks to be exactly) and using 2.5.0, which seems to be stable:

    - name: Test & Publish Code Coverage
      uses: paambaati/codeclimate-action@v2.5.0
      env:
        CC_TEST_REPORTER_ID: asdf
      with:
        coverageCommand: true
        prefix: (go repo name)