Skip to content

Commit 2b7337f

Browse files
Merge #1756: ci: Fix image caching and apply other improvements
f163c35 ci: Set `DEBIAN_FRONTEND=noninteractive` (Hennadii Stepanov) 70ae177 ci: Bump `docker/build-push-action` version (Hennadii Stepanov) b2a95a4 ci: Drop `tags` input for `docker/build-push-action` (Hennadii Stepanov) 122014e ci: Add `scope` parameter to `cache-{to,from}` options (Hennadii Stepanov) Pull request description: This PR fixes an issue where only the latest image cache was available. For other minor improvements, see the individual commit messages. ACKs for top commit: real-or-random: utACK f163c35 Tree-SHA512: 7178c447d32e5c06e42d33ed32c9088fc19ca6a67369f2a8f6672b0ec010a516d4bb3a70a1847eec76e034ec22d6df778f6d421a04ba603ae18526a6f4104e65
2 parents baa2654 + f163c35 commit 2b7337f

File tree

3 files changed

+25
-43
lines changed

3 files changed

+25
-43
lines changed

.github/actions/run-in-docker-action/action.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ inputs:
44
dockerfile:
55
description: 'A Dockerfile that defines an image'
66
required: true
7-
tag:
8-
description: 'A tag of an image'
9-
required: true
7+
scope:
8+
description: 'A cached image scope'
9+
required: false
10+
default: ${{ runner.arch }}
1011
command:
1112
description: 'A command to run in a container'
1213
required: false
@@ -16,25 +17,23 @@ runs:
1617
steps:
1718
- uses: docker/setup-buildx-action@v3
1819

19-
- uses: docker/build-push-action@v5
20+
- uses: docker/build-push-action@v6
2021
id: main_builder
2122
continue-on-error: true
2223
with:
2324
context: .
2425
file: ${{ inputs.dockerfile }}
25-
tags: ${{ inputs.tag }}
2626
load: true
27-
cache-from: type=gha
27+
cache-from: type=gha,scope=${{ inputs.scope }}
2828

29-
- uses: docker/build-push-action@v5
29+
- uses: docker/build-push-action@v6
3030
id: retry_builder
3131
if: steps.main_builder.outcome == 'failure'
3232
with:
3333
context: .
3434
file: ${{ inputs.dockerfile }}
35-
tags: ${{ inputs.tag }}
3635
load: true
37-
cache-from: type=gha
36+
cache-from: type=gha,scope=${{ inputs.scope }}
3837

3938
- # Workaround for https://github.com/google/sanitizers/issues/1614 .
4039
# The underlying issue has been fixed in clang 18.1.3.
@@ -47,7 +46,8 @@ runs:
4746
$(echo '${{ toJSON(env) }}' | jq -r 'keys[] | "--env \(.) "') \
4847
--volume ${{ github.workspace }}:${{ github.workspace }} \
4948
--workdir ${{ github.workspace }} \
50-
${{ inputs.tag }} bash -c "
49+
$(docker images -q | head -n1) \
50+
bash -c "
5151
git config --global --add safe.directory ${{ github.workspace }}
5252
${{ inputs.command }}
5353
"

.github/workflows/ci.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ jobs:
6767
network=host
6868
6969
- name: Build container
70-
uses: docker/build-push-action@v5
70+
uses: docker/build-push-action@v6
7171
with:
7272
file: ./ci/linux-debian.Dockerfile
73-
tags: ${{ matrix.arch }}-debian-image
74-
cache-from: type=gha
75-
cache-to: type=gha,mode=min
73+
cache-from: type=gha,scope=${{ runner.arch }}
74+
cache-to: type=gha,scope=${{ runner.arch }},mode=min
7675

7776
x86_64-debian:
7877
name: "x86_64: Linux (Debian stable)"
@@ -116,7 +115,6 @@ jobs:
116115
uses: ./.github/actions/run-in-docker-action
117116
with:
118117
dockerfile: ./ci/linux-debian.Dockerfile
119-
tag: x64-debian-image
120118

