Skip to content

GitHubCI: add workflow to detect WIP commits in PR - #430

Open
knocte wants to merge 2 commits into
masterfrom
wip/detectWIPcommitsInPR
Open

knocte wants to merge 2 commits into
masterfrom
wip/detectWIPcommitsInPR

Conversation

@knocte

@knocte knocte commented Nov 23, 2026

Copy link
Copy Markdown
Member

If PR is marked as non-draft (ready for review) and it contains WIP commits, a comment yelling to the author will be posed.

If PR is marked as non-draft (ready for review) and it contains
WIP commits, a comment yelling to the author will be posed.
By adding 'synchronize' this workflow will also fire when more
commits are added to a PR (so that if PR is not marked as DRAFT
and the new commits are WIP, the author is warned that she
should only test things in DRAFT PRs).
@knocte

knocte commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

/pi please review this PR

@nodefect nodefect left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow has a few gaps that can miss WIP commits or post misleading/repeated warnings. Please address the event coverage and notification behavior before merging.

# Use the base repository's token so comments also work for fork PRs.
# Never check out or execute PR code in this workflow.
pull_request_target:
types: [opened, synchronize, ready_for_review, converted_to_draft]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Recheck reopened PRs and base-branch changes

A ready PR can be closed, have WIP commits pushed while closed, and then be reopened; reopened is not subscribed, so it is never checked until another head update. Similarly, changing the base branch can introduce WIP commits into the PR without triggering these events. Subscribe to reopened and the relevant edited events and re-evaluate the PR.


jobs:
comment-on-wip-commits:
if: github.event.pull_request.draft == false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Check the current draft state before posting

This uses the event snapshot, not the PR's current state. If a non-draft PR is pushed and then promptly converted to draft while the synchronize run is queued, that run still posts an admonishment on the now-draft PR. Fetch the current PR state before commenting (and consider cancelling superseded runs), so converting to draft actually prevents the warning.

uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Account for the 250-commit API limit

pulls.listCommits returns at most 250 commits for a PR, even when paginated. For larger PRs a WIP commit beyond that limit is silently missed. Use a complete commit listing/comparison for large PRs, or provide a fallback when the limit is reached.

pull_number: pr.number,
per_page: 100
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Detect lowercase WIP prefixes too

A commit such as wip: implement feature is a WIP commit but will not trigger this check. The repository's empty-wip rule also treats the prefix case-insensitively, so this creates an inconsistent gap for otherwise valid commit messages. Normalize the header's case before testing the prefix.

if (!commits.some(commit => commit.commit.message.startsWith('WIP'))) {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Avoid posting the same warning on every push

Every synchronize event creates a new comment as long as any existing WIP commit remains, even when the push only adds an unrelated fix. A ready PR receiving several pushes will therefore accumulate identical comments and repeatedly notify its author. Reuse/update an existing bot warning or otherwise deduplicate while the same violation persists.

@nodefect

Copy link
Copy Markdown
Contributor

Review submitted with five findings covering missed WIP commits, event handling, and repeated or stale warnings.


View action run | Model: ppq/auto | Time: 1m 46s | Tokens: 77.8K | Pi SDK v1.5.2 | Action v2.30.2-develop (develop @ d5e244b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants