Skip to content

Commit 3eb4eb5

Browse files
committed
Composite GHA action with caching
This adds caching for apt and should make things a bit more stable and faster.
1 parent 5b9d0a1 commit 3eb4eb5

30 files changed

Lines changed: 298 additions & 154 deletions
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 'Install apt dependencies'
2+
description: 'Install apt packages with retry logic and caching'
3+
inputs:
4+
packages:
5+
description: 'Space-separated list of apt packages to install'
6+
required: true
7+
retries:
8+
description: 'Number of retry attempts'
9+
required: false
10+
default: '3'
11+
retry-delay:
12+
description: 'Initial delay between retries (seconds, doubles each attempt)'
13+
required: false
14+
default: '5'
15+
no-install-recommends:
16+
description: 'Pass --no-install-recommends to apt-get install'
17+
required: false
18+
default: 'false'
19+
cache:
20+
description: 'Cache apt archives (disable for dynamic package names)'
21+
required: false
22+
default: 'true'
23+
runs:
24+
using: 'composite'
25+
steps:
26+
- name: Compute cache key
27+
if: inputs.cache == 'true'
28+
id: cache-key
29+
shell: bash
30+
run: |
31+
SORTED_PKGS=$(echo "${{ inputs.packages }}" | tr ' ' '\n' | sort | tr '\n' ' ')
32+
PKG_HASH=$(echo "$SORTED_PKGS" | sha256sum | cut -d' ' -f1 | head -c 16)
33+
OS_VERSION=$(lsb_release -rs 2>/dev/null || echo "unknown")
34+
echo "key=apt-deps-${{ runner.os }}-${{ runner.arch }}-${OS_VERSION}-${PKG_HASH}" >> $GITHUB_OUTPUT
35+
echo "restore-key=apt-deps-${{ runner.os }}-${{ runner.arch }}-${OS_VERSION}-" >> $GITHUB_OUTPUT
36+
37+
- name: Restore apt cache
38+
if: inputs.cache == 'true'
39+
id: apt-cache
40+
uses: actions/cache/restore@v4
41+
with:
42+
path: /var/cache/apt/archives
43+
key: ${{ steps.cache-key.outputs.key }}
44+
restore-keys: ${{ steps.cache-key.outputs.restore-key }}
45+
46+
- name: Install packages
47+
shell: bash
48+
run: |
49+
export DEBIAN_FRONTEND=noninteractive
50+
RETRIES=${{ inputs.retries }}
51+
DELAY=${{ inputs.retry-delay }}
52+
NO_REC=""
53+
if [ "${{ inputs.no-install-recommends }}" = "true" ]; then
54+
NO_REC="--no-install-recommends"
55+
fi
56+
for i in $(seq 1 $RETRIES); do
57+
if sudo apt-get update -q && \
58+
sudo apt-get install -y $NO_REC ${{ inputs.packages }}; then
59+
exit 0
60+
fi
61+
if [ "$i" -eq "$RETRIES" ]; then
62+
echo "::error::apt-get failed after $RETRIES attempts"
63+
exit 1
64+
fi
65+
echo "::warning::apt-get failed (attempt $i/$RETRIES), retrying in ${DELAY}s..."
66+
sleep $DELAY
67+
DELAY=$((DELAY * 2))
68+
done
69+
70+
- name: Save apt cache
71+
if: inputs.cache == 'true' && steps.apt-cache.outputs.cache-hit != 'true'
72+
uses: actions/cache/save@v4
73+
with:
74+
path: /var/cache/apt/archives
75+
key: ${{ steps.cache-key.outputs.key }}

.github/workflows/ada.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ jobs:
5656
if: ${{ failure() && steps.examples.outcome == 'failure' }}
5757
run: cat ./wrapper/Ada/examples/server.log
5858

59+
- name: Install valgrind
60+
uses: ./.github/actions/install-apt-deps
61+
with:
62+
packages: valgrind
63+
5964
- name: Run Ada wrapper tests (valgrind)
6065
working-directory: ./wrapper/Ada/tests
6166
run: |
62-
sudo apt-get update
63-
sudo apt-get install -y valgrind
6467
valgrind --leak-check=full --error-exitcode=1 \
6568
--suppressions=valgrind.supp ./bin/tests
6669

.github/workflows/bind.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ jobs:
5252
timeout-minutes: 10
5353
needs: build_wolfssl
5454
steps:
55+
- name: Checkout wolfSSL CI actions
56+
uses: actions/checkout@v4
57+
with:
58+
sparse-checkout: .github/actions
59+
depth: 1
60+
5561
- name: Download lib
5662
uses: actions/download-artifact@v4
5763
with:
@@ -61,12 +67,9 @@ jobs:
6167
run: tar -xf build-dir.tgz
6268

6369
- name: Install dependencies
64-
run: |
65-
# Don't prompt for anything
66-
export DEBIAN_FRONTEND=noninteractive
67-
sudo apt-get update
68-
# hostap dependencies
69-
sudo apt-get install -y libuv1-dev libnghttp2-dev libcap-dev libcmocka-dev liburcu-dev
70+
uses: ./.github/actions/install-apt-deps
71+
with:
72+
packages: libuv1-dev libnghttp2-dev libcap-dev libcmocka-dev liburcu-dev
7073

7174
- name: Checkout OSP
7275
uses: actions/checkout@v4