121119
- name: Print logs
122120
uses: ./.github/actions/print-logs
@@ -152,7 +150,6 @@ jobs:
152150
uses: ./.github/actions/run-in-docker-action
153151
with:
154152
dockerfile: ./ci/linux-debian.Dockerfile
155-
tag: x64-debian-image
156153

157154
- name: Print logs
158155
uses: ./.github/actions/print-logs
@@ -184,7 +181,6 @@ jobs:
184181
uses: ./.github/actions/run-in-docker-action
185182
with:
186183
dockerfile: ./ci/linux-debian.Dockerfile
187-
tag: x64-debian-image
188184

189185
- name: Print logs
190186
uses: ./.github/actions/print-logs
@@ -225,7 +221,6 @@ jobs:
225221
uses: ./.github/actions/run-in-docker-action
226222
with:
227223
dockerfile: ./ci/linux-debian.Dockerfile
228-
tag: x64-debian-image
229224

230225
- name: Print logs
231226
uses: ./.github/actions/print-logs
@@ -265,7 +260,6 @@ jobs:
265260
uses: ./.github/actions/run-in-docker-action
266261
with:
267262
dockerfile: ./ci/linux-debian.Dockerfile
268-
tag: arm64-debian-image
269263

270264
- name: Print logs
271265
uses: ./.github/actions/print-logs
@@ -297,7 +291,6 @@ jobs:
297291
uses: ./.github/actions/run-in-docker-action
298292
with:
299293
dockerfile: ./ci/linux-debian.Dockerfile
300-
tag: x64-debian-image
301294

302295
- name: Print logs
303296
uses: ./.github/actions/print-logs
@@ -313,28 +306,22 @@ jobs:
313306
fail-fast: false
314307
matrix:
315308
include:
316-
- docker_arch: x64
317-
runner: ubuntu-latest
309+
- runner: ubuntu-latest
318310
binary_arch: x64
319311
env_vars: { CC: 'clang', ASM: 'auto' }
320-
- docker_arch: x64
321-
runner: ubuntu-latest
312+
- runner: ubuntu-latest
322313
binary_arch: i686
323314
env_vars: { CC: 'i686-linux-gnu-gcc', HOST: 'i686-linux-gnu', ASM: 'auto' }
324-
- docker_arch: arm64
325-
runner: ubuntu-24.04-arm
315+
- runner: ubuntu-24.04-arm
326316
binary_arch: arm64
327317
env_vars: { CC: 'clang', ASM: 'auto' }
328-
- docker_arch: x64
329-
runner: ubuntu-latest
318+
- runner: ubuntu-latest
330319
binary_arch: x64
331320
env_vars: { CC: 'clang', ASM: 'no', ECMULTGENKB: 2, ECMULTWINDOW: 2 }
332-
- docker_arch: x64
333-
runner: ubuntu-latest
321+
- runner: ubuntu-latest
334322
binary_arch: i686
335323
env_vars: { CC: 'i686-linux-gnu-gcc', HOST: 'i686-linux-gnu', ASM: 'no', ECMULTGENKB: 2, ECMULTWINDOW: 2 }
336-
- docker_arch: arm64
337-
runner: ubuntu-24.04-arm
324+
- runner: ubuntu-24.04-arm
338325
binary_arch: arm64
339326
env_vars: { CC: 'clang', ASM: 'no', ECMULTGENKB: 2, ECMULTWINDOW: 2 }
340327

@@ -360,7 +347,6 @@ jobs:
360347
uses: ./.github/actions/run-in-docker-action
361348
with:
362349
dockerfile: ./ci/linux-debian.Dockerfile
363-
tag: ${{ matrix.docker_arch }}-debian-image
364350

365351
- name: Print logs
366352
uses: ./.github/actions/print-logs
@@ -404,7 +390,6 @@ jobs:
404390
uses: ./.github/actions/run-in-docker-action
405391
with:
406392
dockerfile: ./ci/linux-debian.Dockerfile
407-
tag: x64-debian-image
408393

409394
- name: Print logs
410395
uses: ./.github/actions/print-logs
@@ -455,7 +440,6 @@ jobs:
455440
uses: ./.github/actions/run-in-docker-action
456441
with:
457442
dockerfile: ./ci/linux-debian.Dockerfile
458-
tag: x64-debian-image
459443

