fix: authenticate and reconcile approval delegations

This commit is contained in:
Turtle committed 2026-09-15 22:12:41 +08:00
1 parent 60d26ac4ab
commit 3e9b6ad94e
9 files changed
+270 -80

No files matched your search

+9 -2
View File
@@ -935,7 +935,10 @@ describe('Weighted approval workflow', () => {
'cancel-in-progress': false,
})
expect(job).toMatchObject({
if: "(github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') && (github.event_name != 'issue_comment' || github.event.issue.pull_request)",
if: "(github.event_name != 'pull_request_target' || github.event.pull_request.state == 'open') && "
+ "(github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') && "
+ "(github.event_name != 'issue_comment' || (github.event.issue.pull_request && github.event.issue.state == 'open' &&\n"
+ " (contains(github.event.comment.body, '/delegate') || contains(github.event.changes.body.from, '/delegate'))))",
name: 'weighted approval publisher',
'runs-on': 'ubuntu-latest',
'timeout-minutes': 5,
@@ -948,13 +951,14 @@ describe('Weighted approval workflow', () => {
},
})
const setupIndex = steps.findIndex(step => typeof step.uses === 'string' && step.uses.startsWith('actions/setup-python@'))
expect(steps[setupIndex]?.if).toBe("steps.revoke.outputs.active == 'true'")
expect(steps[setupIndex]?.uses).toBe('actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1')
const revokeIndex = steps.findIndex(step => step.id === 'revoke')
expect(revokeIndex).toBeGreaterThan(steps.indexOf(checkout!))
expect(revokeIndex).toBeLessThan(setupIndex)
expect(steps[revokeIndex]?.run).toBe('node .github/review-ownership/check-approval.mjs pending')
expect(steps.at(-1)).toMatchObject({
if: "failure() && steps.revoke.outcome == 'success'",
if: "failure() && steps.revoke.outputs.active == 'true'",
run: 'node .github/review-ownership/check-approval.mjs error',
})
const pythonJob = workflowJob(loadWorkflow('.github/workflows/ci.yml'), 'python-sdk')
@@ -963,9 +967,11 @@ describe('Weighted approval workflow', () => {
run: "uv run --python 3.10 --with-requirements .github/review-ownership/requirements.txt python -m unittest discover -s .github/review-ownership -p 'test_*.py'",
})
expect(steps.find(step => step.name === 'Install production lexer')).toMatchObject({
if: "steps.revoke.outputs.active == 'true'",
run: 'python3 -m pip install -r .github/review-ownership/requirements.txt',
})
expect(publish).toMatchObject({
if: "steps.revoke.outputs.active == 'true'",
env: {
GITHUB_TOKEN: '${{ github.token }}',
GITHUB_RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
@@ -973,6 +979,7 @@ describe('Weighted approval workflow', () => {
run: 'node .github/review-ownership/check-approval.mjs',
})
expect(recordJob).toMatchObject({
if: "github.event.pull_request.state == 'open'",
name: 'record weighted approval review event',
'runs-on': 'ubuntu-latest',
'timeout-minutes': 2,