Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/claude-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
# Requested reviewer: a team member requests a review from the review agent in a pull request's Reviewers box, on
# drafts too. Requests for anyone else or for a team are skipped, as are requests made by bots or the review agent
# (without a lookup), and requests on closed pull requests or forks.
# Push: commits pushed to a pull request that is ready (not a draft), the pull_request event's synchronize action. A
# caller turns it on by listing synchronize. Pushes to closed pull requests and drafts, bots' pull requests, forks
# and deleted forks, and pushes made by bots are skipped, and so is a pull request whose author is not a team member.
# A pull request opened by the review agent is reviewed without a membership lookup. The request asks for a review
# of the commits pushed, and of earlier ones not yet reviewed, with the whole pull request as context, and the
# decision names the commit after the push.
name: Claude review

on:
Expand Down Expand Up @@ -216,15 +222,20 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions: {}
# One request per pull request at a time. A second waits rather than cancelling the first, whose request may already
# have started a session; a third replaces the waiting one. This serialises only the fire request, not the review
# session it starts, so sessions can overlap.
# Two groups per pull request: one for Ready, comment command and requested-reviewer requests, and one for Push
# requests. Each group sends one request at a time. A second waits rather than cancelling the first, whose request
# may already have started a session; a third replaces the waiting one. This serialises only the fire request, not
# the review session it starts, so sessions can overlap.
# Every kind of review request puts the pull request's number in the same place, so a Ready request and a comment
# command for one pull request share a group. The group names the calling workflow too (github.workflow is the
# caller's name), because groups are shared across workflows: in this repository the self-test and the real
# caller both call this workflow for the same pull request, and without it one could cancel the other's request.
# A Push request has a group of its own, ending in -push: pushes come often, and in the shared group a push could
# replace a waiting comment command or requested-reviewer request. A push replaces only another waiting push.
# So a Push fire can run at the same time as a fire of another kind for the same pull request. This departs on
# purpose from #50, which kept one queue for every kind, so that a push never drops an explicit request.
concurrency:
group: claude-review-${{ github.workflow }}-${{ github.repository }}-${{ fromJSON(needs.decide.outputs.decision).pull_request.number }}
group: claude-review-${{ github.workflow }}-${{ github.repository }}-${{ fromJSON(needs.decide.outputs.decision).pull_request.number }}${{ fromJSON(needs.decide.outputs.decision).kind == 'push' && '-push' || '' }}
cancel-in-progress: false
outputs:
# "true" only when the routine trigger accepted the request.
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#
# Comments run this file from the default branch, so the comment command works only once this file is merged there.
#
# Push reviews are off by default. To review the commits pushed to a pull request that is ready (not a draft), add
# `synchronize` to the pull_request types below: `types: [opened, reopened, ready_for_review, review_requested,
# synchronize]`. Each push to a ready pull request whose author is a team member, or the review agent, then requests a
# review of the commits pushed, and of an earlier push's commits that got no review of their own. Pushes to drafts,
# pushes by bots, and pushes to bots' pull requests or to pull requests from forks are never reviewed. The pinned
# release must have Push reviews; an older one skips the event, so adding it early does no harm.
#
# Needs, as organisation or repository settings:
# secret CLAUDE_ROUTINE_TOKEN the code-review routine's bearer token
# secret CLAUDE_REVIEW_APP_PRIVATE_KEY the membership GitHub App's private key
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# place of the real Claude code-review routine. The stub only posts a comment naming the request it received, so a test
# run is fast and cheap and never starts a real review.
#
# When a pull request here is opened, reopened or marked ready for review, or a review is requested (or re-requested)
# from the review agent, cipherstash-agent, the review job calls this pull request's own version of
# When a pull request here is opened, reopened or marked ready for review, commits are pushed to it, or a review is
# requested (or re-requested) from the review agent, cipherstash-agent, the review job calls this pull request's own version of
# .github/workflows/claude-review.yml (`$/`, GitHub's form for this repository at the exact
# commit that is running, not a pinned commit), with the stub's trigger id and token. The
# verify job then fails if the review workflow decided not to request a review, naming the skip reason, if the request
Expand All @@ -20,9 +20,10 @@
# membership is private as CONTRIBUTOR or NONE, so the commenter's author_association cannot tell who may ask.
#
# Pull requests from forks (which get none of this repository's secrets) and pull requests opened by bots are not
# tested, and neither are drafts when they are opened or reopened: the skipped job says why. Marking a draft ready, or
# requesting a review from the review agent, runs the test; the review workflow takes a requested reviewer on a draft
# too. A review requested from anyone else, or from a team, or on a closed pull request, starts no job at all, not even
# tested, and neither are drafts when they are opened or reopened, pushes to a draft (the review workflow never
# reviews them), or pushes made by a bot (which the review workflow skips): the skipped job says why. Marking a draft
# ready, or requesting a review from the review agent, runs the test; the review workflow takes a requested reviewer on
# a draft too. A review requested from anyone else, or from a team, or on a closed pull request, starts no job at all, not even
# the skipped one: the review workflow would skip a closed pull request, and the verify job would fail for it.
#
# Needs, as repository settings (never the real routine's trigger or token):
Expand All @@ -37,7 +38,7 @@ name: Self-test

