Skip to content

Commit b3ef329

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#26976: ci: Cache package manager install step
fa486de ci: Cache package manager install step (MarcoFalke) Pull request description: Use the local podman or docker image cache to skip the slow `apt` step ACKs for top commit: jamesob: ACK fa486de ([`jamesob/ackr/26976.1.MarcoFalke.ci_cache_package_manager`](https://github.com/jamesob/bitcoin/tree/ackr/26976.1.MarcoFalke.ci_cache_package_manager)) Tree-SHA512: 3495346c6c862b63296d2691cc492bf52a0a99ee7fae798887c792609904546013eba788045cd508a5f669f2c52e3479c122c18a5275c87af38237a1b5c9da17
2 parents ea41aba + fa486de commit b3ef329

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

ci/test/01_base_install.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018-2022 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
CI_EXEC_ROOT () { bash -c "$*"; }
10+
export -f CI_EXEC_ROOT
11+
12+
if [ -n "$DPKG_ADD_ARCH" ]; then
13+
CI_EXEC_ROOT dpkg --add-architecture "$DPKG_ADD_ARCH"
14+
fi
15+
16+
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
17+
${CI_RETRY_EXE} CI_EXEC_ROOT dnf -y install epel-release
18+
${CI_RETRY_EXE} CI_EXEC_ROOT dnf -y --allowerasing install "$CI_BASE_PACKAGES" "$PACKAGES"
19+
elif [ "$CI_USE_APT_INSTALL" != "no" ]; then
20+
if [[ "${ADD_UNTRUSTED_BPFCC_PPA}" == "true" ]]; then
21+
# Ubuntu 22.04 LTS and Debian 11 both have an outdated bpfcc-tools packages.
22+
# The iovisor PPA is outdated as well. The next Ubuntu and Debian releases will contain updated
23+
# packages. Meanwhile, use an untrusted PPA to install an up-to-date version of the bpfcc-tools
24+
# package.
25+
# TODO: drop this once we can use newer images in GCE
26+
CI_EXEC_ROOT add-apt-repository ppa:hadret/bpfcc
27+
fi
28+
if [[ -n "${APPEND_APT_SOURCES_LIST}" ]]; then
29+
CI_EXEC_ROOT echo "${APPEND_APT_SOURCES_LIST}" \>\> /etc/apt/sources.list
30+
fi
31+
${CI_RETRY_EXE} CI_EXEC_ROOT apt-get update
32+
${CI_RETRY_EXE} CI_EXEC_ROOT apt-get install --no-install-recommends --no-upgrade -y "$PACKAGES" "$CI_BASE_PACKAGES"
33+
fi

ci/test/04_install.sh

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
3333

3434
# the name isn't important, so long as we use the same UID
3535
LOCAL_USER=nonroot
36-
${CI_RETRY_EXE} docker pull "$CI_IMAGE_NAME_TAG"
36+
DOCKER_BUILDKIT=1 ${CI_RETRY_EXE} docker build \
37+
--file "${BASE_ROOT_DIR}/ci/test_imagefile" \
38+
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
39+
--build-arg "FILE_ENV=${FILE_ENV}" \
40+
--tag="${CONTAINER_NAME}" \
41+
"${BASE_ROOT_DIR}"
3742

3843
if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then
3944
echo "Restart docker before run to stop and clear all containers started with --rm"
@@ -49,7 +54,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
4954
-w $BASE_ROOT_DIR \
5055
--env-file /tmp/env \
5156
--name $CONTAINER_NAME \
52-
$CI_IMAGE_NAME_TAG)
57+
$CONTAINER_NAME)
5358
export CI_CONTAINER_ID
5459

5560
# Create a non-root user inside the container which matches the local user.
@@ -63,6 +68,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
6368
export CI_EXEC_CMD_PREFIX="docker exec -u $LOCAL_UID $CI_CONTAINER_ID"
6469
else
6570
echo "Running on host system without docker wrapper"
71+
"${BASE_ROOT_DIR}/ci/test/01_base_install.sh"
6672
fi
6773

6874
CI_EXEC () {
@@ -76,29 +82,6 @@ export -f CI_EXEC_ROOT
7682

7783
CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}"
7884

79-
if [ -n "$DPKG_ADD_ARCH" ]; then
80-
CI_EXEC_ROOT dpkg --add-architecture "$DPKG_ADD_ARCH"
81-
fi
82-
83-
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
84-
${CI_RETRY_EXE} CI_EXEC_ROOT dnf -y install epel-release
85-
${CI_RETRY_EXE} CI_EXEC_ROOT dnf -y --allowerasing install "$CI_BASE_PACKAGES" "$PACKAGES"
86-
elif [ "$CI_USE_APT_INSTALL" != "no" ]; then
87-
if [[ "${ADD_UNTRUSTED_BPFCC_PPA}" == "true" ]]; then
88-
# Ubuntu 22.04 LTS and Debian 11 both have an outdated bpfcc-tools packages.
89-
# The iovisor PPA is outdated as well. The next Ubuntu and Debian releases will contain updated
90-
# packages. Meanwhile, use an untrusted PPA to install an up-to-date version of the bpfcc-tools
91-
# package.
92-
# TODO: drop this once we can use newer images in GCE
93-
CI_EXEC_ROOT add-apt-repository ppa:hadret/bpfcc
94-
fi
95-
if [[ -n "${APPEND_APT_SOURCES_LIST}" ]]; then
96-
CI_EXEC_ROOT echo "${APPEND_APT_SOURCES_LIST}" \>\> /etc/apt/sources.list
97-
fi
98-
${CI_RETRY_EXE} CI_EXEC_ROOT apt-get update
99-
${CI_RETRY_EXE} CI_EXEC_ROOT apt-get install --no-install-recommends --no-upgrade -y "$PACKAGES" "$CI_BASE_PACKAGES"
100-
fi
101-
10285
if [ -n "$PIP_PACKAGES" ]; then
10386
if [ "$CI_OS_NAME" == "macos" ]; then
10487
sudo -H pip3 install --upgrade pip

ci/test_imagefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ARG CI_IMAGE_NAME_TAG
2+
FROM ${CI_IMAGE_NAME_TAG}
3+
4+
ARG FILE_ENV
5+
ENV FILE_ENV=${FILE_ENV}
6+
7+
COPY ./ci/retry/retry /usr/bin/retry
8+
COPY ./ci/test/00_setup_env.sh ./${FILE_ENV} ./ci/test/01_base_install.sh /ci_base_install/ci/test/
9+
10+
RUN ["bash", "-c", "cd /ci_base_install/ && set -o errexit && source ./ci/test/00_setup_env.sh && ./ci/test/01_base_install.sh"]

0 commit comments

Comments
 (0)