1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
# kate: hl earthfile;
VERSION --shell-out-anywhere 0.6
# <beginfold id='1'>BEGIN</beginfold id='1'> Global parameters
ARG DEVTOOLSET_VERSION = 11
ARG DEVTOOLSET = devtoolset-${DEVTOOLSET_VERSION}
# <endfold id='1'>END</endfold id='1'> Global parameters
ARG param_1 = "String w/ variable interpolation ${DEVTOOLSET}"
ARG param_2 = 'String w/o variable interpolation ${DEVTOOLSET}'
# Run shell command
ARG param_3 = $(echo "String w/ variable interpolation ${DEVTOOLSET}")
<endfold id='2'></endfold id='2'><beginfold id='2'>sample-target:</beginfold id='2'>
FROM alpine
ARG stage
COPY --if-exists files/${stage}/ /files/
SAVE ARTIFACT --keep-ts /files /share
<endfold id='2'></endfold id='2'><beginfold id='2'>repos-conf-apt:</beginfold id='2'>
ARG image
ARG ppa
FROM ${image}
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
<beginfold id='3'>IF</beginfold id='3'> [ "${ppa}" != '' ]
ARG _more_cmds = add-apt-repository -y -n ppa:${ppa}/ppa
ELSE
ARG _more_cmds = :
<endfold id='3'>END</endfold id='3'>
RUN --mount type=secret,id=+secrets/repo_gpg_key,target=/run/secrets/private-archive-keyring.gpg \
--mount type=cache,target=/var/cache/apt/archives \
--mount type=cache,target=/var/lib/apt/lists \
set -x; \
debconf-set-selections /tmp/debconf-preset.txt \
&& rm -rf /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository --remove multiverse \
&& gpg -v --dearmor - </run/secrets/private-archive-keyring.gpg > /usr/share/keyrings/private-archive-keyring.gpg \
&& ${_more_cmds}
SAVE ARTIFACT /etc/apt/sources.list /sources.list
SAVE ARTIFACT /usr/share/keyrings/private-archive-keyring.gpg /private-archive-keyring.gpg
<beginfold id='3'>IF</beginfold id='3'> [ "${ppa}" != '' ]
SAVE ARTIFACT /etc/apt/sources.list.d/${ppa}*.list /sources.list.d
SAVE ARTIFACT /etc/apt/trusted.gpg.d/${ppa}*.gpg /trusted.gpg.d
<endfold id='3'>END</endfold id='3'>
<endfold id='2'></endfold id='2'><beginfold id='2'>APT_INSTALL:</beginfold id='2'>
FUNCTION
ARG image
ARG packages = ''
ARG packages_on_hold = ''
ARG upgrade = 0
ARG clean = 0
ARG pm_aux_options = ''
ARG more_rm_files = ''
ARG more_cmds = :
<beginfold id='3'>IF</beginfold id='3'> [ ! -f /root/debconf-preset.txt ]
COPY (+repos-conf-apt/debconf-preset.txt --image=${image}) /root/debconf-preset.txt
ARG _debconf_cmd_cond = debconf-set-selections /root/debconf-preset.txt
ELSE
ARG _debconf_cmd_cond = :
<endfold id='3'>END</endfold id='3'>
<beginfold id='3'>IF</beginfold id='3'> [ ! -f /usr/share/keyrings/private-archive-keyring.gpg ]
COPY (+repos-conf-apt/private-archive-keyring.gpg --image=${image}) \
/usr/share/keyrings/private-archive-keyring.gpg
# NOTE Also copy the `sources.list` file with `multiverse` disabled!
COPY (+repos-conf-apt/sources.list --image=${image}) /etc/apt
<endfold id='3'>END</endfold id='3'>
# ...
<endfold id='2'></endfold id='2'><beginfold id='2'>MAKE_PYTHON_CI_IMAGE:</beginfold id='2'>
FUNCTION
ARG image
ARG python = python3
ARG python_pkg = ${python}
ARG python_bin = ${python}
ARG python_ver = 3.11
DO +APT_INSTALL --packages="${python_pkg} git"
ARG _chroot_base = $(dirname <beginfold id='4'>$(</beginfold id='4'>cat /etc/debian_chroot<endfold id='4'>)</endfold id='4'>)
DO ./share+IMAGE_INIT \
--image_description="CI image for Python projects" \
--debian_chroot=${_chroot_base}/python/${python_ver}/ci \
--storage_name=none
COPY --dir (+prep-python-ci/local --image=${image}) /usr
ENV SETUPTOOLS_USE_DISTUTILS='stdlib'
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
<endfold id='2'></endfold id='2'><beginfold id='2'>all:</beginfold id='2'>
LOCALLY
# Primary images
BUILD +ci
BUILD +clang-ci
BUILD +python-ci
<beginfold id='3'>IF</beginfold id='3'> [ "${BUILD_TESTING}" -gt 0 ]
# Also include all tests
BUILD +tests
<endfold id='3'>END</endfold id='3'>
<endfold id='2'></endfold id='2'><beginfold id='2'>tests:</beginfold id='2'>
LOCALLY
BUILD +ci-tests
BUILD +clang-ci-tests
BUILD +python-ci-tests
<endfold id='2'></endfold id='2'><beginfold id='2'>ci-tests:</beginfold id='2'>
FROM +ci
COPY .env /
DO share+RUN_TESTS --VERBOSE=${VERBOSE}
<endfold id='2'></endfold id='2'><beginfold id='2'>clang-ci-tests:</beginfold id='2'>
FROM +clang-ci
COPY .env /
ENV EXPECT_CLANG_VERSION=${CLANG_VERSION}
DO share+RUN_TESTS --VERBOSE=${VERBOSE} --script=ci-tests.sh
<endfold id='2'></endfold id='2'><beginfold id='2'>python-ci-tests:</beginfold id='2'>
FROM +python-ci
COPY .env /
DO share+RUN_TESTS --VERBOSE=${VERBOSE}
|