paambaati / codeclimate-action

GitHub Action to send your code coverage to CodeClimate
MIT License
199 stars 63 forks source link

Error: JSON: Cannot unmarshal object into Go struct #532

Closed ThomasKoppensteiner closed 2 years ago

ThomasKoppensteiner commented 2 years ago

Describe the bug Uploading the code-coverage report fails with Error: json: cannot unmarshal object into Go struct field resultSet.coverage of type []formatters.NullInt.

##[debug]Evaluating: secrets.CC_TEST_REPORTER_ID
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'CC_TEST_REPORTER_ID'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'Run paambaati/codeclimate-action@v3.0.0'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run paambaati/codeclimate-action@v3.0.0
##[debug]Loading inputs
##[debug]Loading env
Run paambaati/codeclimate-action@v3.0.0
##[debug]ℹ️ Downloading CC Reporter from https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 ...
##[debug]✅ CC Reporter downloaded...
##[debug]ℹ️ Verifying CC Reporter checksum...
##[debug]✅ CC Reported checksum verification completed...
##[debug]ℹ️ Verifying CC Reporter GPG signature...
##[debug]✅ CC Reported GPG signature verification completed...
/home/runner/work/sidekiq-undertaker/sidekiq-undertaker/cc-reporter before-build
##[debug]✅ CC Reporter before-build checkin completed...
ℹ️ 'coverageCommand' not set, so skipping building coverage report!
/home/runner/work/sidekiq-undertaker/sidekiq-undertaker/cc-reporter after-build --exit-code 0 --debug
time="2022-04-27T14:00:56Z" level=debug msg="about to run format-coverage" 
time="2022-04-27T14:00:56Z" level=debug msg="searching for a formatter to use" 
time="2022-04-27T14:00:56Z" level=debug msg="checking excoveralls formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path cover/excoveralls.json for excoveralls formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking gcov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path ./ for GCov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking jacoco formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path jacoco.xml for jacoco formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking lcov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path coverage/lcov.info for lcov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking clover formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path build/logs/clover.xml for clover formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path clover.xml for clover formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking coverage.py formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path coverage.xml for coverage.py formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking lcov-json formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking simplecov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path coverage/coverage.json for simplecov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="checking search path coverage/.resultset.json for simplecov formatter" 
time="2022-04-27T14:00:56Z" level=debug msg="found file coverage/.resultset.json for simplecov formatter" 
time="2022-04-27T14:01:05Z" level=debug msg="couldn't load committed at from ENV, trying git..." 
time="2022-04-27T14:01:05Z" level=debug msg="Analyzing simplecov json output from latest format coverage/.resultset.json" 
time="2022-04-27T14:01:05Z" level=debug msg="Analyzing simplecov json output from legacy format coverage/.resultset.json" 
Error: json: cannot unmarshal object into Go struct field resultSet.coverage of type []formatters.NullInt
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, lcov-json, simplecov, xccov]
      --exit-code int                exit code of the test run
  -r, --id string                    reporter identifier (default "***")
      --insecure                     send coverage insecurely (without HTTPS)
  -p, --prefix string                the root directory where the coverage analysis was performed (default "/home/runner/work/sidekiq-undertaker/sidekiq-undertaker")

Global Flags:
  -d, --debug   run in debug mode

(node:1580) UnhandledPromiseRejectionWarning: Error: The process '/home/runner/work/sidekiq-undertaker/sidekiq-undertaker/cc-reporter' failed with exit code 255
Error: The process '/home/runner/work/sidekiq-undertaker/sidekiq-undertaker/cc-reporter' failed with exit code 255
    at ExecState._setResult (/home/runner/work/_actions/paambaati/codeclimate-action/v3.0.0/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/paambaati/codeclimate-action/v3.0.0/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/paambaati/codeclimate-action/v3.0.0/node_modules/@actions/exec/lib/toolrunner.js:469:27)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
(node:1580) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:1580) [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.
Error: 🚨 CC Reporter after-build checkin failed!
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run paambaati/codeclimate-action@v3.0.0

Version of codeclimate-action you're using v3.0.0

Example links Failing Github Actions Run Example Pull Request

Expected behavior Uploading the code-coverage report should work with all versions of codeclimate-action.

Additional context Works with version v2.7.1, but fails with versions above (like: v3.0.0).

paambaati commented 2 years ago

This looks like an upstream issue, and would be better suited as an issue here – https://github.com/codeclimate/test-reporter/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc

To verify this, you can try this out yourself by following the quick guide here – https://docs.codeclimate.com/docs/configuring-test-coverage#quick-guide

ThomasKoppensteiner commented 2 years ago

@paambaati you were right, the issue was not related to codeclimate-action, but rather to https://github.com/codeclimate/test-reporter/issues/413 and https://github.com/codeclimate/test-reporter/issues/418.

In the end I needed to require simplecov_json_formatter manually, when using simplecov >= 0.21.

For details: https://github.com/simplecov-ruby/simplecov#json-formatter

My changes: https://github.com/ThomasKoppensteiner/sidekiq-undertaker/pull/68