From fa9ad59f8796e0c7e9463f47beda7dfb81ad69a9 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 22 Jul 2024 13:18:31 +0200 Subject: [PATCH 1/3] lint: Use $CI_RETRY_EXE when building ./ci/lint_imagefile Previous code was confusing and brittle. For example, the full import "source ./ci/test/00_setup_env.sh" and $PATH overwrite was not needed. Fix it by simply copying the exe to /ci_retry and use that in $CI_RETRY_EXE. This is also a fix, because previously ci/lint_imagefile did use an empty $CI_RETRY_EXE. --- ci/lint/04_install.sh | 4 ++-- ci/lint_imagefile | 1 + ci/lint_run_all.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ci/lint/04_install.sh b/ci/lint/04_install.sh index 550c7b8c92..f02b150c98 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/04_install.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash # -# Copyright (c) 2018-2022 The Bitcoin Core developers +# Copyright (c) 2018-present The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. export LC_ALL=C -export PATH=$PWD/ci/retry:$PATH +export CI_RETRY_EXE="/ci_retry --" ${CI_RETRY_EXE} apt-get update # Lint dependencies: diff --git a/ci/lint_imagefile b/ci/lint_imagefile index d32b35b19d..9adc256a62 100644 --- a/ci/lint_imagefile +++ b/ci/lint_imagefile @@ -9,6 +9,7 @@ FROM debian:bookworm ENV DEBIAN_FRONTEND=noninteractive ENV LC_ALL=C.UTF-8 +COPY ./ci/retry/retry /ci_retry COPY ./.python-version /.python-version COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh COPY ./ci/lint/04_install.sh /install.sh diff --git a/ci/lint_run_all.sh b/ci/lint_run_all.sh index b56ee0d303..fe02016c29 100755 --- a/ci/lint_run_all.sh +++ b/ci/lint_run_all.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash # -# Copyright (c) 2019-2020 The Bitcoin Core developers +# Copyright (c) 2019-present The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. export LC_ALL=C.UTF-8 -set -o errexit; source ./ci/test/00_setup_env.sh +cp "./ci/retry/retry" "/ci_retry" set -o errexit; source ./ci/lint/04_install.sh set -o errexit ./ci/lint/06_script.sh From fa0f859885ee2c39c2d1cc704797c2461f3c473e Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 22 Jul 2024 13:23:48 +0200 Subject: [PATCH 2/3] doc: Clarify intent of ./ci/lint_run_all.sh --- ci/lint_run_all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/lint_run_all.sh b/ci/lint_run_all.sh index fe02016c29..452be67f1b 100755 --- a/ci/lint_run_all.sh +++ b/ci/lint_run_all.sh @@ -6,6 +6,8 @@ export LC_ALL=C.UTF-8 +# Only used in .cirrus.yml. Refer to test/lint/README.md on how to run locally. + cp "./ci/retry/retry" "/ci_retry" set -o errexit; source ./ci/lint/04_install.sh set -o errexit From fa8d73e86e1c11cdfe8154ab84edc1948283454b Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 22 Jul 2024 13:39:20 +0200 Subject: [PATCH 3/3] lint: Use consistent out-of-tree build for python and test_runner This mirrors the build by ./ci/lint_imagefile, which is done out-of-tree in "/". Otherwise, there could be errors due to a dirty tree. --- ci/lint/04_install.sh | 8 ++++++-- ci/lint_run_all.sh | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/lint/04_install.sh b/ci/lint/04_install.sh index f02b150c98..7a01482025 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/04_install.sh @@ -8,6 +8,8 @@ export LC_ALL=C export CI_RETRY_EXE="/ci_retry --" +pushd "/" + ${CI_RETRY_EXE} apt-get update # Lint dependencies: # - automake pkg-config libtool (for lint_includes_build_config) @@ -28,7 +30,7 @@ if [ ! -d "${PYTHON_PATH}/bin" ]; then libbz2-dev libreadline-dev libsqlite3-dev curl llvm \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \ clang - env CC=clang python-build "$(cat "./.python-version")" "${PYTHON_PATH}" + env CC=clang python-build "$(cat "/.python-version")" "${PYTHON_PATH}" fi export PATH="${PYTHON_PATH}/bin:${PATH}" command -v python3 @@ -38,7 +40,7 @@ export LINT_RUNNER_PATH="/lint_test_runner" if [ ! -d "${LINT_RUNNER_PATH}" ]; then ${CI_RETRY_EXE} apt-get install -y cargo ( - cd ./test/lint/test_runner || exit 1 + cd "/test/lint/test_runner" || exit 1 cargo build mkdir -p "${LINT_RUNNER_PATH}" mv target/debug/test_runner "${LINT_RUNNER_PATH}" @@ -62,3 +64,5 @@ MLC_VERSION=v0.18.0 MLC_BIN=mlc-x86_64-linux curl -sL "https://github.com/becheran/mlc/releases/download/${MLC_VERSION}/${MLC_BIN}" -o "/usr/bin/mlc" chmod +x /usr/bin/mlc + +popd || exit diff --git a/ci/lint_run_all.sh b/ci/lint_run_all.sh index 452be67f1b..c57261d21a 100755 --- a/ci/lint_run_all.sh +++ b/ci/lint_run_all.sh @@ -9,6 +9,9 @@ export LC_ALL=C.UTF-8 # Only used in .cirrus.yml. Refer to test/lint/README.md on how to run locally. cp "./ci/retry/retry" "/ci_retry" +cp "./.python-version" "/.python-version" +mkdir --parents "/test/lint" +cp --recursive "./test/lint/test_runner" "/test/lint/" set -o errexit; source ./ci/lint/04_install.sh set -o errexit ./ci/lint/06_script.sh