Skip to content

Commit

Permalink
/retest check team membership in graphql. See #416
Browse files Browse the repository at this point in the history
  • Loading branch information
kwk committed Apr 22, 2024
1 parent 5dd67aa commit c290652
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/retest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,35 @@ jobs:
}
const result = await github.graphql(mutation, variables)
console.log(result)
check-team-membership:
runs-on: ubuntu-latest
steps:
- name: Check if commented is member of the required team.
uses: actions/github-script@v7
with:
script: |
const query = `query check_if_user_is_team_member($user_login: String!, $org: String!, $team_slug: String!) {
organization(login: $org) {
team(slug: $team_slug) {
members(query: $user_login) {
totalCount
}
}
}
}`;
const variables = {
"user_login": "${{github.event.comment.user.login}}",
"org": context.repo.owner,
"team_slug": "llvm-toolset-engineers"
}
const result = await github.graphql(query, variables)
console.log(result)
if(result['organization']['team']['members']['totalCount'] != 1) {
core.setFailed("User is not allowed to use the /retest command");
}
get-chroots:
needs: check-team-membership
if: ${{ !github.event.issue.pull_request && startsWith(github.event.comment.body, '/retest')}}
runs-on: ubuntu-latest
outputs:
Expand Down
8 changes: 0 additions & 8 deletions snapshot_manager/snapshot_manager/snapshot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ def retest(
logging.info(f"Trigger comment with ID {trigger_comment_id} not found")
return

# Get author from trigger comment to verify one is in the correct team
team = repo.organization.get_team_by_slug(self.config.retest_team_slug)
if not team.has_in_members(trigger_comment.user):
logging.info(
f"Trigger comment author '{trigger_comment.user.login}' must be a member of this team: '{self.config.retest_team_slug}'"
)
return

# Check chroots
if chroots is None or len(chroots) == 0:
logging.info("No chroots found")
Expand Down

0 comments on commit c290652

Please sign in to comment.