Skip to content

Commit 3fee9bd

Browse files
authored
ci: optimize Docker image loading (#1037)
1 parent 3cf8cc5 commit 3fee9bd

1 file changed

Lines changed: 35 additions & 9 deletions

File tree

.github/workflows/linux.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: linux
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66
pull_request:
77

88
concurrency:
@@ -12,7 +12,7 @@ concurrency:
1212
env:
1313
FORCE_COLOR: 1
1414

15-
permissions: {}
15+
permissions: { }
1616

1717
jobs:
1818
crate-build:
@@ -248,15 +248,41 @@ jobs:
248248
249249
- name: Load Docker Images
250250
run: |
251+
set -euo pipefail
252+
253+
# We need to keep the image-*.tar file since it is used as a
254+
# Makefile dependency.
255+
load() {
256+
image="${1%.tar.zst}"
257+
echo "decompressing ${image}.tar.zst"
258+
zstd -d --rm "${image}.tar.zst"
259+
docker load --input "${image}.tar"
260+
}
261+
262+
# Avoid loading images that aren't used.
263+
case "$(uname -m)" in
264+
aarch64)
265+
want_suffix=linux_aarch64.tar.zst
266+
;;
267+
x86_64)
268+
want_suffix=linux_x86_64.tar.zst
269+
;;
270+
*)
271+
echo "unsupported host arch: $(uname -m)"
272+
exit 1
273+
;;
274+
esac
275+
251276
for f in build/image-*.tar.zst; do
252-
echo "decompressing $f"
253-
zstd -d --rm ${f}
254-
done
255-
256-
for f in build/image-*.tar; do
257-
echo "loading $f"
258-
docker load --input $f
277+
if [[ "$f" == *"${want_suffix}" ]]; then
278+
load "${f}" &
279+
else
280+
echo "skipping ${f}"
281+
rm "${f}"
282+
fi
259283
done
284+
285+
wait
260286
261287
- name: Build
262288
if: ${{ ! matrix.dry-run }}

0 commit comments

Comments
 (0)