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
51 changes: 41 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,48 @@ jobs:
echo "Base Ref: $BASE_REF"
echo "PR DESCRIPTION: $PR_DESCRIPTION"
if [ "$EVENT_NAME" = "pull_request" ]; then
if [[ "$PR_DESCRIPTION" != *"Changelog-None"* && \
-z "$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')" && \
"$(git rev-parse --abbrev-ref HEAD)" != "$BASE_REF" ]]; then
echo "::error::'Changelog' entry is missing in all commits, and 'Changelog-None' not specified in the PR description"
on_base=0
if [ "$(git rev-parse --abbrev-ref HEAD)" = "$BASE_REF" ]; then
on_base=1
fi
found=0
invalid=0
if ! commits=$(git rev-list "origin/${BASE_REF}..HEAD"); then
echo "::error::Cannot list commits origin/${BASE_REF}..HEAD"
exit 1
fi
# Same shape devtools/changelog.py keeps: class, colon, one space,
# then a nonempty entry. Changelog-None is the opt-out, in a
# commit or in the PR body. Any other Changelog- line is a typo
# which changelog.py would silently drop from the release notes.
valid='^[[:space:]]*Changelog-(Added|Changed|Deprecated|Fixed|Removed|Experimental): [^[:space:]]'
none='^[[:space:]]*Changelog-None([.[:space:]]*$|:)'
while IFS= read -r sha; do
[ -n "$sha" ] || continue
msg=$(git show -s --format=%B "$sha")
shopt -s nocasematch
while IFS= read -r line; do
if [[ "$line" =~ $valid ]] || [[ "$line" =~ $none ]]; then
found=1
Comment thread
sangbida marked this conversation as resolved.
Resolved
elif [[ "$line" =~ ^[[:space:]]*Changelog- ]]; then
echo "::error::Malformed Changelog line in ${sha}: ${line}"
invalid=1
fi
done <<< "$msg"
shopt -u nocasematch
done <<< "$commits"
if [ "$invalid" -eq 1 ]; then
exit 1
fi
if [[ "$PR_DESCRIPTION" == *"Changelog-None"* ]]; then
echo "Changelog found in PR description"
elif [ "$found" -eq 1 ]; then
echo "Changelog found in commit range origin/${BASE_REF}..HEAD"
elif [ "$on_base" -eq 1 ]; then
echo "HEAD is ${BASE_REF}; changelog check skipped"
else
if [[ "$PR_DESCRIPTION" == *"Changelog-None"* ]]; then
echo "Changelog found in PR description"
else
echo "Changelog found in Commit \"$(git log origin/$BASE_REF..HEAD --oneline --grep='Changelog-')\""
fi
echo "::error::'Changelog' entry is missing in all commits, and 'Changelog-None' not specified in the PR description"
exit 1
fi
else
echo "Not a PR event."
Expand Down Expand Up @@ -101,7 +132,7 @@ jobs:
VALGRIND: 0
PYTEST_OPTS: ${{ env.PYTEST_OPTS_BASE }}
run: |
uv run make -j $(nproc) check-source BASE_REF="origin/${{ github.base_ref }}" GRPC_BREAKING_BASE_REF="origin/${{ github.base_ref || 'master' }}" CARGO=false CC=devtools/cc-nobuild SUPPRESS_GENERATION=1
uv run make -j $(nproc) check-source BASE_REF="origin/${{ github.base_ref || 'master' }}" GRPC_BREAKING_BASE_REF="origin/${{ github.base_ref || 'master' }}" CARGO=false CC=devtools/cc-nobuild SUPPRESS_GENERATION=1
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/per-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
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
submodules: recursive

- 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
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ repos:
exclude: ccan|contrib|tests/fuzz/corpora
stages: [ manual ]

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.23.0
hooks:
- id: commitlint
stages: [ commit-msg ]

