codacy / codacy-coverage-reporter-action

GitHub Action for the codacy-coverage-reporter
Other
58 stars 15 forks source link

[CY-4822] Failing Action: Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1 #47

Closed michealroberts closed 3 years ago

michealroberts commented 3 years ago

I am not sure what else to provide other than the following:

Screenshot 2021-07-30 at 16 04 21

I've tried a number of ways to alleviate this issue. All I can say is running the following locally works fine:

npm run test -- --collectCoverage
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage/lcov.info --api-token $CODACY_API_TOKEN --organization-provider gh --username $CODACY_USERNAME --project-name $CODACY_PROJECT_NAME

However, the action does not work.

I'm using as follows as part of a wider build:

      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@v1
        with:
          api-token: ${{ secrets.CODACY_API_TOKEN }}
          coverage-reports: coverage/lcov.info

Could anyone let me know what I have done wrong here?

github-actions[bot] commented 3 years ago

Internal ticket created : CY-4822

machadoit commented 3 years ago

It really seems that is failing due to the contents of your coverage/lcov.info. Maybe somehow on your pipeline you are not making the file available to that job? Can you troubleshoot on your side, like dumping the content of that file location on that job step, to make sure that the coverage file exists and have the expected contents?

michealroberts commented 3 years ago

Hi @machadoit, thank you for your reply. The lcov.info file has been committed to source control, and it definitely there. It's inside a coverage directory, so ... perhaps I have the coverage-reports flag incorrectly set ...

coverage-reports: coverage/lcov.info

Should this be:

coverage-reports: 'coverage/lcov.info'

or

coverage-reports: ['coverage/lcov.info']

or maybe there's a way to specify the base directory to coverage and upload files from there?

What do you think?

machadoit commented 3 years ago

It should be fine as you have with coverage-reports: coverage/lcov.info and you can see the bash code that tackles that argument at https://github.com/codacy/codacy-coverage-reporter-action/blob/master/action.yml#L32 ant it already put double-quotes wrapping the received value.

The lcov.info file has been committed to source control, and it definitely there

Keep in mind, that even if it is on the source control, does not mean that the GitHub action has access to it on that step. That is why I was suggesting for a dump of the file contents as part of a step on that job, so we can troubleshoot, if there is a 'actions/checkout@main' missing or something of sorts

michealroberts commented 3 years ago

@machadoit

Keep in mind, that even if it is on the source control, does not mean that the GitHub action has access to it on that step. That is why I was suggesting for a dump of the file contents as part of a step on that job, so we can troubleshoot, if there is a 'actions/checkout@main' missing or something of sorts

Awesome ... are you able to provide a snippet for this action ... I can return with the output today if that is helpful.

machadoit commented 3 years ago

You can check the snipped on the README at https://github.com/codacy/codacy-coverage-reporter-action#githubworkflowscodacy-coverage-reporteryml it contains a - uses: actions/checkout@main.

Or are you asking for an example to check the contents of the file? You could add a step with a cat of the contents of the file. For a quick example on how to use an action with shell, you can check this action implementation at https://github.com/codacy/codacy-coverage-reporter-action/blob/master/action.yml#L22

Other than that, I am going to propose, for you to create a simple public repository with an example coverage file commited that you can share, and show it failing on the reporter itself. And then I can fork it an troubleshoot to understand if it is a plugin problem or not.

franciscodua commented 3 years ago

It has been a while since this thread was last active. I'll close it, but feel free to re-open it if you're still having this problem