.github/workflows/cmake-autoconf.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ jobs:
1515
# pull wolfSSL
1616
- uses: actions/checkout@v4
1717

18-
# install cmake and autotools
19-
- name: Install cmake
20-
run: |
21-
sudo apt-get update
22-
sudo apt-get install -y cmake autoconf automake libtool
18+
- name: Install cmake and autotools
19+
uses: ./.github/actions/install-apt-deps
20+
with:
21+
packages: cmake autoconf automake libtool
2322

2423
# build and install wolfssl via autotools for CMake consumer test
2524
- name: Build wolfssl with autotools

.github/workflows/cmake.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ jobs:
1515
# pull wolfSSL
1616
- uses: actions/checkout@v4
1717

18-
# install cmake
1918
- name: Install cmake
20-
run: |
21-
sudo apt-get update
22-
sudo apt-get install -y cmake
19+
uses: ./.github/actions/install-apt-deps
20+
with:
21+
packages: cmake
2322

2423
# build wolfssl
2524
- name: Build wolfssl

.github/workflows/curl.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ jobs:
4949
matrix:
5050
curl_ref: [ 'master', 'curl-8_4_0' ]
5151
steps:
52+
- name: Checkout wolfSSL CI actions
53+
uses: actions/checkout@v4
54+
with:
55+
sparse-checkout: .github/actions
56+
depth: 1
57+
5258
- name: Install test dependencies
53-
run: |
54-
sudo apt-get update
55-
sudo apt-get install nghttp2 libpsl5 libpsl-dev python3-impacket apache2 apache2-dev
59+
uses: ./.github/actions/install-apt-deps
60+
with:
61+
packages: nghttp2 libpsl5 libpsl-dev python3-impacket apache2 apache2-dev
5662

5763
- name: Download lib
5864
uses: actions/download-artifact@v4

.github/workflows/cyrus-sasl.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ jobs:
5353
timeout-minutes: 4
5454
needs: build_wolfssl
5555
steps:
56+
- name: Checkout wolfSSL CI actions
57+
uses: actions/checkout@v4
58+
with:
59+
sparse-checkout: .github/actions
60+
depth: 1
61+
5662
- name: Install dependencies
57-
run: |
58-
# Don't prompt for anything
59-
export DEBIAN_FRONTEND=noninteractive
60-
sudo apt-get update
61-
sudo apt-get install krb5-kdc krb5-otp libkrb5-dev \
62-
libsocket-wrapper libnss-wrapper krb5-admin-server libdb5.3-dev
63+
uses: ./.github/actions/install-apt-deps
64+
with:
65+
packages: krb5-kdc krb5-otp libkrb5-dev libsocket-wrapper libnss-wrapper krb5-admin-server libdb5.3-dev
6366

6467
- name: Download lib
6568
uses: actions/download-artifact@v4

.github/workflows/grpc.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,16 @@ jobs:
6262
ip addr list lo | grep 'inet '
6363
ip addr list lo | grep 'inet6 '
6464
65+
- name: Checkout wolfSSL CI actions
66+
uses: actions/checkout@v4
67+
with:
68+
sparse-checkout: .github/actions
69+
depth: 1
70+
6571
- name: Install prereqs
66-
run:
67-
sudo apt-get install build-essential autoconf libtool pkg-config cmake clang libc++-dev
72+
uses: ./.github/actions/install-apt-deps
73+
with:
74+
packages: build-essential autoconf libtool pkg-config cmake clang libc++-dev
6875

6976
- name: Download lib
7077
uses: actions/download-artifact@v4

.github/workflows/haproxy.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ jobs:
4949
matrix:
5050
haproxy_ref: [ 'v3.1.0', 'v3.2.0']
5151
steps:
52+
- name: Checkout wolfSSL CI actions
53+
uses: actions/checkout@v4
54+
with:
55+
sparse-checkout: .github/actions
56+
depth: 1
57+
5258
- name: Install test dependencies
53-
run: |
54-
sudo apt-get update
55-
sudo apt-get install libpcre2-dev
59+
uses: ./.github/actions/install-apt-deps
60+
with:
61+
packages: libpcre2-dev
5662

5763
- name: Download lib
5864
uses: actions/download-artifact@v4

.github/workflows/hostap-vm.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,12 @@ jobs:
211211
run: tar -xf build-dir.tgz
212212

213213
- name: Install dependencies
214-
run: |
215-
# Don't prompt for anything
216-
export DEBIAN_FRONTEND=noninteractive
217-
sudo apt-get update
218-
# hostap dependencies
219-
sudo apt-get install -y libpcap0.8 libpcap-dev curl libcurl4-openssl-dev \
220-
libnl-3-dev binutils-dev libssl-dev libiberty-dev libnl-genl-3-dev \
221-
libnl-route-3-dev libdbus-1-dev bridge-utils tshark python3-pycryptodome
222-
sudo pip install pycryptodome
214+
uses: ./wolfssl/.github/actions/install-apt-deps
215+
with:
216+
packages: libpcap0.8 libpcap-dev curl libcurl4-openssl-dev libnl-3-dev binutils-dev libssl-dev libiberty-dev libnl-genl-3-dev libnl-route-3-dev libdbus-1-dev bridge-utils tshark python3-pycryptodome
217+
218+
- name: Install pip dependencies
219+
run: sudo pip install pycryptodome
223220

224221
- name: Checking if we have hostap in cache
225222
uses: actions/cache/restore@v4

0 commit comments

Comments
 (0)