- repo: local
hooks:
# Reimplementation of `make check-amount-access` for pygrep.
Expand Down
32 changes: 31 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,41 @@ check-grpc-breaking:
echo "Checking gRPC protos against $$tag"; \
$(BUF) breaking cln-grpc/proto --against ".git#tag=$$tag,subdir=cln-grpc/proto"

# Only lines added since BASE_REF are checked (doc/Makefile sets the
# default): see tools/added-lines.sh.
check-switch-default:
@tools/check-switch-default.py $(BASE_REF)

check-comments:
@tools/check-comments.py $(BASE_REF)

check-unused-functions:
@tools/check-unused-functions.py $(BASE_REF)

check-take-parent:
@tools/check-take-parent.py $(BASE_REF)

check-tab-indent:
@tools/check-tab-indent.py $(BASE_REF)

# The message of each commit since BASE_REF.
check-commit-msgs:
@tools/check-commit-msgs.py $(BASE_REF)

# This should NOT compile things!
check-source: check-makefile check-whitespace check-spelling check-python-flake8 check-includes check-shellcheck check-setup_locale check-tmpctx check-discouraged-functions check-amount-access check-bad-sprintf check-wire-format check-source-bolt check-security check-msggen-grpc check-grpc-breaking
check-source: check-makefile check-whitespace check-spelling check-python-flake8 check-includes check-shellcheck check-setup_locale check-tmpctx check-discouraged-functions check-amount-access check-bad-sprintf check-wire-format check-source-bolt check-security check-msggen-grpc check-grpc-breaking check-switch-default check-comments check-unused-functions check-take-parent check-tab-indent check-commit-msgs

full-check: check check-source

# Build, check-source, unit tests and touched integration tests on each
# commit since BASE_REF: see tools/check-commits.sh.
check-commits:
@uv run tools/check-commits.sh $(BASE_REF)

# The same, with the whole integration suite on every commit.
check-commits-full:
@CHECK_COMMITS_PYTEST=all uv run tools/check-commits.sh $(BASE_REF)

# Simple target to be used on CI systems to check that all the derived
# files were checked in and updated. It depends on the generated
# targets, and checks if any of the tracked files changed. If they did
Expand Down
2 changes: 1 addition & 1 deletion cli/lightning-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ int main(int argc, char *argv[])
json_tok_full_len(result),
json_tok_full(resp, result));
break;
default:
case DEFAULT_FORMAT:
abort();
}
tal_free(ctx);
Expand Down
16 changes: 10 additions & 6 deletions closingd/test/run-closingd-negotiation.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,26 @@ u8 *test_wire_sync_read(const tal_t *ctx, int fd)
bool test_wire_sync_write(int fd, const void *msg TAKES)
{
if (fd == REQ_FD) {
switch (fromwire_peektype(msg)) {
switch ((enum closingd_wire)fromwire_peektype(msg)) {
case WIRE_CLOSINGD_RECEIVED_SIGNATURE: {
struct bitcoin_signature sig;
struct bitcoin_tx *tx;
assert(fromwire_closingd_received_signature(tmpctx, msg, &sig, &tx));
bitcoin_txid(tx, &saved_txid);
break;
goto handled;
}
case WIRE_CLOSINGD_COMPLETE:
completed++;
break;
goto handled;
case WIRE_CLOSINGD_NOTIFICATION:
break;
default:
goto handled;
case WIRE_CLOSINGD_INIT:
case WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY:
abort();
}
/* A u16 can hold values outside enum closingd_wire. */
abort();
handled:;
} else
assert(fd == HSM_FD);
tal_free_if_taken(msg);
Expand Down Expand Up @@ -202,7 +206,7 @@ u8 *test_peer_read(const tal_t *ctx, struct per_peer_state *pps)
case UPPER_BOUND:
fee = offset(high_remote ? first_remote : last_local, false);
break;
default:
case AGREE:
abort();
}
}
Expand Down
56 changes: 0 additions & 56 deletions commitlint.config.js

This file was deleted.

Loading
Loading