Giter Club home page Giter Club logo

codacy-coverage-reporter-action's Introduction

Codacy Coverage Reporter GitHub Action

Codacy Badge

This GitHub Action uploads coverage reports to Codacy on all commits and pull requests, letting you track code coverage on the Codacy UI. After setting it up, you can optionally enable status checks on pull requests to avoid adding untested code or decreasing coverage.

Coverage metrics displayed on Codacy

Codacy is an automated code review tool that makes it easy to ensure your team is writing high-quality code by analyzing more than 40 programming languages such as PHP, JavaScript, Python, Java, and Ruby. Codacy allows you to define your own quality rules, code patterns and quality settings you'd like to enforce to prevent issues on your codebase.

Learn more about Codacy Coverage
Why do you need to measure code coverage?


Codacy


Uploading coverage to Codacy

Before setting up Codacy Coverage Reporter GitHub Action you must have tests and use tools to generate coverage reports for the source code files in your repository.

To upload coverage to Codacy using the GitHub Action using default settings:

  1. Set up an API token to allow the GitHub Action to authenticate on Codacy:

    โš ๏ธ Never write API tokens to your configuration files and keep your API tokens well protected, as they grant owner permissions to your projects on Codacy.

  2. Generate a supported code coverage report on each push to your repository.

  3. Add the following to a file .github/workflows/codacy-coverage-reporter.yaml in your repository, where PATH_TO_REPORT is the path to the coverage report:

    name: Codacy Coverage Reporter
    
    on: ["push"]
    
    jobs:
      codacy-coverage-reporter:
        runs-on: ubuntu-latest
        name: codacy-coverage-reporter
        steps:
          - uses: actions/checkout@v2
          - name: Run codacy-coverage-reporter
            uses: codacy/[email protected]
            with:
              project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
              # or
              # api-token: ${{ secrets.CODACY_API_TOKEN }}
              coverage-reports: <PATH_TO_REPORT>
              # or a comma-separated list for multiple reports
              # coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT>
  4. Optionally, to add coverage results to GitHub status checks, configure a quality gate for coverage and enable sending status checks on Codacy.

Parameters

The Codacy GitHub Action is a wrapper for running the Codacy Coverage Reporter CLI and supports the following subset of parameters available for the command report:

Parameter Description Recommended value
project-token Project API token ${{ secrets.CODACY_PROJECT_TOKEN }}
api-token Account API token, an alternative to project-token when setting up multiple repositories ${{ secrets.CODACY_API_TOKEN }}
coverage-reports Optional path or glob pattern to the coverage report relative to the repository root, or a comma-separated list for multiple reports ''
language Optionally associate a language with your coverage report(s) ''
force-coverage-parser Optionally force using a specific coverage report parser ''
coverage-reporter-version Optionally force using a specific coverage reporter version ''

codacy-coverage-reporter-action's People

Contributors

arahaan avatar dmarinhocodacy avatar josemiguelmelo avatar lolgab avatar machadoit avatar mrazauskas avatar mrfyda avatar nicklem avatar pedrocodacy avatar rtfpessoa avatar vitalijr2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codacy-coverage-reporter-action's Issues

Jest coverage report is not uploaded

I'm add trying to add coverage report but don't see it's uploaded: Hey! Seems like we stopped receiving your coverage results. Check your CI server!

link to dashboard:
https://app.codacy.com/gh/Visual-Regression-Tracker/backend/dashboard

here is the link to PR:
Visual-Regression-Tracker/backend#30

version: codacy/[email protected]

the same config works for Codecov so coverage files are generated:
https://codecov.io/gh/Visual-Regression-Tracker/backend

what am I doing wrong?

[CY-4092] new

name: codacy-coverage-reporter

on: ["push"]

jobs:
codacy-coverage-reporter:
runs-on: ubuntu-latest
name: codacy-coverage-reporter
steps:
- uses: actions/checkout@master
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: cobertura.

[CY-4148] Pull Request from forks fail to retrieve source project token

This action fails when sending a Pull Request from a fork:

https://github.com/Monogramm/ldap-all-for-one-manager/runs/2229098120#step:7:20:

