Skip to content

Commit 4c7eb00

Browse files
ci: switch the review caller to the organization reviewer (#52)
Load the reviewer from pipelab-org/pipelock and admit only the maintainer's numeric account as an organization member on the first run attempt. Remove the transitional approvals for the old caller shape and reviewer pin, and test that both stay rejected.
1 parent b623958 commit 4c7eb00

2 files changed

Lines changed: 40 additions & 35 deletions

File tree

‎.github/workflows/pr-review.yaml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ jobs:
1313
review:
1414
if: >-
1515
github.actor == 'luckyPipewrench' &&
16+
github.actor_id == '142104046' &&
17+
github.run_attempt == '1' &&
1618
github.triggering_actor == 'luckyPipewrench' &&
1719
github.event.comment.user.login == 'luckyPipewrench' &&
18-
github.event.comment.author_association == 'OWNER' &&
20+
github.event.comment.user.id == 142104046 &&
21+
github.event.comment.author_association == 'MEMBER' &&
1922
github.event.issue.pull_request &&
2023
(github.event.comment.body == '/review' ||
2124
github.event.comment.body == '/review deep')
2225
# Keep both pins equal until the nested source identity is verified live.
23-
uses: luckyPipewrench/pipelock/.github/workflows/pr-review-reusable.yaml@3e8534e0dd621c62879238cc01d56f7e58e9d096
26+
uses: pipelab-org/pipelock/.github/workflows/pr-review-reusable.yaml@4edcf46d02011c2aa1e305aff69d4d7100aae0ca
2427
with:
25-
reviewer_sha: 3e8534e0dd621c62879238cc01d56f7e58e9d096
28+
reviewer_sha: 4edcf46d02011c2aa1e305aff69d4d7100aae0ca
2629
pr_number: ${{ github.event.issue.number }}
2730
review_mode: >-
2831
${{ github.event.comment.body == '/review deep' && 'deep' ||

‎scripts/test_pr_review_workflow.py‎

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@
1313
MAX_WORKFLOW_BYTES = 65536
1414
# Upgrade trusted approvals in three stages: expand, migrate, then contract.
1515
# Both bootstrap and trusted validation must pass each stage before merging.
16-
APPROVED_REVIEWER_SHAS = (
17-
"3e8534e0dd621c62879238cc01d56f7e58e9d096",
18-
"4edcf46d02011c2aa1e305aff69d4d7100aae0ca",
19-
)
16+
APPROVED_REVIEWER_SHAS = ("4edcf46d02011c2aa1e305aff69d4d7100aae0ca",)
2017
EXPECTED_CALLERS = (
21-
"""name: AI PR Review
18+
r"""name: AI PR Review
2219
2320
on:
2421
issue_comment:
@@ -33,14 +30,17 @@
3330
review:
3431
if: >-
3532
github.actor == 'luckyPipewrench' &&
33+
github.actor_id == '142104046' &&
34+
github.run_attempt == '1' &&
3635
github.triggering_actor == 'luckyPipewrench' &&
3736
github.event.comment.user.login == 'luckyPipewrench' &&
38-
github.event.comment.author_association == 'OWNER' &&
37+
github.event.comment.user.id == 142104046 &&
38+
github.event.comment.author_association == 'MEMBER' &&
3939
github.event.issue.pull_request &&
4040
(github.event.comment.body == '/review' ||
4141
github.event.comment.body == '/review deep')
4242
# Keep both pins equal until the nested source identity is verified live.
43-
uses: luckyPipewrench/pipelock/.github/workflows/pr-review-reusable.yaml@REVIEWER_SHA
43+
uses: pipelab-org/pipelock/.github/workflows/pr-review-reusable.yaml@REVIEWER_SHA
4444
with:
4545
reviewer_sha: REVIEWER_SHA
4646
pr_number: ${{ github.event.issue.number }}
@@ -52,31 +52,6 @@
5252
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
5353
""",
5454
)
55-
# After the move into pipelab-org: approve the organization caller shape before
56-
# the caller switches to it, because the contract check validates a proposed
57-
# caller with the approved list on the default branch. GitHub does not follow
58-
# repository redirects for reusable workflows, so the reviewer is loaded from
59-
# pipelab-org/pipelock.
60-
_ORG_CALLER = EXPECTED_CALLERS[0].replace(
61-
"luckyPipewrench/pipelock/.github/workflows/pr-review-reusable.yaml@",
62-
"pipelab-org/pipelock/.github/workflows/pr-review-reusable.yaml@",
63-
)
64-
if "author_association == 'OWNER'" in _ORG_CALLER:
65-
_ORG_CALLER = (
66-
_ORG_CALLER.replace(
67-
"github.actor == 'luckyPipewrench' &&",
68-
"github.actor == 'luckyPipewrench' &&\n"
69-
" github.actor_id == '142104046' &&\n"
70-
" github.run_attempt == '1' &&",
71-
)
72-
.replace(
73-
"github.event.comment.user.login == 'luckyPipewrench' &&",
74-
"github.event.comment.user.login == 'luckyPipewrench' &&\n"
75-
" github.event.comment.user.id == 142104046 &&",
76-
)
77-
.replace("author_association == 'OWNER'", "author_association == 'MEMBER'")
78-
)
79-
EXPECTED_CALLERS += (_ORG_CALLER,)
8055
EXPECTED_CONTRACTS = (
8156
r"""name: Review caller contract
8257
@@ -251,6 +226,20 @@ def test_caller_contract_and_matching_immutable_pins(self):
251226
def test_installed_contract(self):
252227
validate_contract(WORKFLOW.with_name("review-caller-contract.yaml"))
253228

229+
def test_only_the_organization_caller_and_reviewer_are_approved(self):
230+
self.assertEqual(APPROVED_REVIEWER_SHAS, ("4edcf46d02011c2aa1e305aff69d4d7100aae0ca",))
231+
self.assertEqual(len(EXPECTED_CALLERS), 1)
232+
self.assertEqual(len(EXPECTED_CONTRACTS), 1)
233+
for required in [
234+
"uses: pipelab-org/pipelock/.github/workflows/pr-review-reusable.yaml@REVIEWER_SHA",
235+
"github.actor_id == '142104046'",
236+
"github.event.comment.user.id == 142104046",
237+
"github.run_attempt == '1'",
238+
"author_association == 'MEMBER'",
239+
]:
240+
self.assertIn(required, EXPECTED_CALLERS[0])
241+
self.assertNotIn("luckyPipewrench/pipelock/", EXPECTED_CALLERS[0])
242+
254243

255244
class WorkflowInputTest(unittest.TestCase):
256245
def test_bounded_regular_utf8_file(self):
@@ -321,6 +310,19 @@ def test_exact_contract_and_caller_changes_are_rejected(self):
321310
caller.replace(APPROVED_REVIEWER_SHAS[0], "a" * 40, 1),
322311
caller.replace(APPROVED_REVIEWER_SHAS[0], "a" * 40),
323312
caller.replace(APPROVED_REVIEWER_SHAS[0], "a" * 39),
313+
caller.replace(
314+
APPROVED_REVIEWER_SHAS[0], "3e8534e0dd621c62879238cc01d56f7e58e9d096"
315+
),
316+
caller.replace("pipelab-org/pipelock/", "luckyPipewrench/pipelock/"),
317+
caller.replace("github.actor_id == '142104046'", "github.actor_id == '0'"),
318+
caller.replace(
319+
"github.event.comment.user.id == 142104046",
320+
"github.event.comment.user.id == 0",
321+
),
322+
caller.replace("github.run_attempt == '1'", "github.run_attempt == '2'"),
323+
caller.replace(
324+
"author_association == 'MEMBER'", "author_association == 'OWNER'"
325+
),
324326
],
325327
),
326328
(

0 commit comments

Comments
 (0)