on:
pull_request:
types: [opened, reopened, ready_for_review, review_requested]
types: [opened, reopened, ready_for_review, review_requested, synchronize]
# Runs with this repository's secrets, from main, for any comment on an issue or pull request here. Only a team
# member's comment command is acted on: the review job's condition filters out comments that cannot be one, and the
# review workflow checks every rule itself, team membership included. No job checks out or runs the pull request's
Expand All @@ -61,7 +62,8 @@ jobs:
|| (github.event.requested_reviewer.login == 'cipherstash-agent' && github.event.pull_request.state == 'open'))
&& ((github.event.action != 'review_requested' && github.event.pull_request.draft)
|| github.event.pull_request.head.repo.full_name != github.repository
|| github.event.pull_request.user.type == 'Bot')
|| github.event.pull_request.user.type == 'Bot'
|| (github.event.action == 'synchronize' && github.event.sender.type == 'Bot'))
runs-on: ubuntu-latest
timeout-minutes: 5
permissions: {}
Expand All @@ -71,13 +73,19 @@ jobs:
DRAFT: ${{ github.event.action != 'review_requested' && github.event.pull_request.draft }}
FROM_THIS_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
AUTHOR_TYPE: ${{ github.event.pull_request.user.type }}
PUSH: ${{ github.event.action == 'synchronize' }}
SENDER_TYPE: ${{ github.event.sender.type }}
run: |
if [[ "$DRAFT" == true ]]; then
if [[ "$DRAFT" == true && "$PUSH" == true ]]; then
reason="the push is to a draft; pushes to a draft are never reviewed, and marking it ready for review runs the test"
elif [[ "$DRAFT" == true ]]; then
reason="the pull request is a draft; marking it ready for review, or requesting a review from cipherstash-agent, runs the test"
elif [[ "$FROM_THIS_REPOSITORY" != true ]]; then
reason="the pull request comes from a fork, which gets none of this repository's secrets"
elif [[ "$AUTHOR_TYPE" == Bot ]]; then
reason="the pull request was opened by a bot, which gets none of this repository's secrets and whose requests the review workflow skips"
elif [[ "$PUSH" == true && "$SENDER_TYPE" == Bot ]]; then
reason="the push was made by a bot, whose pushes the review workflow skips"
else
reason="unknown"
fi
Expand All @@ -86,7 +94,8 @@ jobs:

# Calls the review workflow with the stub routine's trigger and token: this pull request's own version for a
# pull_request event, and main's for a comment. A draft is tested only for a requested reviewer or a comment
# command, which the review workflow takes on drafts too.
# command, which the review workflow takes on drafts too. A push is tested only when a person made it, because the
# review workflow skips a bot's push; only a push is filtered on its sender.
#
# For a comment, the condition is a filter only, and lets through nothing the review workflow would skip as not a
# comment command, so a red test always means something: the first line must be `@cipherstash-agent review` followed
Expand All @@ -108,7 +117,8 @@ jobs:
|| (github.event.requested_reviewer.login == 'cipherstash-agent' && github.event.pull_request.state == 'open'))
&& (github.event.action == 'review_requested' || github.event.pull_request.draft == false)
&& github.event.pull_request.head.repo.full_name == github.repository
&& github.event.pull_request.user.type != 'Bot')
&& github.event.pull_request.user.type != 'Bot'
&& (github.event.action != 'synchronize' || github.event.sender.type != 'Bot'))
|| (github.event_name == 'issue_comment'
&& github.event.action == 'created'
&& github.event.issue.pull_request
Expand Down
6 changes: 5 additions & 1 deletion CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Reusable GitHub Actions workflows shared by CipherStash repositories, starting w
## Language

**Review request**:
A GitHub event that asks for a Claude review of one pull request: the pull request becoming ready, a comment command, or a requested reviewer.
A GitHub event that asks for a Claude review of one pull request: the pull request becoming ready, a comment command, a requested reviewer, or a push.
_Avoid_: trigger, review trigger

**Ready**:
Expand All @@ -20,6 +20,10 @@ _Avoid_: mention, slash command
The review request made by requesting a review from the review agent in a pull request's Reviewers box.
_Avoid_: assigned reviewer

**Push**:
The review request made when commits are pushed to a pull request that is ready (not a draft). It asks for a review of the commits pushed, and of an earlier push's commits that got no review of their own, with the whole pull request as context. A caller turns it on by listing the pull request `synchronize` event.
_Avoid_: sync, update, review on push

**Team member**:
A member of the GitHub team allowed to make review requests (by default `@cipherstash/developers`); nobody else can cause a review.
_Avoid_: member, collaborator, maintainer
Expand Down
Loading
Loading