2021-03-30 15:45:05.873Z error [CodacyCoverageReporter] Invalid configuration: Empty argument for --project-token  - (CodacyCoverageReporter.scala:25)

 --> Failed!

But it works great with Pull Requests on the same project:

https://github.com/Monogramm/ldap-all-for-one-manager/runs/2297127401#step:7:22

2021-04-08 13:36:09.216Z  info [ConfigurationRules] API base URL: https://api.codacy.com  - (ConfigurationRules.scala:86)
2021-04-08 13:36:09.218Z  info [CommitUUIDProvider] CI/CD provider GitHub Actions found Commit UUID 9c3aec4a5cff1cf831cf17580dc9b2e3a9f63650  - (CommitUUIDProvider.scala:131)
2021-04-08 13:36:09.218Z  info [ReportRules] Parsing coverage data from: /github/workspace/./coverage/coverage-phpunit-cobertura.xml ...  - (ReportRules.scala:43)
2021-04-08 13:36:09.270Z  info [ReportRules] Coverage parser used is com.codacy.parsers.implementation.CoberturaParser$@394ec53c  - (ReportRules.scala:48)
2021-04-08 13:36:09.274Z  info [ReportRules] Generated coverage report: /tmp/codacy-coverage-8113604248686166524.json (15.36 kB)  - (ReportRules.scala:243)
2021-04-08 13:36:09.274Z  info [ReportRules] Uploading coverage data...  - (ReportRules.scala:244)
2021-04-08 13:36:09.632Z  info [ReportRules] Coverage data uploaded. Coverage received successfully.  - (ReportRules.scala:158)
2021-04-08 13:36:09.633Z  info [ReportRules] 
To complete the reporting process, call coverage-reporter with the final flag.
 Check https://docs.codacy.com/coverage-reporter/adding-coverage-to-your-repository/#multiple-reports
 for more information.  - (ReportRules.scala:80)
2021-04-08 13:36:09.633Z  info [CodacyCoverageReporter] All coverage data uploaded.  - (CodacyCoverageReporter.scala:22)

 --> Succeeded!

Edit: Just to make things clear, I'm not expecting the action to work on the fork, I'm expecting the Pull Request from a fork to the original / upstream repository to properly retrieve the secret.

[CY-5878] Wildcard in coverage-reports

I'm running parallel tests so I will upload multiple coverage reports. Ideally, I can add a wildcard (or similar) so that I don't have to hardcode each individual filename (one for each thread). That way, we can change the number of threads without updating the list of coverage-reports.

Specifically, right now I have to write: coverage-reports: "coverage/lcov/project-1.lcov,coverage/lcov/project-2.lcov". I'd like a way to replace the list with a general match for any number.

Docs for the raw coverage script have suggestions for using find, which doesn't appear to be supported here either. That would work too.

[CY-6704] Upload coverage via workflow_run

Hi,

I want to upload coverage reports from github workflows triggered by the workflow_run event in order to be able to access secrets even for coverage data coming from forks. Since these workflows are run from the default branch of the repository, they will be associated with an incorrect commit sha and are therefore not recognized as coverage data belonging to a feature branch. My idea was to pass the correct commit sha manually when uploading, but it does not look like the commit sha is explicitly passed anywhere here in this action. Do you have an idea how to solve this?
Thanks in advance.

[CY-6185] GITHUB_TOKEN permissions used by this action

At https://github.com/step-security/secure-workflows we are building a knowledge-base (KB) of GITHUB_TOKEN permissions needed by different GitHub Actions. When developers try to set minimum token permissions for their workflows, they can use this knowledge-base instead of trying to research permissions needed by each GitHub Action they use.

Below you can see the KB of your GITHUB Action.

name: 'Codacy Coverage Reporter'
#No reference to GitHub token

If you think this information is not accurate, or if in the future your GitHub Action starts using a different set of permissions, please create an issue at https://github.com/step-security/secure-workflows/issues to let us know.

This issue is automatically created by our analysis bot, feel free to close after reading :)

References:

GitHub asks users to define workflow permissions, see https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ and https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token for securing GitHub workflows against supply-chain attacks.

