Files
bitcoin/.github/ci-test-each-commit-exec.py
merge-script c8c9c1e617 Merge bitcoin/bitcoin#34383: ci: remove commit count limit from test-each-commit and fail fast
eb510f8678 ci: fail fast in test-each-commit script (Lőrinc)
04c4d71008 ci: remove commit count limit from `test-each-commit` (Lőrinc)

Pull request description:

  ### Problem

  `test-each-commit` currently tests only a limited number of ancestor commits in a PR, so failures introduced deeper in the commit stack might be missed.

  ### Fix

  Remove the max-count limit so `test-each-commit` runs the full build + unit + functional test flow on every non-head PR commit, while keeping the PR tip excluded because it is already covered by the normal CI jobs.
  It will also stop after the first failure to surface the root cause sooner and keep logs readable when testing ancestor commits.

  ### Examples
  * Example failure 10 commits deep: https://github.com/l0rinc/bitcoin/actions/runs/21390976651/job/61577575033?pr=105 in https://github.com/l0rinc/bitcoin/pull/105
  * Example pass with >7 dummy commits: https://github.com/l0rinc/bitcoin/actions/runs/21392557521/job/61595159841?pr=106 in https://github.com/l0rinc/bitcoin/pull/106

  ---------

  Note: this PR has gone through a few iterations, the latest one just extends the existing job.

ACKs for top commit:
  maflcko:
    lgtm ACK eb510f8678 🕓
  hebasto:
    re-ACK eb510f8678.
  willcl-ark:
    ACK eb510f8678

Tree-SHA512: 5aadafd32daad610ce882277802c390642dc34f7d5bfa71d4b503ee007942d1ebafce2a3430ea5fd2af6673c83f9aee42450043be4722d7c02407d90920f8bce
2026-02-17 10:03:37 +00:00

72 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
import subprocess
import sys
import shlex
def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
kwargs.setdefault("check", True)
try:
return subprocess.run(cmd, **kwargs)
except Exception as e:
sys.exit(str(e))
def main():
print("Running tests on commit ...")
run(["git", "log", "-1"])
num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout)
build_dir = "ci_build"
run([
"cmake",
"-B",
build_dir,
"-Werror=dev",
# Use clang++, because it is a bit faster and uses less memory than g++
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
# Use mold, because it is faster than the default linker
"-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold",
# Use Debug build type for more debug checks, but enable optimizations
"-DAPPEND_CXXFLAGS='-O3 -g2'",
"-DAPPEND_CFLAGS='-O3 -g2'",
"-DCMAKE_BUILD_TYPE=Debug",
"-DCMAKE_COMPILE_WARNING_AS_ERROR=ON",
"--preset=dev-mode",
# Tolerate unused member functions in intermediate commits in a pull request
"-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
])
if run(["cmake", "--build", build_dir, "-j", str(num_procs)], check=False).returncode != 0:
print("Build failure. Verbose build follows.")
run(["cmake", "--build", build_dir, "-j1", "--verbose"])
run([
"ctest",
"--output-on-failure",
"--stop-on-failure",
"--test-dir",
build_dir,
"-j",
str(num_procs),
])
run([
sys.executable,
f"./{build_dir}/test/functional/test_runner.py",
"-j",
str(num_procs * 2),
"--failfast",
"--combinedlogslen=99999999",
])
if __name__ == "__main__":
main()