Skip to content

Commit d9e9275

Browse files
feat: review draft pull requests by default (#121)
* feat: configure reviews by pull request state Amp-Thread-ID: https://ampcode.com/threads/T-01a081f0-878f-711e-b4ff-07114b8ea68a Co-authored-by: Ivan Milev <ivanmilevtues@gmail.com> * fix: model pull request selection as states Amp-Thread-ID: https://ampcode.com/threads/T-01a081f0-878f-711e-b4ff-07114b8ea68a Co-authored-by: Ivan Milev <ivanmilevtues@gmail.com> * feat: review draft pull requests by default Amp-Thread-ID: https://ampcode.com/threads/T-01a081f0-878f-711e-b4ff-07114b8ea68a Co-authored-by: Ivan Milev <ivanmilevtues@gmail.com> --------- Co-authored-by: Amp <amp@ampcode.com>
1 parent b41de12 commit d9e9275

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎.github/workflows/codeboarding.yml‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ name: CodeBoarding review
22

33
on:
44
pull_request:
5-
# Generate once, when the PR becomes reviewable. Reusing this PR's previous
6-
# analysis makes per-push runs affordable, so `synchronize` is a reasonable
7-
# addition now; /codeboarding still refreshes on demand. 'closed' only
8-
# cancels an in-flight review (see concurrency), it doesn't start one.
9-
types: [opened, reopened, ready_for_review, closed]
5+
# Analyze when the PR opens or receives a commit, whether it is ready or draft.
6+
# Changing only the draft state does not rerun analysis. 'closed' only cancels
7+
# an in-flight review (see concurrency), it doesn't start one.
8+
types: [opened, reopened, closed, synchronize]
109
issue_comment:
1110
types: [created]
1211

@@ -37,7 +36,7 @@ jobs:
3736
# changes generated files, so a diff comment would be noise. Scope this to
3837
# this repository so a fork using the same branch name is still reviewed.
3938
if: >
40-
(github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.draft == false &&
39+
(github.event_name == 'pull_request' && github.event.action != 'closed' &&
4140
github.event.pull_request.head.repo.full_name == github.repository &&
4241
!(github.head_ref == 'codeboarding/sync' && github.event.pull_request.head.repo.full_name == github.repository)) ||
4342
(github.event_name == 'issue_comment' && github.event.issue.pull_request != null &&

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name: CodeBoarding review
1818

1919
on:
2020
pull_request:
21-
types: [opened, reopened, ready_for_review, synchronize]
21+
types: [opened, reopened, synchronize]
2222
issue_comment:
2323
types: [created]
2424

@@ -42,7 +42,7 @@ concurrency:
4242
jobs:
4343
review:
4444
if: >
45-
(github.event_name == 'pull_request' && github.event.pull_request.draft == false &&
45+
(github.event_name == 'pull_request' &&
4646
github.event.pull_request.head.repo.full_name == github.repository) ||
4747
(github.event_name == 'issue_comment' && github.event.issue.pull_request != null &&
4848
startsWith(github.event.comment.body, '/codeboarding') &&
@@ -55,7 +55,7 @@ jobs:
5555
llm: hosted # or license, or a provider name -- see Authentication
5656
```
5757
58-
Automatic runs update one sticky **CodeBoarding review** comment. A trusted repository owner, member, or collaborator can comment `/codeboarding` to analyze the current PR head again, including on fork PRs; every command creates a new result comment.
58+
Automatic runs review both draft and non-draft pull requests and update one sticky **CodeBoarding review** comment. Opening, reopening, or pushing a commit runs analysis; changing only the draft state does not. A trusted repository owner, member, or collaborator can comment `/codeboarding` to analyze the current PR head again, including on fork PRs; every command creates a new result comment.
5959

6060
`synchronize` re-runs the review on every push to the branch. Each of those runs covers only the commits pushed since the previous one, so a push costs a fraction of a first analysis — and a pushed commit is the only thing that builds the reusable analysis, since GitHub gives comment-triggered runs a read-only cache. Drop `synchronize` from the list if you would rather spend one analysis per pull request than one per push.
6161

‎tests/test_action_inputs.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
ROOT = Path(__file__).resolve().parent.parent
1717
ACTION = (ROOT / "action.yml").read_text(encoding="utf-8")
1818
TABLE = json.loads((ROOT / "scripts" / "action" / "supported-providers.json").read_text(encoding="utf-8"))
19+
DOGFOOD = (ROOT / ".github" / "workflows" / "codeboarding.yml").read_text(encoding="utf-8")
1920

2021

2122
def declared_inputs() -> dict[str, str]:
@@ -70,6 +71,15 @@ def test_depth_is_wired_to_state_identity_and_both_analysis_modes(self) -> None:
7071
block = ACTION[start : ACTION.index("\n run:", start)]
7172
self.assertIn("DEPTH_CAP: ${{ inputs.depth_cap }}", block)
7273

74+
def test_default_workflow_reviews_drafts_on_open_and_new_commits(self) -> None:
75+
self.assertNotIn("github.event.pull_request.draft", DOGFOOD)
76+
start = DOGFOOD.index("types:")
77+
types = DOGFOOD[start : DOGFOOD.index("\n", start)]
78+
for event in ("opened", "reopened", "synchronize"):
79+
self.assertIn(event, types)
80+
for state_change in ("ready_for_review", "converted_to_draft"):
81+
self.assertNotIn(state_change, types)
82+
7383
def test_the_inferred_credential_inputs_are_gone(self) -> None:
7484
"""`llm_api_key`/`llm_provider` are what made a fallback expressible at all."""
7585
for stale in ("llm_api_key", "llm_provider"):

0 commit comments

Comments
 (0)