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

Prefix parameter not passed to test-reporter if coverageLocations is empty #265

Closed
matthewshirley opened this issue Dec 4, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@matthewshirley
Copy link
Contributor

Describe the bug
I have set the test reporter to upload without specifying the coverageLocations parameter. In this scenario, the prefix is never added to the after-build call.

Version of codeclimate-action you're using
v2.5.7

Example links

CI Step

      - name: Publish coverage to CodeClimate
        uses: paambaati/codeclimate-action@v2.7.4
        env:
          CC_TEST_REPORTER_ID: demo
        with:
          debug: true
          workingDirectory: ./example_example
          prefix: /home/runner/work/example_example/example_example

Environment

 with:
    debug: true
    workingDirectory: ./example_example
    prefix: /home/runner/work/example_example/example_example
  env:
    ...

Debug

time="2020-12-04T03:52:45Z" level=debug msg="about to run format-coverage" 
time="2020-12-04T03:52:45Z" level=debug msg="searching for a formatter to use" 
time="2020-12-04T03:52:45Z" level=debug msg="checking gocov formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path c.out for gocov formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking jacoco formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path jacoco.xml for jacoco formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking lcov formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path coverage/lcov.info for lcov formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking clover formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path build/logs/clover.xml for clover formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path clover.xml for clover formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking cobertura formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path cobertura.xml for cobertura formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking coverage.py formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="checking search path coverage.xml for coverage.py formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="found file coverage.xml for coverage.py formatter" 
time="2020-12-04T03:52:45Z" level=debug msg="couldn't load committed at from ENV, trying git..." 
time="2020-12-04T03:52:45Z" level=debug msg="creating test file report for /home/runner/work/example_example/example_example/example_example/conftest.py" 
time="2020-12-04T03:52:45Z" level=info msg="trimming with prefix /home/runner/work/example_example/example_example/example_example/" 

Expected behavior
The prefix to be added to the after-build call.

@roobre
Copy link

roobre commented Dec 4, 2020

I just came across this very same issue. Because of codeclimate/test-reporter#378, this breaks all go tests outside of $GOPATH. Since in Github Actions repos are cloned outside of the $GOPATH by default, this renders codeclimate unusable unless workarounded.

Setting a non-empty coverageLocation and computing the prefix does work well:

      - name: Set codeclimate prefix
        run: |
          echo "CC_PREFIX=$(go list -m)" >> $GITHUB_ENV
      - name: Test & publish code coverage
        uses: paambaati/codeclimate-action@v2.7.4
        env:
          CC_TEST_REPORTER_ID: redacted
        with:
          coverageCommand: go test -coverprofile=c.out ./...
          coverageLocations: "${{ github.workspace }}/c.out:gocov" # Should be the default, but workarounds this issue
          prefix: ${{ env.CC_PREFIX }} # Makes reporter work with modern gocov reports

@paambaati
Copy link
Owner

@roobre The fix provided by @matthewshirley has now landed in v2.7.5. Can you try that and see if that fixes your issue? If it doesn't, feel free to reopen this issue.

roobre added a commit to newrelic/nri-prometheus that referenced this issue Dec 10, 2020
roobre added a commit to newrelic/nri-prometheus that referenced this issue Dec 10, 2020
@roobre
Copy link

roobre commented Dec 10, 2020

Seems to be working nice and smooth now, many thanks @paambaati @matthewshirley! ❤️

roobre added a commit to newrelic/nri-prometheus that referenced this issue Dec 14, 2020
* ci: report coverage to codeclimate

* ci: codeclimate: remove debug flag

* ci: add codeclimate config file

* ci/codeclimate: removed coverageLocations workaround
paambaati/codeclimate-action#265 was fixed upstream
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
Development

No branches or pull requests

3 participants