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

##[error]Found no pull request. #10

Closed
revmischa opened this issue Apr 16, 2020 · 13 comments
Closed

##[error]Found no pull request. #10

revmischa opened this issue Apr 16, 2020 · 13 comments

Comments

@revmischa
Copy link

revmischa commented Apr 16, 2020

    runs-on: ubuntu-latest
    needs: compile
    steps:
      - uses: actions/checkout@v2
      - name: Restore target dir
        uses: actions/download-artifact@v1
        with:
          name: target
      - name: Coverage
        uses: jetbridge/[email protected]
        with:
          commands: coverage coverageReport
      - uses: 5monkeys/cobertura-action@master
        with:
          path: target/scala-2.12/coverage-report/cobertura.xml
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          minimum_coverage: 90

Gives me the error:

Run 5monkeys/cobertura-action@master
  with:
    path: target/scala-2.12/coverage-report/cobertura.xml
    repo_token: ***
    minimum_coverage: 90
    skip_covered: true
    show_line: false
    show_branch: false
    show_class_names: false
    only_changed_files: false
[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
##[error]Found no pull request.

(It's a pull request and not a fork)

@hannseman
Copy link
Contributor

On what triggers are the job run? Make sure that you use:

on:
  pull_request:
    branches:
      - master (or what ever you want to target)

If that's not possible you can limit the action with a conditional:

- name: Report coverage
  if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')
  uses: 5monkeys/cobertura-action@master
  with:
    path: target/scala-2.12/coverage-report/cobertura.xml
    repo_token: ${{ secrets.GITHUB_TOKEN }}
    minimum_coverage: 90

@revmischa
Copy link
Author

on: push

Is what I have for triggers

@hannseman
Copy link
Contributor

Yes, that won't work. See my comment above. This action can only act on pull requests.

@lucasteles
Copy link

Why its only for PR? i'm having the same problem

@hannseman
Copy link
Contributor

@lucasteles help me understand what your expected result is. The point of this action is to parse a cobertura report file and then write a comment on a PR with the content. If I’m missing a usecase I would love to know it but it’s hard to guess :)

@lucasteles
Copy link

@hannseman Hi, Now I saw how it works, the action puts a comment on PR, I didn't get it when i commented

Would be possible to add a note on workflow annotation?

image

@Siemian
Copy link
Contributor

Siemian commented Sep 11, 2020

running this action on triggers different than pull request will be possible once this is merged #20

@mskrip
Copy link

mskrip commented Apr 19, 2021

And if you want to have the PR number in a push event trigger you can do this, for example, through the Github API:

    - name: Find a pull request containing this commit
      uses: octokit/[email protected]
      id: get_pr
      with:
        route: GET /search/issues?q=${{ github.sha }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Set PR number
      run: |
        pr_number=${{ fromJson(steps.get_pr.outputs.data).items[0].number }}
        echo "PR_NUMBER=${pr_number}" >> $GITHUB_ENV
...
    - name: Post coverage report as comment
      uses: 5monkeys/cobertura-action@master
      with:
        ...
        pull_request_number: ${{ env.PR_NUMBER }}

It's not perfect but it gets the job done.

@dinkopehar
Copy link

dinkopehar commented Jun 9, 2021

You can use:

...
pull_request_number: ${{ github.event.number }}

which makes finding Pull request and setting PR number obsolete. Based on this answer.

@mskrip
Copy link

mskrip commented Jun 10, 2021

You can use:

...
pull_request_number: ${{ github.event.number }}

which makes finding Pull request and setting PR number obsolete. Based on this answer.

This only applies if you are using on: pull_request unfortunately. on: push event trigger does not contain the event number.

@dinkopehar
Copy link

pull_request_number refers to pull_request being open. If it's on: push trigger, where does this action post comment than ?

@paulz
Copy link

paulz commented Aug 1, 2021

We got this working by using workflow triggered on push and PR but only running action on PR.
This way when PR updates report gets updated, but when we push on main without report is skipped.

on:
  pull_request:
    branches:
      - '**'
  push:
    branches:
      - main
...

    - name: cobertura-report
      uses: 5monkeys/cobertura-action@61b3b14d4da85a16843613a7de9c49aaeddd9d1b
      if: ${{ github.event_name == 'pull_request' }}
      with:
        path: html/cobertura.xml
        repo_token: ${{ github.token }}
        minimum_coverage: 100
        show_branch: true
        pull_request_number: ${{ github.pull_request.number }}
        fail_below_threshold: true

it seem extraneous to specify pull_request_number: ${{ github.pull_request.number }}

@hannseman
Copy link
Contributor

This should now be fixed by #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants