codeclimate-action: CodeClimate Report for Go doesn't work

Error

Actions Result URL: https://github.com/toshimaru/nyan/runs/459063904

./cc-reporter after-build --exit-code 0
time="2020-02-20T23:26:31Z" level=error msg="failed to read file github.com/toshimaru/nyan/main.go\nopen github.com/toshimaru/nyan/main.go: no such file or directory" 
Error: open github.com/toshimaru/nyan/main.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 "f4c78effd3a10a5a45239e6886b35f42475467ad53f09a01002feeb04eb92d5b")
      --insecure                     send coverage insecurely (without HTTPS)
  -p, --prefix string                the root directory where the coverage analysis was performed (default "/home/runner/work/nyan/nyan")

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

##[error]Error: The process './cc-reporter' failed with exit code 255
##[error]๐Ÿšจ CC Reporter after-build checkin failed!
(node:2888) UnhandledPromiseRejectionWarning: Error: The process './cc-reporter' failed with exit code 255
    at ExecState._setResult (/home/runner/work/_actions/paambaati/codeclimate-action/v2.4.0/node_modules/@actions/exec/lib/toolrunner.js:548:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/paambaati/codeclimate-action/v2.4.0/node_modules/@actions/exec/lib/toolrunner.js:531:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/paambaati/codeclimate-action/v2.4.0/node_modules/@actions/exec/lib/toolrunner.js:431:27)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
(node:2888) 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:2888) [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.

My Setting

    steps:
    - uses: actions/setup-go@v2-beta
      with:
        go-version: '^1.13.8'
    ...
    - uses: paambaati/codeclimate-action@v2.4.0
      env:
        CC_TEST_REPORTER_ID: ...
      with:
        coverageCommand: go test ./... -coverprofile c.out

Other information

cc-test-reporter on TravisCI works with the following setting.

...
before_script:
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
  - chmod +x ./cc-test-reporter
  - ./cc-test-reporter before-build
script:
  - go build .
  - go test ./... -coverprofile c.out
after_script:
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 19 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I figured out more. The code climate reporter really depends on what is configured in go.mod. this example here:

module github.com/ccremer/clustercode
go 1.15
require (
...
)

doesnโ€™t work with

    - name: Test & Publish Code Coverage
      uses: paambaati/codeclimate-action@v2.7.5
      env:
        CC_TEST_REPORTER_ID: ...
      with:
        coverageCommand: make test
        prefix: ${{ github.event.repository.name }}
        coverageLocations:
          "${{github.workspace}}/cover.out:gocov"

The problematic line is module github.com/ccremer/clustercode in go.mod. If it were just module clustercode, then the config works. So I made a little hack by just removing the github.com/ccremer/ prefix from the cover file:

.PHONY: test_codeclimate
test_codeclimate: test ## Run tests for CodeClimate
	@sed -i "s%github.com/ccremer/%%" cover.out

and combine with coverageCommand: make test_codeclimate Now it works for me.

@toshimaru Iโ€™ve pushed a fix for this. Can you try v2.5.3?

@toshimaru Why is the prefix empty? For Go itโ€™s needed to give the prefix that is named the same as the directory (I think, or is it the Go module ๐Ÿค” )

It worked! ๐Ÿ‘ https://github.com/toshimaru/nyan/pull/73/checks?check_run_id=468919116

@paambaati Thanks for you quick work ๐Ÿ˜ƒ

@ccremer Sorry, but can you try again? I just pushed a new release.

steps:
  - name: Test & publish code coverage
    uses: paambaati/codeclimate-action@v2.5.0