Repository navigation
feat: add PR title check action - #18
Merged
Merged
Conversation
Add the composite action actions/pr-title. A script checks the whole title: Conventional Commits format with an allowed type, at most 50 characters in total, no uppercase start of the description, no trailing period or whitespace, one line. The title comes in through the environment only, and every failed rule is reported with the title length. Tests cover good and bad titles. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the test job: run the title tests, and the action itself on a good and a bad title. The gate now needs it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read types across lines, allow acronyms and names at the start of the description, reject an empty title, a trailing ellipsis or no-break space. Tests now assert the reported rule, cover invalid inputs and several rules at once, and CI exercises the types and max-length inputs. Lint shell scripts with shellcheck; document the rules in the READMEs and CONTRIBUTING. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Treat no-break, figure, narrow no-break and zero-width spaces as whitespace at both ends of the description, let acronyms such as S3 or C++ start it, keep the max-length input out of the log, and test the types input in CI with a type that is not a default. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideIntroduces a secure, plain Bash composite action for enforcing the repository’s pull request title convention, with configurable types and length, exhaustive rule reporting, documentation, focused tests, CI integration, and shell-script linting. Sequence diagram for the PR title check actionsequenceDiagram
participant Workflow
participant Action
participant Script
participant GitHub
Workflow->>Action: Run actions/pr-title
Action->>Script: bash check.sh
Action->>Script: PR_TITLE, PR_TITLE_TYPES, PR_TITLE_MAX_LENGTH
Script->>Script: Validate title rules
alt Rules pass
Script-->>Action: Exit 0
Action-->>Workflow: Check succeeds
else Rules fail
Script->>GitHub: Emit error annotations
Script-->>Action: Exit 1
Action-->>Workflow: Check fails
end
Flow diagram for PR title validation rulesflowchart TD
A[PR title from pull_request event] --> B[Read title and inputs from environment]
B --> C{Valid inputs and non-empty title?}
C -- No --> E[Emit error annotation and exit 1]
C -- Yes --> D[Validate format, allowed type, length, casing, whitespace, and punctuation]
D --> F{Any rules failed?}
F -- Yes --> G[Report every failed rule with title length]
G --> E
F -- No --> H[Print success with title length and exit 0]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
uniqueg
marked this pull request as ready for review
October 28, 2026 06:13
There was a problem hiding this comment.
Hey - I've found 9 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="actions/pr-title/README.md" line_range="36" />
<code_context>
+name: PR title
+on:
+ pull_request:
+ types: [opened, edited, synchronize, reopened, ready_for_review]
+
+permissions: {}
</code_context>
<issue_to_address>
**Obsolete title checks leave stale results**
When a PR title is edited while an earlier title-check run is queued or running, both workflow runs check their event's title snapshot and publish the `PR title` check for the same head commit. The earlier run can finish last, leaving a successful check for an invalid current title or a failing check for a valid one.
Cancel or otherwise prevent superseded title-check runs from publishing results.
</issue_to_address>
### Comment 2
<location path="actions/pr-title/check.sh" line_range="70" />
<code_context>
+ fi
+ # A capitalised word (`Add`), not an acronym or name (`API`, `OpenAPI`,
+ # `S3`, `C++`)
+ if [[ "${description}" =~ ^[[:upper:]][[:lower:]]*([[:space:]]|$) ]]; then
+ errors+=("The description starts with a capitalised word; use lowercase")
+ fi
</code_context>
<issue_to_address>
**Capitalized descriptions pass validation**
When the description starts with a capitalized word followed by punctuation or one of the listed invisible spaces, the casing check in `check.sh` recognizes a word boundary only at POSIX whitespace or the end of the description, so it accepts titles that violate the lowercase-description rule.
Update the casing check to recognize punctuation and the listed invisible spaces as word boundaries.
Also at `actions/pr-title/check.sh:71`.
</issue_to_address>
### Comment 3
<location path="actions/pr-title/check.sh" line_range="54" />
<code_context>
+
+# Type, optional scope (no spaces or parentheses), optional `!`, then `: `
+# and a description that starts with a visible character
+format="^([a-z]+)(\\([^()[:space:]]+\\))?(!)?: ([^[:space:]${invisible}].*)\$"
+if [[ "${title}" =~ ${format} ]]; then
+ type="${BASH_REMATCH[1]}"
</code_context>
<issue_to_address>
**Allowed custom types are rejected**
When the caller configures an allowed type containing a hyphen or digit, the `format` regex accepts only `[a-z]+` for the type, so a configured type such as `security-fix` or `v2` is rejected as malformed.
Make the format check accept configured types containing hyphens or digits.
</issue_to_address>
### Comment 4
<location path="actions/pr-title/check.sh" line_range="54" />
<code_context>
+
+# Type, optional scope (no spaces or parentheses), optional `!`, then `: `
+# and a description that starts with a visible character
+format="^([a-z]+)(\\([^()[:space:]]+\\))?(!)?: ([^[:space:]${invisible}].*)\$"
+if [[ "${title}" =~ ${format} ]]; then
+ type="${BASH_REMATCH[1]}"
</code_context>
<issue_to_address>
**Whitespace in scopes passes validation**
When a scope contains a no-break, figure, narrow no-break, or zero-width space, the scope character class in `format` excludes POSIX whitespace but not the additional characters in `invisible`, so the title passes despite the no-spaces scope rule.
Exclude the characters in `invisible` from the scope character class.
</issue_to_address>
### Comment 5
<location path="actions/pr-title/check.sh" line_range="50" />
<code_context>
+
+# Whitespace that [[:space:]] misses: no-break, figure, narrow no-break and
+# zero-width spaces
+invisible=$'\u00a0\u2007\u202f\u200b'
+
+# Type, optional scope (no spaces or parentheses), optional `!`, then `: `
</code_context>
<issue_to_address>
**Zero-width no-break space passes validation**
When a title contains U+FEFF at the start of its description or at its end, `invisible` omits U+FEFF, and the format and trailing-whitespace checks do not otherwise recognize it, so the title passes despite the documented whitespace rule.
Include U+FEFF in the invisible whitespace set used by the format and trailing-whitespace checks.
Also at `actions/pr-title/check.sh:54`, `actions/pr-title/check.sh:77`.
</issue_to_address>
### Comment 6
<location path="actions/pr-title/check.sh" line_range="44" />
<code_context>
+ title="${title//[$'\n\r']/ }"
+fi
+
+if ((length > max_length)); then
+ errors+=("Too long: ${length} characters, at most ${max_length} allowed")
+fi
</code_context>
<issue_to_address>
**Large limits reject valid titles**
When `max-length` is a positive decimal larger than Bash's signed integer range, `((length > max_length))` evaluates the limit as a fixed-width signed integer, which wraps negative and reports ordinary titles as too long.
Compare the limit without signed-integer overflow or reject values outside the supported range.
</issue_to_address>
### Comment 7
<location path="actions/pr-title/check.sh" line_range="44" />
<code_context>
+ title="${title//[$'\n\r']/ }"
+fi
+
+if ((length > max_length)); then
+ errors+=("Too long: ${length} characters, at most ${max_length} allowed")
+fi
</code_context>
<issue_to_address>
**Valid limits abort checking**
When the `max-length` input is `08` or another accepted value that Bash cannot parse as octal, bash evaluates `max_length` as an octal number in `((length > max_length))`; `08` passes the positive-integer validation but causes an arithmetic error, so the action exits without reporting the title check result.
Evaluate the limit explicitly in base 10 or reject values that Bash arithmetic cannot safely parse.
</issue_to_address>
### Comment 8
<location path="tests/pr-title/test.sh" line_range="24" />
<code_context>
+ if [[ "${got}" != "${want}" ]]; then
+ echo "NOT OK: expected ${want}, got ${got}: ${title@Q}"
+ failures=$((failures + 1))
+ elif [[ -n "${message}" && "${output}" != *"${message}"* ]]; then
+ echo "NOT OK: expected output ${message@Q}, got ${output@Q}: ${title@Q}"
+ failures=$((failures + 1))
</code_context>
<issue_to_address>
**Extra rule failures go unnoticed**
When the checker emits the expected annotation alongside an unrelated failure annotation, `expect` in `tests/pr-title/test.sh` only checks that `$output` contains `$message`, so a checker that reports the expected rule plus unrelated false-positive rules still passes these cases.
Assert the complete set of reported rule annotations for each failure case.
</issue_to_address>
### Comment 9
<location path="tests/pr-title/test.sh" line_range="27" />
<code_context>
+ elif [[ -n "${message}" && "${output}" != *"${message}"* ]]; then
+ echo "NOT OK: expected output ${message@Q}, got ${output@Q}: ${title@Q}"
+ failures=$((failures + 1))
+ elif grep -qE '^::(warning|notice|debug|add-mask|stop-commands)' <<< "${output}"; then
+ echo "NOT OK: the title injected a workflow command: ${title@Q}"
+ failures=$((failures + 1))
</code_context>
<issue_to_address>
**Error-command injection goes unnoticed**
When a multiline title contains `::error::injected` and the checker prints that line as a workflow command, the `expect` helper in `tests/pr-title/test.sh` excludes `::error` from its workflow-command scan, while the multiline injection cases use only `::warning`; a regression that emits an injected `::error` command therefore passes the injection check.
Distinguish the expected error annotations from title-derived output and assert that no title content produces an additional workflow command.
Also at `tests/pr-title/test.sh:122-123`.
</issue_to_address>Sourcery assessment
Approval pending. 9 findings to address first.
Blocking findings: actions/pr-title/README.md:36, actions/pr-title/check.sh:70, actions/pr-title/check.sh:54, actions/pr-title/check.sh:54, actions/pr-title/check.sh:50, and 4 more
Bound max-length to 1-9999 and compare it in base 10, allow custom types with digits and hyphens, treat U+FEFF and other invisible spaces as whitespace in the scope and description, catch capitalised words followed by punctuation, test that no title line becomes a workflow command (::error included), and cancel superseded runs in the documented caller. Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniqueg
added a commit
to uniqueg/dotgithub-release-dryrun
that referenced
this pull request
Oct 28, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds the composite action
actions/pr-title, which checks pull request titles against the org convention with a plain script (no token, no third-party action):<type>[(<scope>)][!]: <description>with an allowed type (inputtypes, whitespace- or newline-separated; defaultbuild chore ci docs feat fix perf refactor revert style test);max-length(default 50) characters in total, counted as Unicode code points;Add); acronyms and names with more capitals or digits (API,OpenAPI,S3,C++) pass. This keeps the lowercase rule of the current cloud-components check without rejecting names seen in FOCA's history;env:only and never starts a log line, so it can't inject workflow commands.Also:
tests/pr-title/test.sh: good and bad titles, asserting the exit status and the reported rule, invalid inputs, several rules at once, injection attempts.testjob (Test) runs those tests and the action itself, once with a customtypeslist (a type that is not a default, so it passes only if the input arrives) and once withmax-length(fails only if the input arrives); the gate now needstest.actions/pr-title/README.mdwith the caller workflow from the issue, the root README, and CONTRIBUTING (the type list is closed, the description starts lowercase, thePR titlecheck enforces it).The workflow template moved to #17: it has to pin the action by a release commit, which only exists after the first release.
Closes #13
Verification
bash tests/pr-title/test.sh: all tests pass; a mutation check (reverting the multi-line types and acronym fixes) made 5 tests fail.pre-commit run --all-files(incl. shellcheck, check-github-actions onaction.yml, markdownlint) and the manualgitleaks-all: passed.actionlintwith shellcheck: no findings.Lint,Test,CI passed); the log shows the good title passing with the customtypesand the bad one failing onmax-length(10).Declined review findings
(#N)squash suffix: the issue and CONTRIBUTING set 50 characters for the title; the README says the suffix doesn't count.title(the PR's own title) in CI: that would turn CI into a title check for this repo, which doesn't re-run when a title is edited; the per-repopr-title.ymlis the place for it.Docker image tags) still fails: it can't be told from a capitalised verb; documented.::line other than the script's own annotations fails a test; asserting full sets would duplicate the messages without catching more.🤖 Generated with Claude Code