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

feat(ci): implement PR command /request-review #1638

Merged

Conversation

aali309
Copy link
Contributor

@aali309 aali309 commented Aug 29, 2023

Welcome to Cryostat! 👋

Before contributing, make sure you have:

  • Read the contributing guidelines
  • Linked a relevant issue which this PR resolves
  • Linked any other relevant issues, PR's, or documentation, if any
  • Resolved all conflicts, if any
  • Rebased your branch PR on top of the latest upstream main branch
  • Attached at least one of the following labels to the PR: [chore, ci, docs, feat, fix, test]
  • Signed all commits using a GPG signature

To recreate commits with GPG signature git fetch upstream && git rebase --force --gpg-sign upstream/main


Fixes: #1585

Description of the change:

This change will add a label review-requested on the PR when /request-review command is detected and then remove it if the reviewer requested changed on the PR

Motivation for the change:

Raised by Max in the Cryostat team

How to manually test:

  1. Run CRYOSTAT_IMAGE=quay.io... sh smoketest.sh...
  2. ...

@aali309 aali309 added the feat New feature or request label Aug 29, 2023
@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from aea7f92 to 4af1980 Compare August 29, 2023 19:01
Copy link
Member

@tthvo tthvo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GITHUB_TOKEN will soon be restrictive after https://github.com/cryostatio/cryostat/pull/1635.

We should explicitly declare permissions here. You mostly need pull_request: write.

@aali309 aali309 self-assigned this Aug 30, 2023
@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from d91b384 to 2413645 Compare August 30, 2023 21:59
@tthvo tthvo added the ci label Aug 31, 2023
@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from 2413645 to 275edc2 Compare August 31, 2023 14:05
@aali309 aali309 marked this pull request as ready for review August 31, 2023 14:05
@aali309
Copy link
Contributor Author

aali309 commented Aug 31, 2023

Link to the test run aali309/cryostat#16

image

image

Looking at this now, the label is being added. i also see this error:

  reviewers="@cryostatio/reviewers"
  
  echo "Adding label 'review-requested' to the PR"
  gh pr edit 11 --add-label "review-requested"
  
  if [ -n "$reviewers" ]; then
    gh pr request-review 11 --reviewer $reviewers
  else
    echo "Requesting review from @cryostatio/reviewer(s) team"
    gh pr request-review 11 --team cryostatio/reviewer(s)
  fi
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***
Adding label 'review-requested' to the PR
https://github.com/aali309/cryostat/pull/11
/home/runner/work/_temp/8dd5f478-5bf9-4dfb-9[2](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:2)55-180[3](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:3)f82e[4](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:4)34[6](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:6).sh: line [10](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:10): syntax error near unexpected token `('
Error: Process completed with exit code 2.```

@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from 275edc2 to 9afa25d Compare August 31, 2023 16:17
@andrewazores
Copy link
Member

andrewazores commented Aug 31, 2023

    echo "Requesting review from @cryostatio/reviewer(s) team"
    gh pr request-review 11 --team cryostatio/reviewer(s)
  fi
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***
Adding label 'review-requested' to the PR
https://github.com/aali309/cryostat/pull/11
/home/runner/work/_temp/8dd5f478-5bf9-4dfb-9[2](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:2)55-180[3](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:3)f82e[4](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:4)34[6](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:6).sh: line [10](https://github.com/aali309/cryostat/actions/runs/6038327673/job/16384492648#step:3:10): syntax error near unexpected token `('
Error: Process completed with exit code 2.```

The last part:

syntax error near unexpected token `('

looks like it's probably related to:

    echo "Requesting review from @cryostatio/reviewer(s) team"
    gh pr request-review 11 --team cryostatio/reviewer(s)

There shouldn't be () on reviewers, that's probably the unexpected token the shell is complaining about.

@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from dfb7718 to 7861b18 Compare September 1, 2023 13:48
@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from 4911f98 to 08124b6 Compare September 1, 2023 18:15
@aali309 aali309 force-pushed the implementPRcommand/requestReview branch from 0a2dcfe to 7523fad Compare September 5, 2023 14:23
@andrewazores andrewazores merged commit 92fdae5 into cryostatio:main Sep 5, 2023
8 checks passed
@andrewazores
Copy link
Member

Didn't work:

https://github.com/cryostatio/cryostat/actions/runs/6087853970/job/16517292637

 Adding label 'review-requested' to the PR
https://github.com/cryostatio/cryostat/pull/1636
Requesting review from @cryostatio/reviewers
error fetching organization teams: GraphQL: Resource not accessible by integration (organization.teams)
Error: Process completed with exit code 1.

I checked the organization settings and it looks like the reviewers team is publicly readable, so I think this workflow might need to run with some elevated token permissions?

@andrewazores
Copy link
Member

It seems to still work regardless of that workflow failure though, somehow...

@aali309
Copy link
Contributor Author

aali309 commented Sep 5, 2023

It seems to still work regardless of that workflow failure though, somehow...

I am quite confused on this one to be honest. Honestly, If you dint explain to me that the --add-reviewer would work the same in a team and individual environment, I would have thought that was the reason.

@andrewazores
Copy link
Member

The failure seems to be a permissioning issue ("resource not accessible"), not that the reviewer is a team, so I don't think that really has to do with it.

Anyway, this is not a very high priority thing to troubleshoot, so we can come back around to it later. I'll file a separate bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci feat New feature or request safe-to-test
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Task] Implement PR command /request_review
4 participants