Skip to content

Commit 716d64c

Browse files
committed
partial Merge bitcoin#28083: ci: Use DOCKER_BUILDKIT for lint image
fa2f18a ci: Use DOCKER_BUILDKIT for lint image (MarcoFalke) Pull request description: Currently the lint docker/podman image has many issues: * It relies on an EOL debian version. * It relies on a debian version different from the one used in the CI lint task. * It relies on the legacy docker build command, which requires the user to make `cd ./ci/lint/` before the build step. * It doesn't use the `.python-version` file, but a hardcoded version. Fix all issues by using the recommended `DOCKER_BUILDKIT=1` to generate the image. Also: * Rename `/tmp/python` to `/python_build`. * Compress all `pip install` commands into one. * Bump `.python-version`. ACKs for top commit: jamesob: ACK bitcoin@fa2f18a Tree-SHA512: 804b384904ad753845667998841cc7825f4229933ca2c42af021384713486ec3cca80ba58612d37557fba7ee1921439dacca5e1236aac0557dd75bd9a2f1875d Dash adaptations: - ci/lint/04_install.sh: adopted upstream's single multi-line `pip3 install` invocation but kept Dash's pinned versions (codespell 2.2.1, flake8 5.0.4, mypy 0.981, pyzmq 24.0.1) and Dash's `# NOTE: BUMP ALSO contrib/containers/ci/ci-slim.Dockerfile` comment; upstream's version bumps come from a separate commit Dash has not backported and are out of scope here. - .python-version: left at Dash's 3.10.19 rather than taking upstream's 3.8.16->3.8.17 bump; Dash is already ahead of upstream on this file. - ci/lint/Dockerfile: Dash's copy differed from upstream (FROM python:3.10.19-bookworm instead of python:3.8-buster), but upstream deletes the file wholesale in favour of ci/lint_imagefile, so the Dash variant was removed too. - ci/lint_imagefile: taken verbatim from upstream, including `WORKDIR /bitcoin`; Dash's existing lint tooling (docker-entrypoint.sh safe.directory, test/lint/README.md mount path and `bitcoin-linter` tag) already uses /bitcoin, and upstream's commit does not rename it, so no rebranding was applied. Omitted (partial backport): - .cirrus.yml: Dash deleted .cirrus.yml from its tree (it uses GitHub Actions / GitLab CI, not Cirrus). The cherry-pick re-introduced upstream's whole file as a delete/modify conflict; resolved by keeping it deleted, so the python_cache folder change /tmp/python -> /python_build has no home in Dash.
1 parent abf223e commit 716d64c

5 files changed

Lines changed: 45 additions & 56 deletions

File tree

‎ci/lint/04_install.sh‎

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,32 @@ ${CI_RETRY_EXE} apt-get update
1313
# - gpg (used by verify-commits)
1414
${CI_RETRY_EXE} apt-get install -y curl xz-utils git gpg
1515

16-
if [ -z "${SKIP_PYTHON_INSTALL}" ]; then
17-
PYTHON_PATH=/tmp/python
18-
if [ ! -d "${PYTHON_PATH}/bin" ]; then
19-
(
20-
git clone https://github.com/pyenv/pyenv.git
21-
cd pyenv/plugins/python-build || exit 1
22-
./install.sh
23-
)
24-
# For dependencies see https://github.com/pyenv/pyenv/wiki#suggested-build-environment
25-
${CI_RETRY_EXE} apt-get install -y build-essential libssl-dev zlib1g-dev \
26-
libbz2-dev libreadline-dev libsqlite3-dev curl llvm \
27-
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
28-
clang
29-
env CC=clang python-build "$(cat "${BASE_ROOT_DIR}/.python-version")" "${PYTHON_PATH}"
30-
fi
31-
export PATH="${PYTHON_PATH}/bin:${PATH}"
32-
command -v python3
33-
python3 --version
16+
PYTHON_PATH="/python_build"
17+
if [ ! -d "${PYTHON_PATH}/bin" ]; then
18+
(
19+
git clone https://github.com/pyenv/pyenv.git
20+
cd pyenv/plugins/python-build || exit 1
21+
./install.sh
22+
)
23+
# For dependencies see https://github.com/pyenv/pyenv/wiki#suggested-build-environment
24+
${CI_RETRY_EXE} apt-get install -y build-essential libssl-dev zlib1g-dev \
25+
libbz2-dev libreadline-dev libsqlite3-dev curl llvm \
26+
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
27+
clang
28+
env CC=clang python-build "$(cat "./.python-version")" "${PYTHON_PATH}"
3429
fi
30+
export PATH="${PYTHON_PATH}/bin:${PATH}"
31+
command -v python3
32+
python3 --version
3533

3634
# NOTE: BUMP ALSO contrib/containers/ci/ci-slim.Dockerfile
37-
${CI_RETRY_EXE} pip3 install codespell==2.2.1
38-
${CI_RETRY_EXE} pip3 install flake8==5.0.4
39-
${CI_RETRY_EXE} pip3 install lief==0.13.2
40-
${CI_RETRY_EXE} pip3 install mypy==0.981
41-
${CI_RETRY_EXE} pip3 install pyzmq==24.0.1
42-
${CI_RETRY_EXE} pip3 install vulture==2.6
35+
${CI_RETRY_EXE} pip3 install \
36+
codespell==2.2.1 \
37+
flake8==5.0.4 \
38+
lief==0.13.2 \
39+
mypy==0.981 \
40+
pyzmq==24.0.1 \
41+
vulture==2.6
4342

4443
SHELLCHECK_VERSION=v0.8.0
4544
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | \

‎ci/lint/Dockerfile‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎ci/lint/docker-entrypoint.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export LC_ALL=C
55
# of the mounted bitcoin src dir.
66
git config --global --add safe.directory /bitcoin
77

8+
export PATH="/python_build/bin:${PATH}"
9+
810
if [ -z "$1" ]; then
911
LOCAL_BRANCH=1 bash -ic "./ci/lint/06_script.sh"
1012
else

‎ci/lint_imagefile‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See test/lint/README.md for usage.
2+
3+
FROM debian:bookworm
4+
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV LC_ALL=C.UTF-8
7+
8+
COPY ./.python-version /.python-version
9+
COPY ./ci/lint/docker-entrypoint.sh /entrypoint.sh
10+
COPY ./ci/lint/04_install.sh /install.sh
11+
12+
RUN /install.sh && \
13+
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \
14+
chmod 755 /entrypoint.sh && \
15+
rm -rf /var/lib/apt/lists/*
16+
17+
18+
WORKDIR /bitcoin
19+
ENTRYPOINT ["/entrypoint.sh"]

‎test/lint/README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ To run linters locally with the same versions as the CI environment, use the inc
77
Dockerfile:
88

99
```sh
10-
cd ./ci/lint
11-
docker build -t bitcoin-linter .
10+
DOCKER_BUILDKIT=1 docker build -t bitcoin-linter --file "./ci/lint_imagefile" ./
1211

13-
cd /root/of/bitcoin/repo
1412
docker run --rm -v $(pwd):/bitcoin -it bitcoin-linter
1513
```
1614

0 commit comments

Comments
 (0)