Merge bitcoin/bitcoin#33776: ci: Lint follow-ups

fae3618fd6 ci: Annotate all check runs with the pull request number (MarcoFalke)
faf05d637d ci: Retry lint image building once after failure (MarcoFalke)
fac4f6de28 ci: Rewrite lint task Bash snippet to Python (MarcoFalke)
fa0d37a579 ci: Rewrite Bash to check inputs to Python (MarcoFalke)

Pull request description:

  This contains a few follow-ups to https://github.com/bitcoin/bitcoin/pull/33744:

  * Rewrite the actions Bash snippet to Python. I've confirmed it still works in https://github.com/maflcko/bitcoin-core-with-ci/actions/runs/19067932430 (scroll down).
  * Add a lint-build retry to avoid issues such as https://github.com/bitcoin/bitcoin/issues/33640 for the lint task as well.
  * Finally, run the `debug_pull_request_number_str` annotation on all checks, to ensure they are present even when GitHub deletes annotations on a re-run. For example, the initial attempt https://github.com/bitcoin/bitcoin/actions/runs/19041534107/attempts/1?pr=33772 has the annotations, and the lint re-run has them removed: https://github.com/bitcoin/bitcoin/actions/runs/19041534107?pr=33772

ACKs for top commit:
  m3dwards:
    ACK fae3618fd6
  willcl-ark:
    ACK fae3618fd6

Tree-SHA512: 6db147ccee622b7a640703f7e916ea662a8e42978f633046f22f8540017196250ef7771b28cd6e502368f1f3fe52b7524de0a3443f25c9659f524b4c9286ad0d
This commit is contained in:
merge-script committed 2025-11-17 12:35:17 +00:00
commit c03081fdb4
2 files changed
+57 -18

No files matched your search

+3 -8
View File
@@ -8,16 +8,11 @@ runs:
using: 'composite' using: 'composite'
steps: steps:
- name: Check inputs - name: Check inputs
shell: bash shell: python
run: | run: |
# We expect only gha or cirrus as inputs to cache-provider # We expect only gha or cirrus as inputs to cache-provider
case "${{ inputs.cache-provider }}" in if "${{ inputs.cache-provider }}" not in ("gha", "cirrus"):
gha|cirrus) print("::warning title=Unknown input to configure docker action::Provided value was ${{ inputs.cache-provider }}")
;;
*)
echo "::warning title=Unknown input to configure docker action::Provided value was ${{ inputs.cache-provider }}"
;;
esac
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
+54 -10
View File
@@ -35,10 +35,12 @@ jobs:
outputs: outputs:
provider: ${{ steps.runners.outputs.provider }} provider: ${{ steps.runners.outputs.provider }}
steps: steps:
- name: Annotate with pull request number - &ANNOTATION_PR_NUMBER
name: Annotate with pull request number
# This annotation is machine-readable and can be used to assign a check # This annotation is machine-readable and can be used to assign a check
# run to its corresponding pull request. Running in one check run is # run to its corresponding pull request. Running in all check runs is
# sufficient for each check suite. # required, because check re-runs discard the annotations of other
# tasks in the test suite.
run: | run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "::notice title=debug_pull_request_number_str::${{ github.event.number }}" echo "::notice title=debug_pull_request_number_str::${{ github.event.number }}"
@@ -63,6 +65,7 @@ jobs:
steps: steps:
- name: Determine fetch depth - name: Determine fetch depth
run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV" run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV"
- *ANNOTATION_PR_NUMBER
- uses: actions/checkout@v5 - uses: actions/checkout@v5
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
@@ -141,6 +144,8 @@ jobs:
BASE_ROOT_DIR: ${{ github.workspace }}/repo_archive BASE_ROOT_DIR: ${{ github.workspace }}/repo_archive
steps: steps:
- *ANNOTATION_PR_NUMBER
- &CHECKOUT - &CHECKOUT
name: Checkout name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v5
@@ -220,6 +225,8 @@ jobs:
job-name: 'Windows native, fuzz, VS 2022' job-name: 'Windows native, fuzz, VS 2022'
steps: steps:
- *ANNOTATION_PR_NUMBER
- *CHECKOUT - *CHECKOUT
- &SET_UP_VS - &SET_UP_VS
@@ -347,6 +354,8 @@ jobs:
DANGER_CI_ON_HOST_FOLDERS: 1 DANGER_CI_ON_HOST_FOLDERS: 1
steps: steps:
- *ANNOTATION_PR_NUMBER
- *CHECKOUT - *CHECKOUT
- name: Configure environment - name: Configure environment
@@ -387,6 +396,8 @@ jobs:
TEST_RUNNER_TIMEOUT_FACTOR: 40 TEST_RUNNER_TIMEOUT_FACTOR: 40
steps: steps:
- *ANNOTATION_PR_NUMBER
- *CHECKOUT - *CHECKOUT
- name: Download built executables - name: Download built executables
@@ -553,6 +564,8 @@ jobs:
file-env: './ci/test/00_setup_env_native_msan.sh' file-env: './ci/test/00_setup_env_native_msan.sh'
steps: steps:
- *ANNOTATION_PR_NUMBER
- *CHECKOUT - *CHECKOUT
- name: Configure environment - name: Configure environment
@@ -593,6 +606,8 @@ jobs:
env: env:
CONTAINER_NAME: "bitcoin-linter" CONTAINER_NAME: "bitcoin-linter"
steps: steps:
- *ANNOTATION_PR_NUMBER
- name: Checkout - name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v5
with: with:
@@ -605,11 +620,40 @@ jobs:
cache-provider: ${{ needs.runners.outputs.provider }} cache-provider: ${{ needs.runners.outputs.provider }}
- name: CI script - name: CI script
shell: python
run: | run: |
set -o xtrace import os, shlex, subprocess, sys, time
docker buildx build -t "$CONTAINER_NAME" $DOCKER_BUILD_CACHE_ARG --file "./ci/lint_imagefile" .
CIRRUS_PR_FLAG="" def run(cmd, **kwargs):
if [ "${{ github.event_name }}" = "pull_request" ]; then print("+ " + shlex.join(cmd), flush=True)
CIRRUS_PR_FLAG="-e CIRRUS_PR=1" kwargs.setdefault("check", True)
fi try:
docker run --rm $CIRRUS_PR_FLAG -v "$(pwd)":/bitcoin "$CONTAINER_NAME" 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,
])