/ .github / ci-test-each-commit-exec.py
ci-test-each-commit-exec.py
 1  #!/usr/bin/env python3
 2  # Copyright (c) The Bitcoin Core developers
 3  # Distributed under the MIT software license, see the accompanying
 4  # file COPYING or https://opensource.org/license/mit/.
 5  
 6  import subprocess
 7  import sys
 8  import shlex
 9  
10  
11  def run(cmd, **kwargs):
12      print("+ " + shlex.join(cmd), flush=True)
13      try:
14          return subprocess.run(cmd, check=True, **kwargs)
15      except Exception as e:
16          sys.exit(e)
17  
18  
19  def main():
20      print("Running tests on commit ...")
21      run(["git", "log", "-1"])
22  
23      num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout)
24      build_dir = "ci_build"
25  
26      run([
27          "cmake",
28          "-B",
29          build_dir,
30          "-Werror=dev",
31          # Use clang++, because it is a bit faster and uses less memory than g++
32          "-DCMAKE_C_COMPILER=clang",
33          "-DCMAKE_CXX_COMPILER=clang++",
34          # Use mold, because it is faster than the default linker
35          "-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold",
36          # Use Debug build type for more debug checks, but enable optimizations
37          "-DAPPEND_CXXFLAGS='-O3 -g2'",
38          "-DAPPEND_CFLAGS='-O3 -g2'",
39          "-DCMAKE_BUILD_TYPE=Debug",
40          "-DWERROR=ON",
41          "--preset=dev-mode",
42          # Tolerate unused member functions in intermediate commits in a pull request
43          "-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
44      ])
45      run(["cmake", "--build", build_dir, "-j", str(num_procs)])
46      run([
47          "ctest",
48          "--output-on-failure",
49          "--stop-on-failure",
50          "--test-dir",
51          build_dir,
52          "-j",
53          str(num_procs),
54      ])
55      run([
56          sys.executable,
57          f"./{build_dir}/test/functional/test_runner.py",
58          "-j",
59          str(num_procs * 2),
60          "--combinedlogslen=99999999",
61      ])
62  
63  
64  if __name__ == "__main__":
65      main()