Skip to content

Commit db0c92b

Browse files
committed
Extend and improve testing instructions
Now also documents testing of how the commit history is used to infer committer addition times. To make that work, we use a clean members-test directory that is guaranteed to not exist in the upstream repo, so it has a clean history that isn't conflicting.
1 parent 2ccc350 commit db0c92b

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

scripts/README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,32 @@ Once you have the above setup (or got @infinisil to add yourself to his), you ha
3636
This script has no external effects and as such can be easily tested by running:
3737

3838
```bash
39-
scripts/sync.sh infinisil-test-org actors members
39+
scripts/sync.sh infinisil-test-org actors members-test
4040
```
4141

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

4444
## `retire.sh`
4545

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

4848
### Setup (important!)
4949

50-
To avoid other users getting pings, ensure that the `members` directory contains only a simulated new user and your own user (simulated to have been added over a year ago), then commit and push it for testing:
50+
To avoid other users getting pings, ensure that the `members-test` directory contains only simulated new users and your own user (simulated to have been added over a year ago), then commit and push it for testing:
5151

5252
```bash
5353
me=$(gh api /user --jq .login)
5454
git switch -C "test-$me"
55-
rm -rf members
56-
mkdir members
57-
date +%F > "members/github"
58-
date --date="1 year ago 1 day ago" +%F > "members/$me"
59-
git add members
55+
rm -rf members-test
56+
mkdir -p members-test
57+
58+
touch members-test/"$me"
59+
date +%F > "members-test/new-committer-1"
60+
git add members-test
61+
GIT_COMMITTER_DATE=$(date --date @0) git commit -m testing
62+
63+
touch "members-test/new-committer-2"
64+
git add members-test
6065
git commit -m testing
6166
git push -f -u origin HEAD
6267
```
@@ -67,40 +72,40 @@ The following sequence tests all code paths:
6772

6873
1. Run the script with the `active` repo argument to simulate CI running without inactive users:
6974
```bash
70-
scripts/retire.sh infinisil-test-org active nixpkgs-committers members 'yesterday 1 month ago'
75+
scripts/retire.sh infinisil-test-org active nixpkgs-committers members-test 'yesterday 1 month ago'
7176
```
7277

7378
Check that no PR would be opened.
7479
2. Run the script with the `empty` repo argument to simulate CI running with inactive users:
7580

7681
```bash
77-
scripts/retire.sh infinisil-test-org empty nixpkgs-committers members 'yesterday 1 month ago'
82+
scripts/retire.sh infinisil-test-org empty nixpkgs-committers members-test 'yesterday 1 month ago'
7883
```
7984

80-
Check that it would only create a PR for your own user and not the "github" user before running it again with `PROD=1` to actually do it:
85+
Check that it would only create a PR for your own user and not the "new-committer-1" or "new-committer-2" user before running it again with `PROD=1` to actually do it:
8186

8287
```bash
83-
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members 'yesterday 1 month ago'
88+
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members-test 'yesterday 1 month ago'
8489
```
8590

8691
Check that it created the PR appropriately.
8792
You can undo this step by closing the PR.
8893
3. Run it again to simulate CI running again later:
8994
```bash
90-
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members 'yesterday 1 month ago'
95+
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members-test 'yesterday 1 month ago'
9196
```
9297
Check that no other PR is opened.
9398
4. Run it again with `now` as the date to simulate the time interval passing:
9499
```bash
95-
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members now
100+
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members-test now
96101
```
97102
Check that it undrafted the previous PR and posted an appropriate comment.
98103
5. Run it again to simulate CI running again later:
99104
```bash
100-
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members now
105+
PROD=1 scripts/retire.sh infinisil-test-org empty nixpkgs-committers members-test now
101106
```
102107
6. Reset by marking the PR as a draft again.
103108
7. Run it again with the `active` repo argument to simulate activity during the time interval:
104109
```bash
105-
PROD=1 scripts/retire.sh infinisil-test-org active nixpkgs-committers members now
110+
PROD=1 scripts/retire.sh infinisil-test-org active nixpkgs-committers members-test now
106111
```

0 commit comments

Comments
 (0)