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

Status check of PRs is broken #9

Closed
algomaster99 opened this issue Mar 31, 2022 · 4 comments
Closed

Status check of PRs is broken #9

algomaster99 opened this issue Mar 31, 2022 · 4 comments

Comments

@algomaster99
Copy link

Hey! Thanks for the workflow, first of all. I integrated it into https://github.com/SpoonLabs/sorald/ and it worked quite well. However, I had to fix the checking of CI status for each PR in the workflow. The URL here kept returning pending even though I am sure the CI was completed with exit code 0. This has also been reported on GitHub community forum.

@mherger
Copy link

mherger commented Aug 29, 2022

@algomaster99 could you please share how you fixed that issue?

@algomaster99
Copy link
Author

algomaster99 commented Aug 29, 2022

Hi @mherger !

I did something like this:

if(${{ github.event.inputs.mustBeGreen }}) {
  console.log('Checking green status: ' + branch);
-  const statusResponse = await github.rest.repos.getCombinedStatusForRef({
+  const check_runs = await github.paginate('GET /repos/{owner}/{repo}/commits/{ref}/check-runs', {
    owner: context.repo.owner,
    repo: context.repo.repo,
    ref: branch
  });
- const state = statusResponse['data']['state'];
-  console.log('Validating status: ' + state);
-  if(state != 'success') {
-    console.log('Discarding ' + branch + ' with status ' + state);
-    statusOK = false;
+  for (const cr of check_runs.data.check_runs) {
+	  console.log('Validating check conclusion: ' + cr.conclusion);
+	  if(cr.conclusion != 'success') {
+	    console.log('Discarding ' + branch + ' with check conclusion ' + cr.conclusion);
+	    statusOK = false;
	  }
}

Reference: https://github.com/SpoonLabs/sorald/blob/fd3db17453ace78fca5f8802f2a1cf7c32c780bd/.github/workflows/combine_prs.yml#L78-L95

@martingjaldbaek
Copy link
Member

Hey, the latest release, 1.3.0, uses a new API that checks the PR/branch status in a way that works both for statuses set with GitHub Actions CI, and external tools. As such this issue should be fixed now. If for any reason it doesn't work for you, let me know!

@algomaster99
Copy link
Author

Thanks @martingjaldbaek ! I will incorporate the latest changes in our workflow.

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

3 participants