Skip to content

Commit

Permalink
Merge pull request #1 from sugatoray/main
Browse files Browse the repository at this point in the history
  • Loading branch information
sugatoray committed Mar 25, 2022
2 parents fa9fb26 + 85bcb43 commit 0cd3306
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 545 deletions.
6 changes: 5 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Thank you very much for putting in this recipe PR!
This repository is very active, so if you need help with
a PR or once it's ready for review, please let the right people know.
a PR, please let the right people know.
There are language-specific teams for reviewing recipes.
Currently available teams are:
Expand All @@ -19,6 +19,10 @@ Currently available teams are:
If your PR doesn't fall into those categories please contact
the full review team `@conda-forge/staged-recipes`.
Once the PR is ready for review, please contact
`@conda-forge/staged-recipes` to have it merged by writing
<code>@</code>`conda-forge-admin, please ping team` in a new comment.
Due to GitHub limitations first time contributors to conda-forge are unable
to ping these teams. You can [ping the team][1] using a special command in
a comment on the PR to get the attention of the `staged-recipes` team. You can
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Automated Review Labels

These diagrams explain the workflow of the automated review labels actions.

## Workflow

```mermaid
sequenceDiagram
actor User
participant issue
participant GitHub actions
actor Authenticated bot
actor Reviewer
Note right of Authenticated bot: Authenticated bot is a GitHub action with the necessary rights for getMembershipForUserInOrg
User->>issue: Adds any comment
activate GitHub actions
alt is PR AND no review-requested label exists
loop Over ['@conda-forge/staged-recipes', '@conda-forge/help-python', '@conda-forge/help-python-c', '@conda-forge/help-r', '@conda-forge/help-java', '@conda-forge/help-nodejs', '@conda-forge/help-c-cpp', '@conda-forge/help-perl', '@conda-forge/help-julia', '@conda-forge/help-ruby']
alt team is in comment
GitHub actions->>issue: Adds review-requested label
GitHub actions->>issue: Adds team label
GitHub actions->>issue: Remove Awaiting author contribution label
rect rgb(191, 223, 255)
GitHub actions-->>issue: Assigns team for review
end
end
end
end
deactivate GitHub actions
Reviewer->>issue: Adds a review comment
activate Authenticated bot
alt is PR AND commenter is not author of PR AND review-requested label exists
Authenticated bot-->>Reviewer: Checks membership
alt Reviewer is part of staged-recipes
Authenticated bot->>issue: Remove review-requested label
Authenticated bot->>issue: Add Awaiting author contribution label
end
end
deactivate Authenticated bot
```

_Note_: The blue part is proposed and not actually integrated yet.

## Label State Diagram

```mermaid
stateDiagram-v2
[*] --> reviewrequested,team: User pings team
reviewrequested,team --> awaitingauthor,team: staged-recipes reviews
awaitingauthor,team --> reviewrequested,team: User pings team
```
114 changes: 114 additions & 0 deletions .github/workflows/automate-review-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: 'Automated review labels'

on:
issue_comment:
types: [created]
pull_request_review:
types: [submitted]
pull_request_review_comment:
types: [created]

jobs:
add-review-team-label:
name: 'When pinged, label a PR with review team'
if: >
github.event.issue
&& github.event.issue.pull_request
&& !contains(github.event.issue.labels.*.name, 'review-requested')
runs-on: ubuntu-latest
steps:
- name: add-labels
uses: actions/github-script@v6
with:
script: |
const teams = [
'@conda-forge/staged-recipes',
'@conda-forge/help-c-cpp',
'@conda-forge/help-cdts',
'@conda-forge/help-go',
'@conda-forge/help-java',
'@conda-forge/help-julia',
'@conda-forge/help-nodejs',
'@conda-forge/help-perl',
'@conda-forge/help-python',
'@conda-forge/help-python-c',
'@conda-forge/help-r',
'@conda-forge/help-ruby'
];
for (const team of teams) {
let text = context.payload.comment.body;
const regex = new RegExp(team + '[^\-]|' + team + '$');
let result = regex.test(text);
if (result) {
label = team.replace("@conda-forge/help-", "");
label_no_staged = label.replace("@conda-forge/", "");
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label_no_staged, 'review-requested']
})
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['Awaiting author contribution']
});
// TODO: Maybe use GitHub API to request review / assign team
}
}
remove-review-requested-label:
name: 'When reviewed, remove review-requested label'
if: >
(
github.event.issue
&& github.event.issue.pull_request
&& (github.event.sender.login != github.event.issue.user.login)
&& contains(github.event.issue.labels.*.name, 'review-requested')
) || (
github.event.pull_request
&& (github.event.sender.login != github.event.pull_request.user.login)
&& contains(github.event.pull_request.labels.*.name, 'review-requested')
)
runs-on: ubuntu-latest
steps:
- name: check-membership
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
// This step is separate from the labeling step because it uses a token
// with different permissions. If it is combined with the following step,
// then the labeling actions are marked as being completed by whomever
// created the token.
const membership_response = github.rest.teams.getMembershipForUserInOrg({
org: 'conda-forge',
team_slug: 'staged-recipes',
username: '${{ github.event.sender.login }}'
});
membership_response.then(function(result) {
console.log(result);
if (result.data.state == 'active'){
return;
} else {
throw new Error('Reviewer not active member of conda-forge/staged-recipes');
}
});
- name: swap-labels
if: ${{ success() }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['review-requested']
});
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Awaiting author contribution']
});
45 changes: 0 additions & 45 deletions recipes/dbstep/meta.yaml

This file was deleted.

Loading

0 comments on commit 0cd3306

Please sign in to comment.