Skip to content

Commit 50673a7

Browse files
committed
Switch to PR workflow for nominations
1 parent 52cc978 commit 50673a7

File tree

4 files changed

+136
-3
lines changed

4 files changed

+136
-3
lines changed

.github/workflows/nomination.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: nomination
2+
3+
on:
4+
pull_request_target:
5+
types: [edited, opened, synchronize, reopened]
6+
7+
# We don't need to use the GitHub App for this workflow,
8+
# because it's all localised to this repo
9+
permissions:
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
process:
15+
name: Check
16+
runs-on: ubuntu-latest
17+
if: ${{ ! contains(github.event.pull_request.labels.*.name, 'nomination') && github.event.pull_request.head.ref != 'create-pull-request/sync' }}
18+
steps:
19+
- name: Fetch source
20+
uses: actions/checkout@v4
21+
- name: Process nomination
22+
run: |
23+
set -o pipefail
24+
gh api "repos/$REPOSITORY/pulls/$PR_NUMBER/files" \
25+
--jq '.[] | "\(.status) \(.filename)"' \
26+
| scripts/nomination.sh members "$REPOSITORY" "$PR_NUMBER" "$ANNOUNCEMENT_ISSUE_NUMBER"
27+
env:
28+
REPOSITORY: ${{ github.repository }}
29+
PR_NUMBER: ${{ github.event.pull_request.number }}
30+
ANNOUNCEMENT_ISSUE_NUMBER: "${{
31+
github.repository_owner == 'NixOS' && 35 ||
32+
github.repository_owner == 'infinisil-test-org' && 30 ||
33+
'NO_ISSUE_NUMBER'
34+
}}"
35+
GH_TOKEN: ${{ github.token }}
36+
PROD: "1"

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ whose members have write access to [Nixpkgs](https://github.com/nixos/nixpkgs).
66

77
The [Nixpkgs commit delegators](https://github.com/orgs/NixOS/teams/commit-bit-delegation)
88
maintain the member list in this repository.
9-
While it's in principle possible to request Nixpkgs commit permissions by creating a PR,
10-
please nominate yourself in [this issue](https://github.com/NixOS/nixpkgs/issues/321665) instead.
9+
10+
## Nominations
11+
12+
To nominate yourself or somebody else:
13+
1. Check [open nominations](/../../issues?q=state%3Aopen%20label%3Anomination) to make sure the user hasn't been nominated already.
14+
1. [Click this link](/../../new/main/members?filename=%3CGITHUB_HANDLE%3E) to create a new file in the [`members` directory](./members).
15+
1. Leave the file contents empty and replace `<GITHUB_HANDLE>` with the handle (without `@`) of the user you'd like to nominate .
16+
1. Click on "Commit changes..." and follow the steps to create a PR.
17+
1. State your motivation for the nomination in the PR description.
18+
19+
Such nominations are also automatically announced in [this issue](/../../issues/35), which you can subscribe to for updates.
1120

1221
## Semi-automatic synchronisation
1322

scripts/README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,41 @@ scripts/sync.sh infinisil-test-org actors members-test
4141

4242
Check that it synchronises the files in the `members-test` directory with the team members of the `actors` team.
4343

44-
## `retire.sh`
44+
## Testing `nomination.sh`
45+
46+
This script does not depend on the current repository, but has some external effects.
47+
For testing, we'll use [PR #33](https://github.com/infinisil-test-org/nixpkgs-committers/pull/33) and [issue #30](https://github.com/infinisil-test-org/nixpkgs-committers/issues/30).
48+
49+
To test:
50+
1. Delete all labels of the PR and reset the title:
51+
```bash
52+
gh api --method DELETE /repos/infinisil-test-org/nixpkgs-committers/issues/33/labels
53+
gh api --method PATCH /repos/infinisil-test-org/nixpkgs-committers/pulls/33 -f title="A non-conforming title"
54+
```
55+
1. Run the script while simulating that a non-nomination PR was opened:
56+
```bash
57+
scripts/nomination.sh members infinisil-test-org/nixpkgs-committers 33 30 <<< "removed members/infinisil"
58+
```
59+
60+
Ensure that it exits with 0 and wouldn't run any effects.
61+
1. Run the script while simulating that multiple users were nominated together:
62+
```bash
63+
scripts/nomination.sh members infinisil-test-org/nixpkgs-committers 33 30 <<< "removed members/foo"$'\n'"added members/bar"
64+
```
65+
66+
Ensure that it exits with non-0 and wouldn't run any effects.
67+
1. Run the script simulating a successful nomination
68+
```bash
69+
scripts/nomination.sh members infinisil-test-org/nixpkgs-committers 33 30 <<< "added members/infinisil"
70+
```
71+
72+
Ensure that it exits with 0 and would run effects to label the PR, change the title and post a comment in the issue.
73+
1. Rerun with effects
74+
```bash
75+
PROD=1 scripts/nomination.sh members infinisil-test-org/nixpkgs-committers 33 30 <<< "added members/infinisil"
76+
```
77+
78+
## Testing `retire.sh`
4579

4680
This script has external effects and as such needs a bit more care when testing.
4781

scripts/nomination.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
source "$(dirname -- "${BASH_SOURCE[0]}")"/common.sh
4+
5+
shopt -s nocasematch
6+
7+
usage() {
8+
log "Usage: $0 MEMBERS_DIR REPOSITORY PR_NUMBER ANNOUNCEMENT_ISSUE_NUMBER"
9+
exit 1
10+
}
11+
12+
MEMBERS_DIR=${1:-$(usage)}
13+
REPOSITORY=${2:-$(usage)}
14+
PR_NUMBER=${3:-$(usage)}
15+
ANNOUNCEMENT_ISSUE_NUMBER=${4:-$(usage)}
16+
17+
log "Waiting to get changed files on stdin.."
18+
readarray -t changedFiles
19+
declare -p changedFiles
20+
21+
regex="^added $MEMBERS_DIR/([^/]+)$"
22+
23+
nomineeHandle=
24+
for statusFilename in "${changedFiles[@]}"; do
25+
if [[ "$statusFilename" =~ $regex ]]; then
26+
nomineeHandle=${BASH_REMATCH[1]}
27+
break
28+
fi
29+
done
30+
31+
if [[ -z "$nomineeHandle" ]]; then
32+
log "Not a nomination PR"
33+
exit 0
34+
elif (( "${#changedFiles[@]}" > 1 )); then
35+
log "Only one person can be nominated per PR"
36+
exit 1
37+
fi
38+
39+
effect gh api \
40+
--method PATCH \
41+
"/repos/$REPOSITORY/pulls/$PR_NUMBER" \
42+
-f title="Nominate @$nomineeHandle" \
43+
44+
effect gh api \
45+
--method POST \
46+
"/repos/$REPOSITORY/issues/$ANNOUNCEMENT_ISSUE_NUMBER/comments" \
47+
-F "body=@-" << EOF
48+
The user @$nomineeHandle has been nominated. Endorsements and discussions should be held in the corresponding nomination PR: #$PR_NUMBER
49+
EOF
50+
51+
effect gh api \
52+
--method POST \
53+
"/repos/$REPOSITORY/issues/$PR_NUMBER/labels" \
54+
-f "labels[]=nomination"

0 commit comments

Comments
 (0)