Merge bitcoin/bitcoin#32767: ci: Allow running CI in worktrees

fa68dcb207 ci: Add missing errexit to lint CI install (MarcoFalke)
fa535a6de7 ci: Allow running CI in worktrees (MarcoFalke)
faf6a04597 ci: Clean UID/GID mismatch (MarcoFalke)

Pull request description:

  Fixes #30028 (modulo lint and tidy CI).

  The error on current master in a worktree is:

  ```
  $ git worktree add ./main origin/master && cd ./main
  $ MAKEJOBS="-j$(nproc)" FILE_ENV="./ci/test/00_setup_env_mac_cross.sh" ./ci/test_run_all.sh
  ...
  + git config --global ci.base-install-done true
  fatal: not a git repository: /root/b-c-ci/.git/worktrees/main
  ```

  So just use a plain file, instead of git. Also, enable pipefail while touching this bash script.

ACKs for top commit:
  willcl-ark:
    tACK fa68dcb207

Tree-SHA512: 0ce360a80883b4aa655fe8a99c38eb54a465b17c7cdb0a69a2d886ff78da32d6af996412ffc5b0db0322acafa9650619838573484de8243dc41594a04a6e17ec
This commit is contained in:
merge-script
2025-06-24 14:18:20 +01:00
6 changed files with 10 additions and 12 deletions

View File

@ -6,6 +6,8 @@
export LC_ALL=C export LC_ALL=C
set -o errexit -o pipefail -o xtrace
export CI_RETRY_EXE="/ci_retry --" export CI_RETRY_EXE="/ci_retry --"
pushd "/" pushd "/"

View File

@ -12,7 +12,7 @@ ENV LC_ALL=C.UTF-8
COPY ./ci/retry/retry /ci_retry COPY ./ci/retry/retry /ci_retry
COPY ./.python-version /.python-version COPY ./.python-version /.python-version
COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh
COPY ./ci/lint/04_install.sh /install.sh COPY ./ci/lint/01_install.sh /install.sh
RUN /install.sh && \ RUN /install.sh && \
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \ echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \

View File

@ -13,6 +13,6 @@ cp "./ci/retry/retry" "/ci_retry"
cp "./.python-version" "/.python-version" cp "./.python-version" "/.python-version"
mkdir --parents "/test/lint" mkdir --parents "/test/lint"
cp --recursive "./test/lint/test_runner" "/test/lint/" cp --recursive "./test/lint/test_runner" "/test/lint/"
set -o errexit; source ./ci/lint/04_install.sh set -o errexit; source ./ci/lint/01_install.sh
set -o errexit set -o errexit
./ci/lint/06_script.sh ./ci/lint/06_script.sh

View File

@ -6,11 +6,11 @@
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
set -ex set -o errexit -o pipefail -o xtrace
CFG_DONE="ci.base-install-done" # Use a global git setting to remember whether this script ran to avoid running it twice CFG_DONE="${BASE_ROOT_DIR}/ci.base-install-done" # Use a global setting to remember whether this script ran to avoid running it twice
if [ "$(git config --global ${CFG_DONE})" == "true" ]; then if [ "$( cat "${CFG_DONE}" || true )" == "done" ]; then
echo "Skip base install" echo "Skip base install"
exit 0 exit 0
fi fi
@ -105,4 +105,4 @@ if [ -n "$XCODE_VERSION" ] && [ ! -d "${DEPENDS_DIR}/SDKs/${OSX_SDK_BASENAME}" ]
tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH" tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH"
fi fi
git config --global ${CFG_DONE} "true" echo -n "done" > "${CFG_DONE}"

View File

@ -153,13 +153,9 @@ CI_EXEC () {
export -f CI_EXEC export -f CI_EXEC
# Normalize all folders to BASE_ROOT_DIR # Normalize all folders to BASE_ROOT_DIR
CI_EXEC rsync --archive --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/" CI_EXEC rsync --recursive --perms --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/"
CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh" CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh"
# Fixes permission issues when there is a container UID/GID mismatch with the owner
# of the git source code directory.
CI_EXEC git config --global --add safe.directory \"*\"
CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}" CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}"
CI_EXEC "${BASE_ROOT_DIR}/ci/test/03_test_script.sh" CI_EXEC "${BASE_ROOT_DIR}/ci/test/03_test_script.sh"

View File

@ -54,7 +54,7 @@ or `--help`:
| `py_lint` | [ruff](https://github.com/astral-sh/ruff) | `py_lint` | [ruff](https://github.com/astral-sh/ruff)
| markdown link check | [mlc](https://github.com/becheran/mlc) | markdown link check | [mlc](https://github.com/becheran/mlc)
In use versions and install instructions are available in the [CI setup](../../ci/lint/04_install.sh). In use versions and install instructions are available in the [CI setup](../../ci/lint/01_install.sh).
Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated. Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated.