Repository navigation
Agent friendly checks: make review conventions mechanically checkable #9748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c27e34a
9ba599e
4d06ae1
e2206c9
0bdd814
56eb800
7c61ef5
8c02b25
039a62a
d745cd1
7788f6d
fe1c03b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| name: Per-commit checks | ||
| # Builds and tests every commit of a PR except the last, which the main CI | ||
| # workflow already covers. | ||
| # | ||
| # Off by default. A maintainer turns it on for all PRs by setting the | ||
| # repository variable PER_COMMIT_CHECKS to "true", for one PR by adding the | ||
| # "per-commit-checks" label, or runs it by hand on a branch. | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, labeled] | ||
| workflow_dispatch: | ||
| inputs: | ||
| base: | ||
| description: Branch the commits are compared against | ||
| default: master | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| # Reduce size, as in the main CI workflow | ||
| RUST_PROFILE: small | ||
| SLOW_MACHINE: 1 | ||
| SCCACHE_GHA_ENABLED: "true" | ||
| BASE_REF: ${{ github.base_ref || inputs.base }} | ||
| PASSED_KEY: check-commits-${{ github.event.pull_request.number || github.ref_name }} | ||
|
|
||
| jobs: | ||
| per-commit: | ||
| name: Build and test each commit | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 120 | ||
| if: >- | ||
| github.event_name == 'workflow_dispatch' || | ||
| (github.event.action == 'labeled' && | ||
| github.event.label.name == 'per-commit-checks') || | ||
| (github.event.action != 'labeled' && | ||
| (vars.PER_COMMIT_CHECKS == 'true' || | ||
| contains(github.event.pull_request.labels.*.name, 'per-commit-checks'))) | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v7 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python 3.10 | ||
| uses: actions/setup-python@v7 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v10.3.2 | ||
|
|
||
| - uses: actions/cache@v6 | ||
| with: | ||
| path: ~/ci-cache | ||
| key: apt-${{ runner.os }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| bash -x .github/scripts/setup.sh | ||
| # check-source checks BOLT quotes | ||
| git clone https://github.com/lightning/bolts.git ../bolts | ||
|
|
||
| - name: Setup sccache | ||
| uses: mozilla-actions/sccache-action@v0.0.11 | ||
|
|
||
| # Commits that passed on an earlier push of this PR are not rechecked. | ||
| - name: Restore list of commits that passed | ||
| uses: actions/cache/restore@v6 | ||
| with: | ||
| path: ~/check-commits | ||
| key: ${{ env.PASSED_KEY }}-${{ github.run_id }}-${{ github.run_attempt }} | ||
| restore-keys: | | ||
| ${{ env.PASSED_KEY }}- | ||
|
|
||
| # The Rust build is the slow part, and the main CI workflow builds the | ||
| # last commit with it anyway. | ||
| - name: Configure | ||
| run: | | ||
| git fetch origin "$BASE_REF" | ||
| rust=--disable-rust | ||
| if ! git diff --quiet "origin/$BASE_REF...HEAD" -- '*.rs' '*Cargo.toml' Cargo.lock cln-grpc/ cln-rpc/ contrib/msggen/ doc/schemas/; then | ||
| rust=--enable-rust | ||
| fi | ||
| ./configure --enable-debugbuild --disable-valgrind "$rust" CC="sccache gcc" | ||
|
|
||
| - name: Check each commit | ||
| env: | ||
| COMPAT: 1 | ||
| RUSTC_WRAPPER: sccache | ||
| PYTEST_OPTS: --timeout=1800 | ||
| CHECK_COMMITS_SKIP_TIP: 1 | ||
| CHECK_COMMITS_LOGDIR: ${{ runner.temp }}/check-commits-logs | ||
| run: | | ||
| mkdir -p ~/check-commits | ||
| touch ~/check-commits/passed | ||
| export CHECK_COMMITS_CACHE=~/check-commits/passed | ||
| export GRPC_BREAKING_BASE_REF="origin/$BASE_REF" | ||
| # Use the base branch's script, so a PR branched before a change | ||
| # to it is checked the same way as every other PR. | ||
| script="$RUNNER_TEMP/check-commits.sh" | ||
| git show "origin/$BASE_REF:tools/check-commits.sh" > "$script" 2>/dev/null || cp tools/check-commits.sh "$script" | ||
| chmod +x "$script" | ||
| sg wireshark "uv run eatmydata $script origin/$BASE_REF" | ||
|
|
||
| - name: Save list of commits that passed | ||
| if: always() | ||
| uses: actions/cache/save@v6 | ||
| with: | ||
| path: ~/check-commits | ||
| key: ${{ env.PASSED_KEY }}-${{ github.run_id }}-${{ github.run_attempt }} | ||
|
|
||
| - name: Upload step logs | ||
| if: failure() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: check-commits-logs | ||
| path: ${{ runner.temp }}/check-commits-logs | ||
| if-no-files-found: ignore |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
| # Print "path:line" for every line the working tree adds since the merge | ||
| # base of BASE and HEAD, in files matching the pathspecs. A check built on | ||
| # this complains about new code only, not about what is already there. | ||
| # | ||
| # Usage: tools/added-lines.sh BASE [pathspec...] | ||
|
|
||
| set -o pipefail | ||
|
|
||
| base=${1:?usage: added-lines.sh BASE [pathspec...]} | ||
| shift | ||
|
|
||
| if ! mergebase=$(git merge-base "$base" HEAD 2> /dev/null); then | ||
| echo "added-lines: no merge base with '$base', so no lines are checked" >&2 | ||
| exit 0 | ||
| fi | ||
|
|
||
| # With -U0 a hunk is only removed and added lines; the +++ header is told | ||
| # apart from an added line by coming before the first hunk of its file. | ||
| git -c core.quotePath=false diff -U0 --no-color --no-ext-diff --no-prefix "$mergebase" -- "$@" | awk ' | ||
| /^diff --git / { header = 1; next } | ||
| header && /^\+\+\+ / { file = substr($0, 5); next } | ||
| /^@@ / { | ||
| header = 0 | ||
| split($3, range, ",") | ||
| line = substr(range[1], 2) + 0 | ||
| next | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ??? maybe a softer limit, or a warning instead of a failure, may fit better?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you're referring to here? |
||
| } | ||
| !header && /^\+/ { print file ":" line; line++ } | ||
| ' || exit 1 | ||
|
|
||
| # A file git does not know yet is new in every line. | ||
| git ls-files --others --exclude-standard -- "$@" | while IFS= read -r file; do | ||
| awk -v file="$file" '{ print file ":" NR }' "$file" | ||
| done | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default
BASE_REF=mastergives false positives with a stale localmaster? maybe lets useBASE_REF ?= origin/masterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.