Repository navigation
Conversation
CI accepted malformed Changelog- lines which changelog.py ignored. Match the parser's accepted prefixes so CI and the release notes agree. Changelog-None Co-authored-by: Cursor <cursoragent@cursor.com>
A non-strict xfail also passes when the test unexpectedly succeeds. Reject added pytest.mark.xfail decorators without strict=True. Co-authored-by: Cursor <cursoragent@cursor.com>
A default label hides the compiler warning when an enum gains a value. Reject added defaults in switches whose cases are enum values. Co-authored-by: Cursor <cursoragent@cursor.com>
Add make check-commits to build each commit and run check-source, unit tests and touched integration tests. check-commits-full runs all integration tests instead. Co-authored-by: Cursor <cursoragent@cursor.com>
Add a workflow which maintainers can enable with a repository variable, a PR label or workflow_dispatch. It enables Rust only when the PR touches Rust inputs. Co-authored-by: Cursor <cursoragent@cursor.com>
Comments should describe the code a reader can see. Reject added comments which narrate the change, describe removed code, cite a ticket or review, or point to a line number. Co-authored-by: Cursor <cursoragent@cursor.com>
Limit comments inside code to 4 lines and comments at the left margin to 8. BOLT quotes and tutorial comments are exempt. Co-authored-by: Cursor <cursoragent@cursor.com>
Check each new commit for wrapped text, short paragraphs and a blank line after the subject. Reject markdown headings and references to a PR, its review or another commit by relative position. Co-authored-by: Cursor <cursoragent@cursor.com>
Reject a new non-static function when no tracked C file calls it. Calls from tests and later commits in the branch count; generated wire helpers are exempt. Co-authored-by: Cursor <cursoragent@cursor.com>
An object allocated only to be handed over with take() should have no other owner. Reject added take() calls which allocate from tmpctx or pass a non-NULL parent to tal or towire helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
Require commit subjects to use the "subsystem: intent" form from the style guide. Preserve exceptions for fixups, releases and reverts. Co-authored-by: Cursor <cursoragent@cursor.com>
The prefix allowlist rejects valid subsystems and requires constant maintenance. check-source now checks subject shape without an allowlist. Co-authored-by: Cursor <cursoragent@cursor.com>
cb240d9 to
fe1c03b
Compare
| continue | ||
| fi | ||
|
|
||
| git checkout -q --detach "$sha" || exit 1 |
There was a problem hiding this comment.
check-commits.sh doesnt update submodules on checkout
| echo "[$n/$total] $(git log -1 --format='%h %s' "$sha")" | ||
|
|
||
| config=$(git hash-object config.vars 2> /dev/null || echo unconfigured) | ||
| key="$(git rev-parse "$sha^{tree}") $(git rev-parse -q --verify "$sha^^{tree}" || echo root) $pytest_mode $config" |
There was a problem hiding this comment.
the check-commits cache key ignores the commit message
| @@ -0,0 +1,99 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
check-xfail-strict.sh can be replaced by one config line? add xfail_strict = true to tests/pytest.ini
| for case in CASE.finditer(code, body[0], body[1]): | ||
| label = case.group(1) | ||
| if innermost(bodies, case.start()) != body: | ||
| continue |
There was a problem hiding this comment.
A switch is flagged as soon as any case label is an enumerator. On master it flags lightningd/peer_htlcs.c at line 2864 (3 of +- 25 onion_wire values) and wire/peer_wire.c at line 74 (is_oversized_gossip_msg, 3 of +-40 peer_wire values)
|
|
||
| # Only lines added since BASE_REF are checked (doc/Makefile sets the | ||
| # default): see tools/added-lines.sh. | ||
| check-xfail-strict: |
There was a problem hiding this comment.
the default BASE_REF=master gives false positives with a stale local master? maybe lets use BASE_REF ?= origin/master
There was a problem hiding this comment.
You can have the same staleness issue with either local master or origin/master. Also, not everyone names their remote origin, and origin is usually the contributor’s fork rather than the upstream ElementsProject/lightning repository.
| header = 0 | ||
| split($3, range, ",") | ||
| line = substr(range[1], 2) + 0 | ||
| next |
There was a problem hiding this comment.
??? maybe a softer limit, or a warning instead of a failure, may fit better?
There was a problem hiding this comment.
I'm not sure what you're referring to here?
| SUBJECT = re.compile(r'((fixup|squash|amend)! )*(\S+ ){0,2}\S+: \S|v\d+\.\d+\S*$|Revert "') | ||
| UNSEEN = re.compile(r'\bthis (pr|mr|pull request)\b|\breview(er)? (comments?|feedback)\b' | ||
| r'|\bper review\b|\bas (requested|discussed)\b', re.I) | ||
| BY_POSITION = re.compile(r'\b(previous|last|earlier|prior|preceding|parent) (commit|patch)(es|s)?\b', re.I) |
There was a problem hiding this comment.
so the the commit message rules reject wording maintainers currently accept?
There was a problem hiding this comment.
Are you referring to the by position rule? I think as maintainers, it's hard to pick up on subtleties like this every time on review and I'm personally unlikely to send back a PR if the only change requested in a commit message change which mentions the previous commit.
Ideally commits should stand alone and someone reading the commit should be able to understand what is going on without traversing the commits in a PR. PRs are ephemeral because once they are merged into main it's hard to tell which commits were a part of which PR.
Also, can we REALLY trust github to be around forever? 👀
I added this rule because more and more I find myself and see others writing more and more commit messages using AI, which is totally fine, but this way the LLMs (and also humans) can hopefully write better commit messages.
Motivation
More code is being written with coding agents, and agents infer conventions
from the code already in the repository. Review feedback which exists only
in documentation or PR discussions is easy to miss and has to be enforced
repeatedly by humans.
This turns a set of recurring CLN review comments into deterministic checks.
The rules apply to all contributors, but are designed to give agents useful
feedback while they build and test their changes.
Existing code is grandfathered: source checks apply only to lines or
definitions added by the branch.
Source checks
This adds checks for:
pytest.mark.xfailwithoutstrict=True;default:added to a switch over an enum;review, or point to a line number;
take()of objects allocated fromtmpctxor another non-NULL parent.BOLT quotes, tutorial comments and generated wire helpers have the necessary
exceptions.
Commit checks
Commit messages are checked for:
subsystem: intentform;The old commitlint prefix allowlist is removed because it rejected valid CLN
subsystems and needed updating for every new plugin or directory.
Per-commit verification
make check-commitschecks every commit in a branch by running:make check-source;make check-commits-fullruns the complete integration suite on everycommit.
An opt-in GitHub workflow provides the same per-commit verification for a PR.
Maintainers can enable it with the
per-commit-checkslabel, thePER_COMMIT_CHECKSrepository variable orworkflow_dispatch. Rust isdisabled when the PR does not touch Rust inputs.
Changelog validation
The changelog CI check now accepts only entries which
changelog.pywillactually collect, preventing malformed entries from passing CI and then
disappearing from the release notes.
Changelog-None