codacy / codacy-coverage-reporter-action

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

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

Open asturio opened 3 months ago

asturio commented 3 months ago

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/checkout@v4.1.1
      - 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?

github-actions[bot] commented 3 months ago

Internal ticket created : TCE-897

vitalijr2 commented 3 months ago

I have met same issue:

Codacy / Codacy Coverage Reporter (pull_request)
Codacy / Codacy Coverage Reporter (push)

Both actions fall with message: ... error [CodacyCoverageReporter] Invalid configuration: Either a project or account API token must be provided or available in an environment variable - (CodacyCoverageReporter.scala:28)

vitalijr2 commented 2 months ago

@asturio there is strange behavior of the action: I just run it again and workflows are green, see https://github.com/codacy/codacy-coverage-reporter/issues/502#issuecomment-2107224244

vitalijr2 commented 2 months ago

Update: how I have resolved similar issue https://github.com/codacy/codacy-coverage-reporter/issues/502#issuecomment-2111096048

vitalijr2 commented 4 weeks ago

Update: how I have resolved similar issue codacy/codacy-coverage-reporter#502 (comment)

I was wrong: it was happend last day See [TCE-969] Pull request and push are failed: project or account API token not found