Skip to content

Commit 877208c

Browse files
authored
Merge pull request #10701 from julek-wolfssl/ci-drop-apt-deps-cache
CI: install all apt deps from ghcr bundles, drop actions/cache apt-deps layer
2 parents 5929586 + d3659c7 commit 877208c

15 files changed

Lines changed: 400 additions & 151 deletions
Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Install apt dependencies'
2-
description: 'Install apt packages with retry logic and caching'
2+
description: 'Install apt packages with retry logic and an optional offline ghcr bundle'
33
inputs:
44
packages:
55
description: 'Space-separated list of apt packages to install'
@@ -16,16 +16,12 @@ inputs:
1616
description: 'Pass --no-install-recommends to apt-get install'
1717
required: false
1818
default: 'false'
19-
cache:
20-
description: 'Cache apt archives (disable for dynamic package names)'
21-
required: false
22-
default: 'true'
2319
ghcr-debs-tag:
2420
description: >
2521
Tag of a prebuilt .deb bundle published to
2622
ghcr.io/<owner>/wolfssl-ci-debs by the ci-deps-image workflow
2723
(e.g. "ubuntu-24.04-minimal"). When set, the packages are installed
28-
offline from that bundle and the apt cache path below is skipped; on
24+
offline from that bundle and the apt path below is skipped; on
2925
that happy path the apt mirror is not contacted. The offline install
3026
is all-or-nothing (a single --no-download install of the whole set),
3127
so any failure - bundle missing, not public, or not covering every
@@ -39,7 +35,7 @@ runs:
3935
# Preferred path: install from a prebuilt .deb bundle pulled from ghcr,
4036
# entirely offline (--no-download), so a flaky/timing-out apt mirror
4137
# cannot break the build. Best-effort: on any failure we leave
42-
# "satisfied" unset and the apt steps below run unchanged. The bundle
38+
# "satisfied" unset and the apt step below runs unchanged. The bundle
4339
# image must be PUBLIC so anonymous `docker pull` works (including from
4440
# fork PRs whose GITHUB_TOKEN cannot read private packages).
4541
- name: Install from ghcr .deb bundle (offline)
@@ -77,40 +73,9 @@ runs:
7773
echo "::notice::offline install incomplete for $IMG; using apt"
7874
fi
7975
80-
- name: Compute cache key
81-
if: inputs.cache == 'true' && steps.ghcr.outputs.satisfied != 'true'
82-
id: cache-key
83-
shell: bash
84-
run: |
85-
SORTED_PKGS=$(echo "${{ inputs.packages }}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
86-
PKG_HASH=$(echo "$SORTED_PKGS" | sha256sum | cut -d' ' -f1 | head -c 16)
87-
OS_VERSION=$(lsb_release -rs 2>/dev/null || echo "unknown")
88-
echo "key=apt-deps-${{ runner.os }}-${{ runner.arch }}-${OS_VERSION}-${PKG_HASH}" >> $GITHUB_OUTPUT
89-
echo "restore-key=apt-deps-${{ runner.os }}-${{ runner.arch }}-${OS_VERSION}-" >> $GITHUB_OUTPUT
90-
91-
- name: Restore apt cache
92-
if: inputs.cache == 'true' && steps.ghcr.outputs.satisfied != 'true'
93-
id: apt-cache
94-
uses: actions/cache/restore@v5
95-
with:
96-
path: ~/apt-cache
97-
key: ${{ steps.cache-key.outputs.key }}
98-
restore-keys: ${{ steps.cache-key.outputs.restore-key }}
99-
100-
- name: Pre-seed apt archives from cache
101-
if: inputs.cache == 'true' && steps.apt-cache.outputs.cache-hit == 'true' && steps.ghcr.outputs.satisfied != 'true'
102-
shell: bash
103-
run: |
104-
if [ -d ~/apt-cache ] && ls ~/apt-cache/*.deb >/dev/null 2>&1; then
105-
sudo cp ~/apt-cache/*.deb /var/cache/apt/archives/
106-
echo "Restored $(ls ~/apt-cache/*.deb | wc -l) cached .deb files"
107-
fi
108-
10976
- name: Install packages
11077
if: steps.ghcr.outputs.satisfied != 'true'
11178
shell: bash
112-
env:
113-
APT_CACHE_HIT: ${{ steps.apt-cache.outputs.cache-hit }}
11479
run: |
11580
export DEBIAN_FRONTEND=noninteractive
11681
RETRIES=${{ inputs.retries }}
@@ -120,17 +85,6 @@ runs:
12085
NO_REC="--no-install-recommends"
12186
fi
12287
123-
# Fast path: on cache hit the .debs are already pre-seeded into
124-
# /var/cache/apt/archives. Try installing directly first; if that
125-
# fails (e.g. the cached .debs were superseded in the index) fall
126-
# through to the regular update + install path.
127-
if [ "$APT_CACHE_HIT" = "true" ]; then
128-
if sudo apt-get install -y $NO_REC ${{ inputs.packages }}; then
129-
exit 0
130-
fi
131-
echo "::warning::install from cached .debs failed, falling back to apt-get update"
132-
fi
133-
13488
for i in $(seq 1 $RETRIES); do
13589
if sudo apt-get update -q && \
13690
sudo apt-get install -y $NO_REC ${{ inputs.packages }}; then
@@ -144,21 +98,3 @@ runs:
14498
sleep $DELAY
14599
DELAY=$((DELAY * 2))
146100
done
147-
148-
# PR runs never write the apt cache (no churn); only push/schedule runs
149-
# refresh it. The make-check family does not need it anyway - it installs
150-
# from the ghcr bundle above.
151-
- name: Collect .deb files for cache
152-
if: inputs.cache == 'true' && github.event_name != 'pull_request' && steps.apt-cache.outputs.cache-hit != 'true' && steps.ghcr.outputs.satisfied != 'true'
153-
shell: bash
154-
run: |
155-
mkdir -p ~/apt-cache
156-
cp /var/cache/apt/archives/*.deb ~/apt-cache/ 2>/dev/null || true
157-
echo "Cached $(ls ~/apt-cache/*.deb 2>/dev/null | wc -l) .deb files"
158-
159-
- name: Save apt cache
160-
if: inputs.cache == 'true' && github.event_name != 'pull_request' && steps.apt-cache.outputs.cache-hit != 'true' && steps.ghcr.outputs.satisfied != 'true'
161-
uses: actions/cache/save@v5
162-
with:
163-
path: ~/apt-cache
164-
key: ${{ steps.cache-key.outputs.key }}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: 'Install Arduino core'
2+
description: >
3+
Make an Arduino core (and the shared CI libraries) available, preferring a
4+
prebuilt bundle pulled from ghcr (published by the arduino-cores-image
5+
workflow) and falling back to `arduino-cli core install` when the bundle is
6+
unavailable or stale. Assumes arduino-cli is already on PATH.
7+
inputs:
8+
core-id:
9+
description: 'vendor:arch core to make available, e.g. esp32:esp32'
10+
required: true
11+
board-manager-url:
12+
description: >
13+
Optional third-party board_manager index URL, used only on the
14+
online-install fallback (the ghcr bundle already carries its own).
15+
required: false
16+
default: ''
17+
libs:
18+
description: 'Space-separated Arduino libraries to ensure are present'
19+
required: false
20+
default: 'ArduinoJson WiFiNINA Ethernet Bridge'
21+
runs:
22+
using: 'composite'
23+
steps:
24+
# Preferred path: restore ~/.arduino15 (the core + toolchain) and the
25+
# shared libraries from a prebuilt tarball pulled from ghcr, so the flaky
26+
# board_manager / toolchain downloads are off the PR critical path. The
27+
# bundle is published only under the wolfssl org (gated below), so fork PRs
28+
# read the public upstream image too. Best-effort: any failure leaves
29+
# "satisfied" unset and the online install below runs unchanged.
30+
- name: Restore Arduino core from ghcr bundle
31+
id: ghcr
32+
shell: bash
33+
run: |
34+
set -u
35+
command -v docker >/dev/null 2>&1 || { echo "::notice::docker unavailable; installing core online"; exit 0; }
36+
command -v arduino-cli >/dev/null 2>&1 || { echo "::notice::arduino-cli not on PATH; installing core online"; exit 0; }
37+
CORE_ID='${{ inputs.core-id }}'
38+
TAG=$(echo "$CORE_ID" | tr ':' '-')
39+
IMG="ghcr.io/wolfssl/wolfssl-ci-arduino:$TAG"
40+
if ! docker pull -q "$IMG" >/dev/null 2>&1; then
41+
echo "::notice::ghcr bundle $IMG unavailable; installing core online"
42+
exit 0
43+
fi
44+
cid=$(docker create "$IMG" 2>/dev/null) || { echo "::notice::cannot open bundle; installing core online"; exit 0; }
45+
rm -f "$RUNNER_TEMP/arduino-core.tar"
46+
docker cp "$cid:/arduino-core.tar" "$RUNNER_TEMP/arduino-core.tar" >/dev/null 2>&1 || true
47+
docker rm "$cid" >/dev/null 2>&1 || true
48+
test -f "$RUNNER_TEMP/arduino-core.tar" || { echo "::notice::bundle had no tarball; installing core online"; exit 0; }
49+
# Entries are stored relative to $HOME (.arduino15/..., Arduino/libraries/...).
50+
tar -C "$HOME" -xf "$RUNNER_TEMP/arduino-core.tar" || { echo "::notice::could not unpack bundle; installing core online"; exit 0; }
51+
rm -f "$RUNNER_TEMP/arduino-core.tar"
52+
if arduino-cli core list 2>/dev/null | awk 'NR>1 {print $1}' | grep -Fxq "$CORE_ID"; then
53+
echo "satisfied=true" >> "$GITHUB_OUTPUT"
54+
echo "Restored $CORE_ID from $IMG"
55+
else
56+
echo "::notice::bundle did not yield $CORE_ID; installing core online"
57+
fi
58+
59+
- name: Install Arduino core online
60+
if: steps.ghcr.outputs.satisfied != 'true'
61+
shell: bash
62+
run: |
63+
set -euo pipefail
64+
CORE_ID='${{ inputs.core-id }}'
65+
BM_URL='${{ inputs.board-manager-url }}'
66+
retry() { local i; for i in 1 2 3 4 5; do "$@" && return 0; sleep $((2**i)); done; "$@"; }
67+
68+
arduino-cli config init --overwrite
69+
# Wait up to 10 minutes for the big toolchain downloads.
70+
arduino-cli config set network.connection_timeout 600s
71+
# Scope third-party indexes to the one core that needs them: arduino-cli
72+
# re-reads every configured index on each call and fails if any is
73+
# unreachable, so an unconditional URL makes all jobs depend on it.
74+
if [ -n "$BM_URL" ]; then
75+
arduino-cli config add board_manager.additional_urls "$BM_URL"
76+
fi
77+
retry arduino-cli core update-index
78+
retry arduino-cli core install "$CORE_ID"
79+
for lib in ${{ inputs.libs }}; do
80+
retry arduino-cli lib install "$lib"
81+
done

.github/ci-deps/packages-ubuntu-22.04-full.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Keep sorted; add a package when an interop workflow adds one.
55
autoconf
66
automake
7+
binutils-dev
78
bison
89
bridge-utils
910
build-essential
@@ -17,6 +18,7 @@ crossbuild-essential-arm64
1718
crossbuild-essential-armel
1819
crossbuild-essential-armhf
1920
crossbuild-essential-riscv64
21+
curl
2022
device-tree-compiler
2123
dfu-util
2224
diffstat
@@ -39,12 +41,19 @@ help2man
3941
iproute2
4042
lcov
4143
libcairo2-dev
44+
libcurl4-openssl-dev
45+
libdbus-1-dev
4246
libglib2.0-dev
4347
libgtk2.0-0
48+
libiberty-dev
4449
liblocale-gettext-perl
4550
libmagic1
4651
libncurses5-dev
52+
libnl-3-dev
53+
libnl-genl-3-dev
54+
libnl-route-3-dev
4755
libpcap-dev
56+
libpcap0.8
4857
libpopt0
4958
libsdl1.2-dev
5059
libsdl2-dev
@@ -63,6 +72,7 @@ python-is-python3
6372
python3-dev
6473
python3-pip
6574
python3-ply
75+
python3-pycryptodome
6676
python3-setuptools
6777
python3-tk
6878
python3-wheel
@@ -73,6 +83,7 @@ socat
7383
srecord
7484
sudo
7585
texinfo
86+
tshark
7687
uml-utilities
7788
unzip
7889
wget
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# membrowse embedded-target apt packages for ubuntu-24.04 (the
2+
# '-embedded' bundle: ghcr.io/<owner>/wolfssl-ci-debs:ubuntu-24.04-embedded).
3+
# Kept separate from -full because the ARM cross-toolchain is large (~0.5 GB)
4+
# and unrelated to the interop workflows that pull -full. Keep sorted.
5+
build-essential
6+
ca-certificates
7+
cmake
8+
gcc-arm-none-eabi
9+
git
10+
libnewlib-arm-none-eabi
11+
libstdc++-arm-none-eabi-newlib
12+
ninja-build
13+
python3
14+
unzip
15+
wget

.github/ci-deps/packages-ubuntu-24.04-full.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ autoconf
88
autoconf-archive
99
automake
1010
autopoint
11+
bc
1112
bubblewrap
1213
build-essential
1314
ccache
@@ -51,6 +52,8 @@ libidn2-dev
5152
libio-socket-ssl-perl
5253
libjansson-dev
5354
libkrb5-dev
55+
libldb-dev
56+
libldb2
5457
liblz4-dev
5558
liblzma-dev
5659
liblzo2-dev
@@ -87,6 +90,7 @@ pkgconf
8790
psmisc
8891
python3-docutils
8992
python3-impacket
93+
python3-ldb
9094
python3-psutil
9195
shellcheck
9296
uuid-dev

0 commit comments

Comments
 (0)