romeovs / lcov-reporter-action

Comments a pull request with the code coverage generated by your tests.
MIT License
161 stars 99 forks source link

RequestError [HttpError]: Empty value for parameter 'issue_number': undefined #33

Open aropan opened 2 years ago

aropan commented 2 years ago

I got the error on push:

...
RequestError [HttpError]: Empty value for parameter 'issue_number': undefined
    at /data/actions-runner/_work/_actions/romeovs/lcov-reporter-action/v0.3.1/dist/main.js:22256:15
    at Array.forEach (<anonymous>)
    at /data/actions-runner/_work/_actions/romeovs/lcov-reporter-action/v0.3.1/dist/main.js:22224:12
    at Array.forEach (<anonymous>)
    at validate$1 (/data/actions-runner/_work/_actions/romeovs/lcov-reporter-action/v0.3.1/dist/main.js:22197:23) {
  status: 400,
...

when using config:

...
      - name: Report
        uses: romeovs/lcov-reporter-action@v0.3.1
        with:
          lcov-file: lcov.info
          lcov-base: base.lcov.info
          github-token: ${{ secrets.GITHUB_TOKEN }}
          filter-changed-files: true
          delete-old-comments: true
...
aropan commented 2 years ago

I think this problem with check shouldDeleteOldComments. It should be inside condition (github_1.eventName === "pull_request") {:

...
    if (shouldDeleteOldComments) {
        await deleteOldComments(githubClient, options, github_1);
    }

    if (github_1.eventName === "pull_request") {
        await githubClient.issues.createComment({
            repo: github_1.repo.repo,
            owner: github_1.repo.owner,
            issue_number: github_1.payload.pull_request.number,
            body: body,
        });
    } else if (github_1.eventName === "push") {
        await githubClient.repos.createCommitComment({
            repo: github_1.repo.repo,
            owner: github_1.repo.owner,
            commit_sha: options.commit,
            body: body,
        });
    }
...
boly38 commented 4 months ago

@aropan thanks this was saving me too (on a fork :) ), triggering report coverage step for a workflow that is not PR produces this error

in the step we could disable report coverage by adding the if you was talking about 👍

      - name: Report coverage
        if: github.event_name == 'pull_request'