ci: Add run_tests step to ci-windows.py
What changed, and why it matters
This commit is a routine cleanup of Bitcoin Core's Windows CI (continuous integration) script. It moves the commands that run tests from the GitHub Actions YAML file into a shared Python helper, and changes where temporary test files are stored so the script can be run locally more easily. There is no indication this affects the security of the Bitcoin software itself or its users.
No security action required. This is a CI infrastructure refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors .github/ci-windows.py and .github/workflows/ci.yml. It adds a run_tests() step to the Python CI helper, consolidating ctest execution, functional test execution, and fuzz test execution that were previously inline shell steps in the GitHub Actions workflow. It also changes the fuzz qa-assets clone directory and the functional test tmpdir prefix from RUNNER_TEMP to the current working directory (os.getcwd()), which is described as making local execution easier. No changes are made to consensus, networking, wallet, or RPC code.
Changed components
.github/ci-windows.py.github/workflows/ci.ymlInspect captured patch +65 / −28
diff --git a/.github/ci-windows.py b/.github/ci-windows.py
index d797814d..693a0154 100755
--- a/.github/ci-windows.py
+++ b/.github/ci-windows.py
@@ -73,7 +73,7 @@ def prepare_tests(ci_type):
if ci_type == "standard":
run([sys.executable, "-m", "pip", "install", "pyzmq"])
elif ci_type == "fuzz":
- repo_dir = os.path.join(os.environ["RUNNER_TEMP"], "qa-assets")
+ repo_dir = os.path.join(os.getcwd(), "qa-assets")
clone_cmd = [
"git",
"clone",
@@ -86,6 +86,64 @@ def prepare_tests(ci_type):
run(["git", "-C", repo_dir, "log", "-1"])
+def run_tests(ci_type):
+ build_dir = "build"
+ num_procs = str(os.process_cpu_count())
+ release_bin = os.path.join(os.getcwd(), build_dir, "bin", "Release")
+
+ if ci_type == "standard":
+ test_envs = {
+ "BITCOIN_BIN": "bitcoin.exe",
+ "BITCOIND": "bitcoind.exe",
+ "BITCOINCLI": "bitcoin-cli.exe",
+ "BITCOIN_BENCH": "bench_bitcoin.exe",
+ "BITCOINTX": "bitcoin-tx.exe",
+ "BITCOINUTIL": "bitcoin-util.exe",
+ "BITCOINWALLET": "bitcoin-wallet.exe",
+ "BITCOINCHAINSTATE": "bitcoin-chainstate.exe",
+ }
+ for var, exe in test_envs.items():
+ os.environ[var] = os.path.join(release_bin, exe)
+
+ ctest_cmd = [
+ "ctest",
+ "--test-dir",
+ build_dir,
+ "--output-on-failure",
+ "--stop-on-failure",
+ "-j",
+ num_procs,
+ "--build-config",
+ "Release",
+ ]
+ run(ctest_cmd)
+
+ test_cmd = [
+ sys.executable,
+ os.path.join(build_dir, "test", "functional", "test_runner.py"),
+ "--jobs",
+ num_procs,
+ "--quiet",
+ f"--tmpdirprefix={os.getcwd()}",
+ "--combinedlogslen=99999999",
+ *shlex.split(os.environ.get("TEST_RUNNER_EXTRA", "").strip()),
+ ]
+ run(test_cmd)
+
+ elif ci_type == "fuzz":
+ os.environ["BITCOINFUZZ"] = os.path.join(release_bin, "fuzz.exe")
+ fuzz_cmd = [
+ sys.executable,
+ os.path.join(build_dir, "test", "fuzz", "test_runner.py"),
+ "--par",
+ num_procs,
+ "--loglevel",
+ "DEBUG",
+ os.path.join(os.getcwd(), "qa-assets", "fuzz_corpora"),
+ ]
+ run(fuzz_cmd)
+
+
def main():
parser = argparse.ArgumentParser(description="Utility to run Windows CI steps.")
parser.add_argument("ci_type", choices=GENERATE_OPTIONS, help="CI type to run.")
@@ -93,6 +151,7 @@ def main():
"generate",
"build",
"prepare_tests",
+ "run_tests",
]
parser.add_argument("step", choices=steps, help="CI step to perform.")
args = parser.parse_args()
@@ -103,6 +162,8 @@ def main():
build()
elif args.step == "prepare_tests":
prepare_tests(args.ci_type)
+ elif args.step == "run_tests":
+ run_tests(args.ci_type)
if __name__ == "__main__":
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a088021e..d09433fc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -304,39 +304,15 @@ jobs:
& mt.exe -nologo -inputresource:$_.FullName -validate_manifest
}
- - name: Run test suite
- if: matrix.job-type == 'standard'
- working-directory: build
- run: |
- ctest --output-on-failure --stop-on-failure -j $NUMBER_OF_PROCESSORS -C Release
-
- name: Prepare tests
run: |
py -3 .github/ci-windows.py ${{ matrix.job-type }} prepare_tests
- - name: Run functional tests
- if: matrix.job-type == 'standard'
- working-directory: build
- env:
- BITCOIN_BIN: '${{ github.workspace }}\build\bin\Release\bitcoin.exe'
- BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe'
- BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe'
- BITCOIN_BENCH: '${{ github.workspace }}\build\bin\Release\bench_bitcoin.exe'
- BITCOINTX: '${{ github.workspace }}\build\bin\Release\bitcoin-tx.exe'
- BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
- BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
- BITCOINCHAINSTATE: '${{ github.workspace }}\build\bin\Release\bitcoin-chainstate.exe'
- TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
- run: |
- py -3 test/functional/test_runner.py --jobs $NUMBER_OF_PROCESSORS --quiet --tmpdirprefix="${RUNNER_TEMP}" --combinedlogslen=99999999 --timeout-factor=${TEST_RUNNER_TIMEOUT_FACTOR} ${TEST_RUNNER_EXTRA}
-
- - name: Run fuzz tests
- if: matrix.job-type == 'fuzz'
- working-directory: build
+ - name: Run tests
env:
- BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
+ TEST_RUNNER_EXTRA: "--timeout-factor=${{ env.TEST_RUNNER_TIMEOUT_FACTOR }} ${{ case(github.event_name == 'pull_request', '', '--extended') }}"
run: |
- py -3 test/fuzz/test_runner.py --par $NUMBER_OF_PROCESSORS --loglevel DEBUG "${RUNNER_TEMP}/qa-assets/fuzz_corpora"
+ py -3 .github/ci-windows.py ${{ matrix.job-type }} run_tests
record-frozen-commit:
# Record frozen commit, so that the native tests on cross-builds can run on
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.