Setting minimum token permissions is also checked for by Open Source Security Foundation (OpenSSF) Scorecards. Scorecards recommend using https://github.com/step-security/secure-workflows so developers can fix this issue in an easier manner.

[CY-4457] Coverage reporter script fetched from site, checksum not checked.

I was investigating the report types that this action supports when I noticed the following issue:

This action seems to download a script (https://coverage.codacy.com/get.sh) during the action to download / execute the reporter. However, it downloads and uses the script without doing a checksum of it. What if someone was able to modify the script on the site through some other vulnerability, and insert something malicious? Or am I misunderstanding something about how this action works?

Relevant line of code:

bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $params --partial &&\

Seems like it might safer to commit the script to this repository and use that instead of downloading it.

This is the same sort of thing that led to the CodeCov security incident: codecov/codecov-action#281

[TCE-1015] Coverage generates but action cannot properly send back to Codacy

I'm currently trying to run this GH Action as part of a longer action that generates coverage and sends to Codacy. The relevant Codacy part of the YAML is:

      - name: Generate Coverage
        run: npm run coverage
      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@v1
        with:
          api-token: ${{secrets.CODACY_TOKEN}}
          coverage-reports: coverage/lcov.info

This has worked as expected for over a year, but we've recently experienced issues specifically when using this Action and trying to send the lcov data back to Codacy. Currently, we keep getting results similar to the following:

--> Expected checksum
7c08e785c88ba02ad9311556e92f07657ccde38387f08989758c02c5508b1032a83c9f383b895a84138b7ec8d315c79e232c77887ca42fb7d998e16bf2178327  codacy-coverage-reporter-linux
 --> Actual checksum
7c08e785c88ba02ad9311556e92f07657ccde38387f08989758c02c5508b1032a83c9f383b895a84138b7ec8d315c79e232c77887ca42fb7d998e16bf2178327  codacy-coverage-reporter-linux
codacy-coverage-reporter-linux: OK
2024-06-17 15:24:38.060Z  info [ConfigurationRules] API base URL: https://api.codacy.com/  - (ConfigurationRules.scala:81)
2024-06-17 15:24:38.258Z  info [CommitUUIDProvider] CI/CD provider GitHub Actions found Commit UUID c285358a090f138405ec7fd85fef7b6449e64168  - (CommitUUIDProvider.scala:134)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2024-06-17 15:24:38.363Z  info [ReportRules] Parsing coverage data from: /home/runner/work/[private-repo-name]/[private-repo-name]/coverage/lcov.info ...  - (ReportRules.scala:41)
2024-06-17 15:24:38.363Z  warn [ReportRules] Report file /home/runner/work/[private-repo-name]/[private-repo-name]/coverage/lcov.info is empty  - (ReportRules.scala:59)
2024-06-17 15:24:38.363Z  info [ReportRules] 
To complete the reporting process, call coverage-reporter with the final flag.
 Check https://docs.codacy.com/coverage-reporter/#multiple-reports
 for more information.  - (ReportRules.scala:88)
2024-06-17 15:24:38.363Z error [CodacyCoverageReporter] No coverage data was sent  - (CodacyCoverageReporter.scala:28)

This is occurring despite seeing the existing unit and integration tests run, pass, and generate the coverage file. Any idea what may be causing the SLF4J issues?

Codacy GitHub Action doesn't close

The coverage action in GitHub shows it is still analyzing where as on codacy page it already has the results. It goes in a never ending loop waiting for results on GitHub page.
The issue started happening since yesterday, Feb 4, 2022.
Please check and let me know if you need any input.

Screenshot 2023-02-05 at 2 20 49 PM

[TCE-978] Pull request branch getting "Commit not found" status

I'm trying to use this GH action within a pull request workflow. The coverage upload action succeeds, but within the Codacy dashboard under the code coverage settings I see failures about "Commit not found" under that "Test your integration" section. I think this is because the commit sha being sent up by the GH action is of the pull request merge commit rather than the head commit sha of the branch. Here's an abbreviated version of my workflow:

name: Code PR Gate

on:
  pull_request:
    branches:
      - main
      - develop

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
      - uses: actions/setup-java@v2
        timeout-minutes: 10
        with:
          java-version: 11
          distribution: 'temurin'
      - uses: gradle/gradle-build-action@v2
        id: gradle
        with:
          arguments: build
      - name: Run codacy-coverage-reporter
        uses: codacy/[email protected]
        with:
          project-token: ${{ secrets.CODACY_TOKEN }}
          coverage-reports: build/reports/jacoco/test/jacocoTestReport.xml

It seems like I might be running into the same issue that should have been resolved here but I'm not certain: #67

Am I doing something wrong or overlooking something?

[CY-3551] Failed to upload coverage report

I'm having an error using this action.

2021-01-27 13:17:41.772Z  info [ConfigurationRules] API base URL: https://api.codacy.com  - (ConfigurationRules.scala:86)
2021-01-27 13:17:41.775Z  info [CommitUUIDProvider] CI/CD provider GitHub Actions found Commit UUID 3e12b8d0b99e1ce2dfdc9c7c8cc1e1243cbec93b  - (CommitUUIDProvider.scala:131)
2021-01-27 13:17:41.775Z  info [ReportRules] Parsing coverage data from: /github/workspace/target/scala-2.12/coverage-report/cobertura.xml ...  - (ReportRules.scala:43)
2021-01-27 13:17:41.793Z  info [ReportRules] Coverage parser used is com.codacy.parsers.implementation.CoberturaParser$@42dd4e62  - (ReportRules.scala:48)
2021-01-27 13:17:41.794Z  info [ReportRules] Generated coverage report: /tmp/codacy-coverage-12628626296437388396.json (4.05 kB)  - (ReportRules.scala:243)
2021-01-27 13:17:41.794Z  info [ReportRules] Uploading coverage data...  - (ReportRules.scala:244)
2021-01-27 13:17:41.937Z  info [ReportRules] 
To complete the reporting process, call coverage-reporter with the final flag.
 Check https://docs.codacy.com/coverage-reporter/adding-coverage-to-your-repository/#multiple-reports
 for more information.  - (ReportRules.scala:80)
2021-01-27 13:17:41.938Z error [CodacyCoverageReporter] Failed to upload coverage report /github/workspace/target/scala-2.12/coverage-report/cobertura.xml: Request URL not found. Check if the project API Token you are using and the API base URL are valid.  - (CodacyCoverageReporter.scala:25)

I've tried even hardcoding the API token in the action, but it's still not working.

my yml:

# This is a basic workflow to help you get started with Actions

name: quality-control

# Controls when the action will run. 
on:

  push:
    branches: [ dev ]
  pull_request:
    branches: [ dev, master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
    
      - name: Test Code with Coverage and Reports
        uses: NikoBergemann/action-sbt-test-report@v2
      
      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ****************
          coverage-reports: target/scala-2.12/coverage-report/cobertura.xml

I'm just using everything as default, so I don't know what could be failing

[CY-3683] Auto discovery

For a multi-module Gradle project should be great that this GitHub Action has an option that allows auto-discover any coverage file in any subproject.

Currently, if there are 100 modules, you can have a long list in the YAML file, and every time you create a new module you have to remember to visit the YAML file to add it, and doing that is annoying.

Something like this which search in every /build/reports/jacoco/ folder in the project:

discovery: **/build/reports/jacoco/*.xml

or which search all files in the project called jacoco.xml

discovery: jacoco.xml

Error using the action

Hey I wanted to use the codacy action to upload my coverage.xml.
But every time I try it I get this error.

image

Errors using action

I'm using PHPUnit 8.5 but can't seem to get my coverage file located at '/build/coverage-xml/index.xml' uploaded.

When I supply that to the 'coverage-reports' param of your action, I get:

2020-06-01 14:17:44.156Z info [ConfigurationRules] API base URL: https://api.codacy.com - (ConfigurationRules.scala:84)
2020-06-01 14:17:44.157Z info [ReportRules] Parsing coverage data from: /build/coverage-xml/index.xml ... - (ReportRules.scala:48)
2020-06-01 14:17:44.157Z error [CodacyCoverageReporter] File /build/coverage-xml/index.xml does not exist. - (CodacyCoverageReporter.scala:25)
--> Failed!

When I supply nothing, I get:
Can't get any report due to no matching! Try to specify the report with -r.

Any ideas where I'm going wrong?

Getting exec format error with codacy-coverage-reporter action

below is my yml file
`name: codacy-coverage-reporter

on:
push:
branches:
- poc-codacy

jobs:
codacy-coverage-reporter:
runs-on: ubuntu-latest
name: codacy-coverage-reporter
steps:
- uses: actions/checkout@master
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
`

below is the error I am getting.

Screenshot 2020-07-06 at 16 25 29

[TS-510] "No such file or directory" when running coverage reporter with version 13.13.3

We are getting this error when running the coverage reporter action using the latest version (13.13.3)

codacy-coverage-reporter-linux: OK
chmod: cannot access '/home/runner/.cache/codacy/coverage-reporter/13.13.3/codacy-coverage-reporter': No such file or directory

With the previous version (13.13.2), our coverage was reporting without errors.

Any ideas?
Thanks.

[CY-3463] Split partial and final steps

In order to send coverage from more than one of the github jobs, it would be useful to have some option to specify to run only the "partial" or only the "final" step.
For example something like this:

name: codacy-coverage-reporter

on: ["push"]

jobs:
  job1:
    runs-on: ubuntu-latest
    name: build1
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Build
        # [...]

      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: cobertura.xml
          partial: true

  job2:
    runs-on: ubuntu-latest
    name: build2
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Build
        # [...]

      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: cobertura.xml
          partial: true

  finalize-coverage-report:
    runs-on: ubuntu-latest
    name: finalize-coverage-report
    needs: [job1, job2]
    steps:
      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: cobertura.xml
          final: true

[CY-6237] Issue with `codacy-coverage-reporter-linux` checksum mismatch

I am using both the GitHub Action and the bash script to push coverage to Codacy, but for a while this has been giving the following error:

--> Expected checksum
4d8299f9fb58aedaee0c2e2948b0cfbdc39be3b0620e64211b8a22bbca607d05a3164edb753b9c5e6128dad56b14d89a1fd4c5b2d56a64c43b08fe0fc384ccd7  codacy-coverage-reporter-linux
--> Actual checksum
424da32d5e55d5a2c20724541807ec7ca7200d2d91b332522e8024df481040f0bdb147d48e9683f406c11d81441ba6fa7221f10a3676d0a04b0ff7f4201d5947  codacy-coverage-reporter-linux
sha512sum: WARNING: 1 computed checksum did NOT match
codacy-coverage-reporter-linux: FAILED

Was only able to run this action after setting CODACY_REPORTER_SKIP_CHECKSUM=true.

Can't find 'action.yml', repository moved

I'm getting the following error running on GitHub Actions:

Download action repository 'mrfyda/codacy-coverage-reporter-action@master'
##[error]Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/_actions/mrfyda/codacy-coverage-reporter-action/master'. Did you forget to run actions/checkout before running your local action?

This is not a local runner, it's running on GitHub's infrastructure.

This is caused by the repository having moved from the mrfyda account to the codacy organisation. If you update your workflow from

    - name: Upload coverage report to Codacy
      uses: mrfyda/codacy-coverage-reporter-action@master
      with:
        project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}

to

    - name: Upload coverage report to Codacy
      uses: codacy/codacy-coverage-reporter-action@master
      with:
        project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}

then everything will work again.

So this is solved for me and not really a bug, I'm just putting this here so others can find it if needed.

[TS-504] Coverage reporter fails on windows builds

Hey, I'm currently having the issue that the coverage reporter fails for no apparent reason. I know that the coverage data exists because it gets successfully sent to codecov in a previous step.

Here's the failed workflow run: https://github.com/chillerlan/php-oauth-core/actions/runs/5684420064/job/15407483856
The last successful run a handful of commits before: https://github.com/chillerlan/php-oauth-core/actions/runs/5578109937/job/15105169028

Screenshot in case the workflow run expires:
Screenshot of the failed workflow run

[CY-4719] Error when running CI for Dependabot PRs

Is there any special configuration/setup required for using with Dependabot?

We're getting the following error:

2021-07-12 22:27:35.255Z error [CodacyCoverageReporter] Invalid configuration: Either a project or account API token must be provided or available in an environment variable  - (CodacyCoverageReporter.scala:25)

And the relevant portion of our CI configuration:

name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
  project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
  coverage-reports: cobertura.xml

[CY-4398] Allow coverage-reports to be set to file globs.

For example let's say I want to upload coverage reports located under my tests subdirectory on my repository however:

  • a copy of that file is only generated in tests located in subdirectories of tests for each test.

As such I would rather do file globbing over a comma separated list of said files for multiple reasons:

  • When more tests are added I would not need to change the workflow and they get automatically picked up.
  • When I want to use the workflows for every project on my user account on github/organization that holds the projects (by placing them in a repository named .github).

This then has benefits as well too, 1 the resulting repositories would be smaller and more easier to focus on development on them as well and less pain in updating the CI's as then they would get updated in 1 place and used globally for all the other repositories.

[CY-4762] Request URL not found. Check if the API Token you are using and the API base URL are valid

My project is here: https://github.com/cassandre-tech/cassandre-trading-bot and the workflow I'm using is here: https://github.com/cassandre-tech/cassandre-trading-bot/blob/development/.github/workflows/continuous-integration.yml.

I've added this to my workflow:

      - name: Upload codacy coverage results
        id: upload-codacy-coverage-reporter
        uses: codacy/[email protected]
        with:
          api-token: ${{ secrets.CODACY_API_TOKEN }}
          coverage-reports: spring-boot-starter/autoconfigure/target/site/jacoco/jacoco.xml

I have this error in the CI:

2021-07-20 19:05:28.879Z  info [ConfigurationRules] API base URL: https://api.codacy.com  - (ConfigurationRules.scala:77)
2021-07-20 19:05:28.879Z  info [CommitUUIDProvider] CI/CD provider GitHub Actions found Commit UUID d0ad078d7d827ccb91ff53a2285a5120337393a5  - (CommitUUIDProvider.scala:131)
2021-07-20 19:05:28.879Z  info [ReportRules] Parsing coverage data from: /home/runner/work/***-trading-bot/***-trading-bot/spring-boot-starter/autoconfigure/target/site/jacoco/jacoco.xml ...  - (ReportRules.scala:43)
2021-07-20 19:05:28.992Z  info [ReportRules] Coverage parser used is com.codacy.parsers.implementation.JacocoParser$@2aa6dbcd  - (ReportRules.scala:48)
2021-07-20 19:05:28.998Z  info [ReportRules] Generated coverage report: /tmp/codacy-coverage-1822594183112371518.json (32.19 kB)  - (ReportRules.scala:256)
2021-07-20 19:05:28.998Z  info [ReportRules] Uploading coverage data...  - (ReportRules.scala:257)
2021-07-20 19:05:29.412Z  info [ReportRules] 
To complete the reporting process, call coverage-reporter with the final flag.
 Check https://docs.codacy.com/coverage-reporter/#multiple-reports
 for more information.  - (ReportRules.scala:82)
2021-07-20 19:05:29.412Z error [CodacyCoverageReporter] Failed to upload coverage report /home/runner/work/***-trading-bot/***-trading-bot/spring-boot-starter/autoconfigure/target/site/jacoco/jacoco.xml: Request URL not found. Check if the API Token you are using and the API base URL are valid.  - (CodacyCoverageReporter.scala:25)

[TCE-897] Pull-Request from contributors can't find CODACY_PROJECT_TOKEN

I setup this file in GitHub to report the coverage to codacy:
https://github.com/LibrePDF/OpenPDF/blob/master/.github/workflows/maven.yml
the relevant part is this:

  codacy-coverage-reporter:
    runs-on: ubuntu-latest
    name: Java 17 and codacy-coverage-reporter
    steps:
      - uses: actions/[email protected]
      - name: Setup java
        uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 17
      - name: Build with Maven
        run: mvn -B verify --file pom.xml
      - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@v1
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: ./openpdf/target/site/jacoco/jacoco.xml,./pdf-toolbox/target/site/jacoco/jacoco.xml,./openpdf-fonts-extra/target/site/jacoco/jacoco.xml

This works great when pushes or PRs are from branches of the repository itself. But when someone clones the repository and create a pull request, than the CODACY_PROJECT_TOKEN is not found, even when the action is executed in my repository.

Like in this case:
https://github.com/LibrePDF/OpenPDF/actions/runs/8409782739

This is the error code:

codacy-coverage-reporter-linux: OK
2024-03-24 13:52:01.253Z error [CodacyCoverageReporter] Invalid configuration: Either a project or account API token must be provided or available in an environment variable  - (CodacyCoverageReporter.scala:28)

 --> Failed!
Error: Process completed with exit code 1.

Is this a bug in the reporter or a problem in my configuration?

[CY-5317] Uploading the coverage reports fails silently

No error is reported, if curl fails during the report upload. The workflow still continues as if the action succeeded.

I suggest do either drop at least an error message ("Upload failed because of: XYZ"), or add a configuration parameter fail_on_error to the action itself.

The curl errors are swallowed here, because of the -s flag to curl.

bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-coverage-reporter/master/get.sh) report $auth $params --partial &&\
bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-coverage-reporter/master/get.sh) final $auth

[CY-3396] Error: File [path]/lcov.info does not exist

Hello,

I think, there is somme thing wrong with the path of reporter file (see image on je first and last line) :
image


Here the lines concerned :

Run ls -al /home/runner/work/mongo-scheduler/mongo-scheduler/coverage
total 20
drwxr-xr-x  3 runner docker 4096 Dec 26 00:15 .
drwxr-xr-x 10 runner docker 4096 Dec 26 00:15 ..
drwxr-xr-x  3 runner docker 4096 Dec 26 00:15 lcov-report
-rw-r--r--  1 runner docker 5941 Dec 26 00:15 lcov.info
 --> Failed!
2020-12-26 00:15:10.922Z  info [ReportRules] Parsing coverage data from: /home/runner/work/mongo-scheduler/mongo-scheduler/coverage/lcov.info ...  - (ReportRules.scala:43)
2020-12-26 00:15:10.922Z  info [ReportRules] 
To complete the reporting process, call coverage-reporter with the final flag.
 Check https://docs.codacy.com/coverage-reporter/adding-coverage-to-your-repository/#multiple-reports
 for more information.  - (ReportRules.scala:80)
2020-12-26 00:15:10.922Z error [CodacyCoverageReporter] File /home/runner/work/mongo-scheduler/mongo-scheduler/coverage/lcov.info does not exist.  - (CodacyCoverageReporter.scala:25)

And here my GHAction file :

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
#         node-version: [10.x, 12.x, 14.x, 15.x]
#         mongodb-version: [4.0, 4.2, 4.4]
        node-version: [15.x]
        mongodb-version: [4.4]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

    - name: Start MongoDB
      uses: supercharge/[email protected]
      with:
        mongodb-version: ${{ matrix.mongodb-version }}

    - run: npm ci && npm i -g projectz badges
    - run: npm run build --if-present
    - run: npm run test:coverage

    - run: cat ${{ github.workspace }}/coverage/lcov.info
    - run: ls -al ${{ github.workspace }}/coverage
      
    - name: Run codacy-coverage-reporter
      uses: codacy/codacy-coverage-reporter-action@master
      with:
        project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
        coverage-reports: lcov.info
```bash

[CY-3880] allow passing parameters to the reporter

When using the reporter in a multi-module project, I need to pass the --partial / --final flags and the params for language and report. Would be nice to have those in the action as well.

Reference, from the codacy docs: https://docs.codacy.com/coverage-reporter/#multiple-reports

[EDIT]: The action takes comma-separated values, but I just want to be able to run the action at different times with partial, not all together.

USE CASE:
A mono repo with several modules and stacks. It becomes hard to collect all the reports in a single action :)

[CY-4882] sha512sum: WARNING: 1 computed checksum did NOT match

How can I fix it?

 curl -Ls https://raw.githubusercontent.com/codacy/codacy-coverage-reporter/master/get.sh
     ______          __
    / ____/___  ____/ /___ ________  __
   / /   / __ \/ __  / __ `/ ___/ / / /
  / /___/ /_/ / /_/ / /_/ / /__/ /_/ /
  \____/\____/\__,_/\__,_/\___/\__, /
                              /____/

  Codacy Coverage Reporter

#=#=#                                                                         

######################################################################## 100.0%
 --> Downloading the codacy reporter codacy-coverage-reporter-linux... (13.1.4)
~/.cache/codacy/coverage-reporter/13.1.4 ~/work/momenti-elixir/momenti-elixir
#=#=#                                                                         

#                                                                          1.9%
###################                                                       26.5%
######################################                                    53.9%
############################################################              84.0%
######################################################################## 100.0%
 --> Checking checksum...
#=#=#                                                                         

######################################################################## 100.0%
######################################################################## 100.0%
sha512sum: WARNING: 1 computed checksum did NOT match
codacy-coverage-reporter-linux: FAILED

[TS-711] Wrong commit UUID is discovered

Hi, your action doesn't allow a mechanism to specify the commit UUID and in my case its auto discovering the wrong commit id:

See my Action Run here:
https://github.com/nHapiNET/nHapi/actions/runs/7222494087/job/19679576963

it "should" discover 6371a8bfc534e7b9df7e724ab4e9d42fdf26ae23 (as seen in the checkout step) but is discovering 50be0187277c901ced58db7ded7acc098f6420d3 and therefor associating the coverage reports with the wrong commit, I know the Codacy Coverage Reporter script has an option to pass --commit-uuid but you aren't using this?

Am I doing something wrong? or is could there be missing feature in this action?

[CY-4067] Unable to send coverage on fork

Fork PR does not have access to the environment token in the secret.

Is there a way to get around it?

It is failing with:

2021-03-28 20:23:45.594Z error [CodacyCoverageReporter] Invalid configuration: Empty argument for --project-token  - (CodacyCoverageReporter.scala:25)

https://github.com/unional/path-equal/pull/27/checks?check_run_id=2213856980

I saw the same issue on other repositories:
https://github.com/Visual-Regression-Tracker/backend/runs/2146070985

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

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?

[CY-4176] Master failing?

Looks like a recent change may have messed up this action, I am now getting this on all builds:

/home/runner/work/_temp/c53da6bb-ae05-463d-b549-29d4ff3c844d.sh: line 3: ./entrypoint.sh: No such file or directory

step just looks like:

     - name: Run codacy-coverage-reporter
        uses: codacy/codacy-coverage-reporter-action@master
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}

[TS-690] External repository token inputs are not supporting

I am getting following errors on my pipeline. I see this action became little bit outdated since does not supporting external-repository-token input.

Unexpected input(s) 'config-file', 'external-repository-token', valid inputs are ['project-token', 'api-token', 'coverage-reports', 'language', 'force-coverage-parser']

[TS-628] Github Actions Error: Process completed with exit code 253

I'm trying to create a github pipeline and I'm getting very generic errors when trying to generate code coverage reports and uploading them to Codacy. I don't see any errors at all in the output log other than the error from my title at the very end. All of my unit tests pass and code builds successfuly. Any ideas on how to find out what the error is? I have pasted the output log below:

enter image description here

- name: Restore .NET Tools
      run: dotnet tool restore
      working-directory: ./tests

    - name: Dotnet Test (Debug)
      run: dotnet dotcover test --dcOutput="AiDotNet.Coverage.xml" --dcReportType="XML"

    - name: Dotnet Build (Release)
      run: dotnet build -c Release
          
    - name: Send Coverage to Codacy
      env:
        CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
      run: bash <(curl -Ls https://coverage.codacy.com/get.sh)

I followed a few different tutorials for how to setup the codacy github actions from the codacy website as well as github action examples.

UPDATE: I'm using the setup .net github action using the code below:

- name: Setup .NET 8.0.x
  uses: actions/setup-dotnet@v3
  with:
    dotnet-version: '8.0.x'

UPDATE #2: I'm uploading the full debug log for the step where it is failing at: https://pastebin.com/Pc7AXiqb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.