Repository navigation
feat(cursor-review): byok — run the panel on the PR author's own Cursor key #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+341
−6
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
2b3f340
feat(cursor-review): byok — run the panel on the PR author's own Curs…
mattmillerai 9fb2076
docs(cursor-review): byok — say who can read the key roster, and requ…
mattmillerai fa697f5
fix(cursor-review): byok — hold the Blocking gate red on a missing ke…
mattmillerai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """Structural regression tests for cursor-review.yml's `byok` wiring. | ||
|
|
||
| With `byok`, an EMPTY CURSOR_API_KEY means the PR author has no key of their | ||
| own. Two things must hold, and neither fails loudly if it regresses: the gate's | ||
| `should_run` must be vetoed for that author (or the panel runs and every cell | ||
| fails at preflight, with no comment telling them why), and the veto must be | ||
| limited to runs that would start a panel (or a push on a keyless author's PR | ||
| would skip the dismissal job that withdraws a stale approval). Plus the comment | ||
| job must only ever POST on `missing`. | ||
|
|
||
| Stdlib-only, reusing the job splitter from test_workflow_job_isolation. | ||
|
|
||
| Run: python3 .github/cursor-review/tests/test_workflow_byok.py | ||
| """ | ||
|
|
||
| import unittest | ||
|
|
||
| from test_workflow_job_isolation import read_workflow, split_jobs | ||
|
|
||
|
|
||
| def text(lines): | ||
| return "\n".join(lines) | ||
|
|
||
|
|
||
| class WorkflowByokTest(unittest.TestCase): | ||
| def setUp(self): | ||
| self.jobs = split_jobs(read_workflow()) | ||
| self.gate = text(self.jobs["gate"]) | ||
|
|
||
| def test_gate_should_run_is_vetoed_by_a_missing_key(self): | ||
| self.assertIn( | ||
| "should_run: ${{ steps.check.outputs.should_run == 'true' && " | ||
| "steps.byok.outputs.status != 'missing' && 'true' || 'false' }}", | ||
| self.gate, | ||
| ) | ||
|
|
||
| def test_key_check_runs_only_when_a_panel_would_start(self): | ||
| # Not on a same-SHA re-trigger either: that runs no panel, so a | ||
| # keyless author must not be told one was skipped. | ||
| self.assertIn( | ||
| "if: inputs.byok && steps.check.outputs.should_run == 'true' && " | ||
| "steps.dup.outputs.already_reviewed != 'true'", | ||
| self.gate, | ||
| ) | ||
|
|
||
| def test_dedupe_runs_before_the_key_check(self): | ||
| self.assertLess( | ||
| self.gate.index("name: Check for prior review on this commit"), | ||
| self.gate.index("name: Check the BYOK key"), | ||
| ) | ||
|
|
||
| def test_key_check_reads_presence_only(self): | ||
| self.assertIn("KEY_PRESENT: ${{ secrets.CURSOR_API_KEY != '' }}", self.gate) | ||
|
|
||
| def test_the_anthropic_probe_honours_the_veto(self): | ||
| # The probe spends API calls; it must not run for a round the veto | ||
| # already cancelled. | ||
| self.assertIn( | ||
| "if: steps.check.outputs.should_run == 'true' && " | ||
| "steps.byok.outputs.status != 'missing' && steps.dup", | ||
| self.gate, | ||
| ) | ||
|
|
||
| def test_blocking_gate_fails_closed_on_a_missing_key(self): | ||
| # The veto folds into should_run, so without this step a keyless | ||
| # author's round reads as review-free and greens the required check. | ||
| job = text(self.jobs["blocking-gate"]) | ||
| self.assertIn("if: ${{ needs.gate.outputs.byok_status == 'missing' }}", job) | ||
| step = job[job.index("name: Fail if the author has no BYOK key"):] | ||
| step = step[: step.index("- name:", 1)] | ||
| self.assertIn("exit 1", step) | ||
|
|
||
| def test_comment_job_runs_only_on_a_byok_verdict_and_posts_only_on_missing(self): | ||
| job = text(self.jobs["byok-comment"]) | ||
| self.assertIn("inputs.byok", job) | ||
| self.assertIn("needs.gate.outputs.byok_status == 'missing'", job) | ||
| self.assertIn('elif [ "$BYOK_STATUS" = "missing" ]; then', job) | ||
| self.assertEqual(job.count("-X POST"), 1) | ||
|
|
||
| def test_comment_job_checks_out_nothing(self): | ||
| self.assertNotIn("actions/checkout@", text(self.jobs["byok-comment"])) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.