|
13 | 13 | MAX_WORKFLOW_BYTES = 65536 |
14 | 14 | # Upgrade trusted approvals in three stages: expand, migrate, then contract. |
15 | 15 | # 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",) |
20 | 17 | EXPECTED_CALLERS = ( |
21 | | - """name: AI PR Review |
| 18 | + r"""name: AI PR Review |
22 | 19 |
|
23 | 20 | on: |
24 | 21 | issue_comment: |
|
33 | 30 | review: |
34 | 31 | if: >- |
35 | 32 | github.actor == 'luckyPipewrench' && |
| 33 | + github.actor_id == '142104046' && |
| 34 | + github.run_attempt == '1' && |
36 | 35 | github.triggering_actor == 'luckyPipewrench' && |
37 | 36 | 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' && |
39 | 39 | github.event.issue.pull_request && |
40 | 40 | (github.event.comment.body == '/review' || |
41 | 41 | github.event.comment.body == '/review deep') |
42 | 42 | # 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 |
44 | 44 | with: |
45 | 45 | reviewer_sha: REVIEWER_SHA |
46 | 46 | pr_number: ${{ github.event.issue.number }} |
|
52 | 52 | openai_api_key: ${{ secrets.OPENAI_API_KEY }} |
53 | 53 | """, |
54 | 54 | ) |
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,) |
80 | 55 | EXPECTED_CONTRACTS = ( |
81 | 56 | r"""name: Review caller contract |
82 | 57 |
|
@@ -251,6 +226,20 @@ def test_caller_contract_and_matching_immutable_pins(self): |
251 | 226 | def test_installed_contract(self): |
252 | 227 | validate_contract(WORKFLOW.with_name("review-caller-contract.yaml")) |
253 | 228 |
|
| 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 | + |
254 | 243 |
|
255 | 244 | class WorkflowInputTest(unittest.TestCase): |
256 | 245 | def test_bounded_regular_utf8_file(self): |
@@ -321,6 +310,19 @@ def test_exact_contract_and_caller_changes_are_rejected(self): |
321 | 310 | caller.replace(APPROVED_REVIEWER_SHAS[0], "a" * 40, 1), |
322 | 311 | caller.replace(APPROVED_REVIEWER_SHAS[0], "a" * 40), |
323 | 312 | 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 | + ), |
324 | 326 | ], |
325 | 327 | ), |
326 | 328 | ( |
|
0 commit comments