ci: Move lint exec snippet to stand-alone py file
What changed, and why it matters
This commit simply moves a chunk of Python code from inside a GitHub Actions workflow file into its own separate Python file. The code that runs is unchanged; only its location changed. There is no security issue here.
No action needed. This is a routine maintainability refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is a pure refactor of CI configuration. The inline Python script in .github/workflows/ci.yml is extracted to a new executable file .github/ci-lint-exec.py, and the workflow now calls that file. The logic, commands, environment variable handling, and Docker invocations are identical. No functional or security-relevant change is introduced.
Changed components
.github/workflows/ci.yml.github/ci-lint-exec.pyInspect captured patch +52 / −37
diff --git a/.github/ci-lint-exec.py b/.github/ci-lint-exec.py
new file mode 100755
index 00000000..b0f78983
--- /dev/null
+++ b/.github/ci-lint-exec.py
@@ -0,0 +1,51 @@
+#!/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 os
+import shlex
+import subprocess
+import sys
+import time
+
+
+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(e)
+
+
+def main():
+ CONTAINER_NAME = os.environ["CONTAINER_NAME"]
+
+ build_cmd = [
+ "docker", "buildx", "build",
+ f"--tag={CONTAINER_NAME}",
+ *shlex.split(os.getenv("DOCKER_BUILD_CACHE_ARG", "")),
+ "--file=./ci/lint_imagefile",
+ "."
+ ]
+
+ if run(build_cmd, check=False).returncode != 0:
+ print("Retry building image tag after failure")
+ time.sleep(3)
+ run(build_cmd)
+
+ CIRRUS_PR_FLAG = []
+ if os.environ.get("GITHUB_EVENT_NAME") == "pull_request":
+ CIRRUS_PR_FLAG = ["-e", "CIRRUS_PR=1"]
+
+ run([
+ "docker", "run", "--rm",
+ *CIRRUS_PR_FLAG,
+ f"--volume={os.getcwd()}:/bitcoin",
+ CONTAINER_NAME,
+ ])
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0265583b..343c20b3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -620,40 +620,4 @@ jobs:
cache-provider: ${{ needs.runners.outputs.provider }}
- name: CI script
- shell: python
- run: |
- import os, shlex, subprocess, sys, time
-
- 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(e)
-
- CONTAINER_NAME = os.environ["CONTAINER_NAME"]
-
- build_cmd = [
- "docker", "buildx", "build",
- f"--tag={CONTAINER_NAME}",
- *shlex.split(os.getenv("DOCKER_BUILD_CACHE_ARG", "")),
- "--file=./ci/lint_imagefile",
- "."
- ]
-
- if run(build_cmd, check=False).returncode != 0:
- print("Retry building image tag after failure")
- time.sleep(3)
- run(build_cmd)
-
- CIRRUS_PR_FLAG = []
- if '${{ github.event_name }}' == "pull_request":
- CIRRUS_PR_FLAG = ["-e", "CIRRUS_PR=1"]
-
- run([
- "docker", "run", "--rm",
- *CIRRUS_PR_FLAG,
- f"--volume={os.getcwd()}:/bitcoin",
- CONTAINER_NAME,
- ])
+ run: python .github/ci-lint-exec.py
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.