Files
gstack/.github/workflows/plain-title.yml
T
Garry Tanandcapy-ai[bot] c53b15c48d Open pull requests with three plain lines and land each one as a single commit (GST-2737) (#4438)
* WIP plain PR bodies and squash messages

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Fold PR bodies to three plain lines and land every PR as one plainly titled commit

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Expect the plain commit body in the train land tests

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Count the new policy keys in the floor tests and record the ship size change

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Let older, generated and Dependabot PRs pass the body check, and keep comments posting

The opening check now follows the same date and branch exemption as the rest of the body check, Dependabot branches are exempt, the exemption only counts for branches in this repository, a merge that cannot read the PR waits instead of refusing, and a broken policy file no longer stops comments.

Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p1/specialist-batched#2 reader=testing
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p1/red-team#4 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Stop re-posted PR bodies from duplicating sections, and let file names through the word check

Posting an already-folded body now replaces each section once instead of keeping the old copy beside it, and listed words inside file paths or file names, such as a test file in the Tests section, no longer count as prose.

Review-Finding: v2/outside-voice#3 reader=outside-voice
Review-Finding: v2/adversarial-native#2 reader=adversarial-native
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Describe the folded three-line PR body in the skills guide and the prose lint help

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-11-17 13:14:33 +00:00

110 lines
5.0 KiB
YAML

name: Plain title
# Checks that a PR's title reads in everyday words (R76, docs/ship-policy.md#plain-titles).
# The title is refused in the front: tracker codes, project-only words and a
# type(scope): prefix. One trailing group of references like (ABC-123) or (#4122)
# is fine. The body is refused when it breaks the plain shape (docs/writing-prs.md);
# the branch name and the commit subjects only warn.
# PRs created before the policy's since date are exempt.
#
# WHY pull_request_target: it runs the base repository's copy of this workflow,
# of bin/gstack-plain-title and of .gstack/plain-titles.json, so a PR cannot
# change the rule it is checked against, and a title edit reruns the check.
#
# WHY this is SAFE:
# - The job checks out the BASE repo (no ref:) and never runs PR code.
# - The token is read-only (contents: read, pull-requests: read).
# - The title, branch, body and created_at arrive only through env: and are
# written to files with printf '%s'. No PR field is inlined into run:.
# - Only the checker's match lines reach the log; PR text is never echoed.
# test/plain-title-workflow-safety.test.ts is the static tripwire for all of it.
on:
pull_request_target:
types: [opened, edited, synchronize, reopened, ready_for_review]
permissions:
contents: read
pull-requests: read
jobs:
plain-title:
name: Plain title
# No job-level if: every event, a base change included, reruns the title
# check, because a skipped run would count as passing over a refused title.
runs-on: ubuntu-24.04
timeout-minutes: 5
# A newer event for the same PR cancels the older run.
concurrency:
group: plain-title-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
# Base repo only: trusted code. No PR-head checkout.
- name: Checkout base repo (trusted)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: 1.4.2
- name: Write the PR fields to files
env:
# Attacker-controlled on fork PRs: env only, never inlined into run:.
PR_TITLE: ${{ github.event.pull_request.title }}
GH_TOKEN: ${{ github.token }}
PR_NUM: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
printf '%s' "$PR_TITLE" > "$RUNNER_TEMP/pr-title.txt"
# The body comes from the event file: a large body overflows one environment string (E2BIG).
jq -j '.pull_request.body // ""' "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/pr-body.txt"
# Commit subjects are a warning only: skip quietly when the API read fails.
if ! gh api --paginate "repos/$REPO/pulls/$PR_NUM/commits" \
--jq '.[] | select((.parents | length) < 2) | .commit.message | split("\n")[0]' \
> "$RUNNER_TEMP/pr-commits.txt" 2>/dev/null; then
: > "$RUNNER_TEMP/pr-commits.txt"
fi
- name: Check the title
env:
PR_CREATED_AT: ${{ github.event.pull_request.created_at }}
run: |
set -euo pipefail
bun --no-env-file --config=/dev/null bin/gstack-plain-title check \
--title-file "$RUNNER_TEMP/pr-title.txt" --created-at "$PR_CREATED_AT" --mode refuse
# The body: its opening, at most three lines before the first fold, and no
# listed word above the Agent notes fold (docs/writing-prs.md). A PR created
# before the policy's body_since date, or from a generated branch the policy
# exempts (release notes repeat CHANGELOG text), only gets warnings. Only a
# branch in this repository counts as exempt: a fork names its own branches.
- name: Check the body
if: ${{ !cancelled() }}
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PR_CREATED_AT: ${{ github.event.pull_request.created_at }}
run: |
set -euo pipefail
exempt_branch=""
if [ "$PR_HEAD_REPO" = "$GITHUB_REPOSITORY" ]; then exempt_branch="$PR_BRANCH"; fi
bun --no-env-file --config=/dev/null bin/gstack-plain-title check \
--body-file "$RUNNER_TEMP/pr-body.txt" --head-branch "$exempt_branch" \
--created-at "$PR_CREATED_AT" --mode refuse
- name: Check the branch name and commit subjects (warnings only)
if: ${{ !cancelled() }}
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
PR_CREATED_AT: ${{ github.event.pull_request.created_at }}
run: |
set -euo pipefail
bun --no-env-file --config=/dev/null bin/gstack-plain-title check \
--branch "$PR_BRANCH" \
--commits-file "$RUNNER_TEMP/pr-commits.txt" --created-at "$PR_CREATED_AT" --mode warn