460444
- name: Print logs
461445
uses: ./.github/actions/print-logs
@@ -498,7 +482,6 @@ jobs:
498482
uses: ./.github/actions/run-in-docker-action
499483
with:
500484
dockerfile: ./ci/linux-debian.Dockerfile
501-
tag: x64-debian-image
502485

503486
- name: Print logs
504487
uses: ./.github/actions/print-logs
@@ -714,7 +697,6 @@ jobs:
714697
uses: ./.github/actions/run-in-docker-action
715698
with:
716699
dockerfile: ./ci/linux-debian.Dockerfile
717-
tag: x64-debian-image
718700

719701
- name: Print logs
720702
uses: ./.github/actions/print-logs
@@ -733,7 +715,6 @@ jobs:
733715
uses: ./.github/actions/run-in-docker-action
734716
with:
735717
dockerfile: ./ci/linux-debian.Dockerfile
736-
tag: x64-debian-image
737718
command: |
738719
g++ -Werror include/*.h
739720
clang -Werror -x c++-header include/*.h

ci/linux-debian.Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN dpkg --add-architecture i386 && \
2121

2222
# dpkg-dev: to make pkg-config work in cross-builds
2323
# llvm: for llvm-symbolizer, which is used by clang's UBSan for symbolized stack traces
24-
RUN apt-get update && apt-get install --no-install-recommends -y \
24+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
2525
git ca-certificates \
2626
make automake libtool pkg-config dpkg-dev valgrind qemu-user \
2727
gcc clang llvm libclang-rt-dev libc6-dbg \
@@ -34,14 +34,15 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
3434
gcc-mingw-w64-i686-win32 wine32 \
3535
python3-full && \
3636
if ! ( dpkg --print-architecture | grep --quiet "arm64" ) ; then \
37-
apt-get install --no-install-recommends -y \
37+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
3838
gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6-dbg:arm64 ;\
3939
fi && \
4040
apt-get clean && rm -rf /var/lib/apt/lists/*
4141

4242
# Build and install gcc snapshot
4343
ARG GCC_SNAPSHOT_MAJOR=16
44-
RUN apt-get update && apt-get install --no-install-recommends -y wget libgmp-dev libmpfr-dev libmpc-dev flex && \
44+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
45+
wget libgmp-dev libmpfr-dev libmpc-dev flex && \
4546
mkdir gcc && cd gcc && \
4647
wget --progress=dot:giga --https-only --recursive --accept '*.tar.xz' --level 1 --no-directories "https://gcc.gnu.org/pub/gcc/snapshots/LATEST-${GCC_SNAPSHOT_MAJOR}" && \
4748
wget "https://gcc.gnu.org/pub/gcc/snapshots/LATEST-${GCC_SNAPSHOT_MAJOR}/sha512.sum" && \
@@ -62,15 +63,15 @@ RUN apt-get update && apt-get install --no-install-recommends -y wget libgmp-dev
6263
# Install clang snapshot, see https://apt.llvm.org/
6364
RUN \
6465
# Setup GPG keys of LLVM repository
65-
apt-get update && apt-get install --no-install-recommends -y wget && \
66+
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y wget && \
6667
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
6768
# Add repository for this Debian release
6869
. /etc/os-release && echo "deb http://apt.llvm.org/${VERSION_CODENAME} llvm-toolchain-${VERSION_CODENAME} main" >> /etc/apt/sources.list && \
6970
apt-get update && \
7071
# Determine the version number of the LLVM development branch
7172
LLVM_VERSION=$(apt-cache search --names-only '^clang-[0-9]+$' | sort -V | tail -1 | cut -f1 -d" " | cut -f2 -d"-" ) && \
7273
# Install
73-
apt-get install --no-install-recommends -y "clang-${LLVM_VERSION}" && \
74+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y "clang-${LLVM_VERSION}" && \
7475
# Create symlink
7576
ln -s "/usr/bin/clang-${LLVM_VERSION}" /usr/bin/clang-snapshot && \
7677
# Clean up

0 commit comments

Comments
 (0)