Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing unit tests does not abort the action #119

Closed
ccremer opened this issue Feb 28, 2020 · 17 comments · Fixed by #127 or #154
Closed

Failing unit tests does not abort the action #119

ccremer opened this issue Feb 28, 2020 · 17 comments · Fixed by #127 or #154
Assignees
Labels
bug Something isn't working

Comments

@ccremer
Copy link

ccremer commented Feb 28, 2020

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.

@paambaati paambaati self-assigned this Mar 4, 2020
paambaati added a commit that referenced this issue Mar 4, 2020
@paambaati paambaati added the bug Something isn't working label Mar 4, 2020
@paambaati
Copy link
Owner

@ccremer v2.5.4 should fix this issue!

@ccremer
Copy link
Author

ccremer commented Mar 4, 2020

Unfortunately, still not fixed: https://github.com/ccremer/znapzend-exporter/runs/484538939

@paambaati paambaati reopened this Mar 4, 2020
@jasonkarns
Copy link
Contributor

jasonkarns commented Mar 29, 2020

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

@paambaati
Copy link
Owner

Apologies, but I still haven’t been able to root-cause this properly.

Would you mind running the latest version and reporting back?

@jasonkarns
Copy link
Contributor

I'm running 2.5.6

@ccremer
Copy link
Author

ccremer commented Mar 30, 2020

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/[email protected]
      env:
        CC_TEST_REPORTER_ID: asdf
      with:
        coverageCommand: true
        prefix: (go repo name)

@andreipislariu
Copy link

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/[email protected]
      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.

@markkevans
Copy link

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

@paambaati
Copy link
Owner

@markkevans Thanks for the workaround. If it indeed works, then it might give me a clue about the issue.

@andreipislariu @ccremer @jasonkarns Can you folks confirm that this workaround works?

@ccremer
Copy link
Author

ccremer commented Apr 12, 2020

With 2.5.6 it gets interesting. Previously an unsuccessful run continued. Now it's the opposite: A successful test runs but fails to format

The workaround with specifying coverageLocations works, also for a failing unit test

In the previous comment, it also seems to be an issue in the format step

/home/runner/work/scripty/scripty/cc-reporter format-coverage [] -t undefined -o codeclimate.0.json
Error: could not find a formatter of type undefined
...
(node:2717) UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function

@paambaati
Copy link
Owner

paambaati commented Apr 17, 2020

@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

paambaati added a commit to paambaati/websight that referenced this issue Apr 17, 2020
…i/codeclimate-action#119"

This reverts commit 8214099.

Because I think
paambaati/codeclimate-action@473bbba
might have *FINALLY* *ACTUALLY* fixed the damn issue.
@ccremer
Copy link
Author

ccremer commented Apr 18, 2020

With 2.5.7 now something else broke again... https://github.com/ccremer/znapzend-exporter/runs/597634507?check_suite_focus=true:

    - name: Test & Publish Code Coverage
      uses: paambaati/[email protected]
      env:
        CC_TEST_REPORTER_ID: ...
      with:
        coverageCommand: go test -coverprofile c.out ./...
        prefix: znapzend-exporter
/home/runner/work/znapzend-exporter/znapzend-exporter/cc-reporter before-build
/opt/hostedtoolcache/go/1.14.2/x64/bin/go test -coverprofile c.out ./...
ok  	znapzend-exporter	1.209s	coverage: 49.4% of statements
/home/runner/work/znapzend-exporter/znapzend-exporter/cc-reporter after-build --exit-code 0
time="2020-04-18T10:17:10Z" level=error msg="failed to read file znapzend-exporter/config.go\nopen znapzend-exporter/config.go: no such file or directory" 
Error: open znapzend-exporter/config.go: no such file or directory
Usage:
  cc-test-reporter after-build [flags]

Flags:
  -s, --batch-size int               batch size for source files (default 500)
  -e, --coverage-endpoint string     endpoint to upload coverage information to (default "https://api.codeclimate.com/v1/test_reports")
  -t, --coverage-input-type string   type of input source to use [clover, cobertura, coverage.py, excoveralls, gcov, gocov, jacoco, lcov, simplecov, xccov]
      --exit-code int                exit code of the test run
  -r, --id string                    reporter identifier (default "e83a1c47936e887bb37d1e37ebd3395744d4b73693a3c6e199294182be045210")
      --insecure                     send coverage insecurely (without HTTPS)
  -p, --prefix string                the root directory where the coverage analysis was performed (default "/home/runner/work/znapzend-exporter/znapzend-exporter")

Global Flags:
  -d, --debug   run in debug mode
(node:4476) UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function

    at escapeData (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/node_modules/@actions/core/lib/command.js:66:10)
    at Command.toString (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/node_modules/@actions/core/lib/command.js:60:35)
    at issueCommand (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/node_modules/@actions/core/lib/command.js:23:30)
    at Object.issue (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/node_modules/@actions/core/lib/command.js:27:5)
    at Object.error (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/node_modules/@actions/core/lib/core.js:127:15)
    at /home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/lib/main.js:195:20
    at Generator.throw (<anonymous>)
    at rejected (/home/runner/work/_actions/paambaati/codeclimate-action/v2.5.7/lib/main.js:6:65)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

@paambaati
Copy link
Owner

@ccremer Can you configure your job to include the debug: true flag and the ACTIONS_STEP_DEBUG secret to true so I can get additional debugging information?

@ccremer
Copy link
Author

ccremer commented Apr 18, 2020

Update: it seems the coverageLocation parameter is now mandatory, then it works:

/home/runner/work/znapzend-exporter/znapzend-exporter/cc-reporter before-build
/opt/hostedtoolcache/go/1.14.2/x64/bin/go test -coverprofile c.out ./...
ok  	znapzend-exporter	1.209s	coverage: 49.4% of statements
/home/runner/work/znapzend-exporter/znapzend-exporter/cc-reporter format-coverage /home/runner/work/znapzend-exporter/znapzend-exporter/c.out -t gocov -o codeclimate.0.json --prefix znapzend-exporter
/home/runner/work/znapzend-exporter/znapzend-exporter/cc-reporter sum-coverage codeclimate.0.json -p 1 -o coverage.total.json
/home/runner/work/znapzend-exporter/znapzend-exporter/cc-reporter upload-coverage -i coverage.total.json
Test report uploaded successfully to Code Climate

@paambaati
Copy link
Owner

@ccremer Can you link me to both the runs with the additional flags turned on (see #119 (comment))?

@ccremer
Copy link
Author

ccremer commented Apr 18, 2020

@ccremer
Copy link
Author

ccremer commented Apr 18, 2020

A failing unit test stops the action, so thats good so far: https://github.com/ccremer/znapzend-exporter/runs/597650813?check_suite_focus=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants