Skip to content

Commit 705e9f3

Browse files
committed
fixup! fixup! CI: Cache packages
1 parent f0ff190 commit 705e9f3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

.github/workflows/build.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ jobs:
2525
- clearlinux:latest
2626
config:
2727
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=gcc"
28+
id: "gcc"
2829
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=clang"
30+
id: "clang"
2931
- cmake_args: "-DENABLE_API=OFF"
32+
id: "no_api"
3033
exclude:
3134
# Clang configured for C11 rejects our C23 usage
3235
- os: debian:oldstable
@@ -43,8 +46,9 @@ jobs:
4346
uses: actions/cache/restore@v4
4447
with:
4548
path: pkg-cache
46-
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ github.sha }}
49+
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-${{ github.sha }}
4750
restore-keys: |
51+
${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-
4852
${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-
4953
${{ matrix.os }}-pkg-cache-main-
5054
@@ -66,24 +70,25 @@ jobs:
6670
case "${{ matrix.os }}" in
6771
debian:*|ubuntu:*)
6872
PKG_CACHE_DIR="/var/cache/apt"
69-
INSTALL_CMD="apt update && apt install -y"
73+
INSTALL_CMD="apt update && apt -o Binary::apt::APT::keep-downloaded-package=true install -y"
7074
PACKAGES="git libc6-dev cmake libcurl4-openssl-dev libjansson-dev libsodium-dev pkgconf"
7175
PACKAGES_API="libmicrohttpd-dev"
7276
CLEANUP_CACHE_CMD="rm -rfv ${PKG_CACHE_DIR}/archives/{partial,lock}"
7377
;;
7478
almalinux:*|amazonlinux:*|fedora:*|oraclelinux:*)
7579
PKG_CACHE_DIR="/var/cache/dnf"
76-
INSTALL_CMD="dnf install -y"
77-
[[ "${{ matrix.os }}" =~ ^almalinux: ]] && INSTALL_CMD="dnf install -y dnf-plugins-core && dnf config-manager --set-enabled crb && $INSTALL_CMD"
78-
[[ "${{ matrix.os }}" =~ ^oraclelinux: ]] && INSTALL_CMD="dnf install -y dnf-plugins-core && dnf config-manager --set-enabled ol9_codeready_builder && $INSTALL_CMD"
79-
[[ "${{ matrix.os }}" =~ ^(alma|oracle)linux: ]] && INSTALL_CMD="dnf install -y epel-release && $INSTALL_CMD"
80+
DNF_INSTALL="dnf --setopt=keepcache=True install -y"
81+
INSTALL_CMD="$DNF_INSTALL"
82+
[[ "${{ matrix.os }}" =~ ^almalinux: ]] && INSTALL_CMD="$DNF_INSTALL dnf-plugins-core && dnf config-manager --set-enabled crb && $INSTALL_CMD"
83+
[[ "${{ matrix.os }}" =~ ^oraclelinux: ]] && INSTALL_CMD="$DNF_INSTALL dnf-plugins-core && dnf config-manager --set-enabled ol9_codeready_builder && $INSTALL_CMD"
84+
[[ "${{ matrix.os }}" =~ ^(alma|oracle)linux: ]] && INSTALL_CMD="$DNF_INSTALL epel-release && $INSTALL_CMD"
8085
PACKAGES="git cmake libcurl-devel jansson-devel libsodium-devel pkgconf"
8186
PACKAGES_API="libmicrohttpd-devel"
8287
[[ "${{ matrix.config.cmake_args }}" =~ clang|gcc ]] || PACKAGES="$PACKAGES gcc"
8388
;;
8489
alpine:*)
8590
PKG_CACHE_DIR="/var/cache/apk"
86-
INSTALL_CMD="apk add"
91+
INSTALL_CMD="ln -s /var/cache/apk /etc/apk/cache && apk add"
8792
PACKAGES="git build-base cmake argp-standalone curl-dev jansson-dev libsodium-dev"
8893
PACKAGES_API="libmicrohttpd-dev"
8994
;;
@@ -112,11 +117,11 @@ jobs:
112117
PACKAGES="$PACKAGES $PACKAGES_CLANG"
113118
fi
114119
CMD="set -ex
115-
find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true
120+
( find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true; ) | head -n 25
116121
${INSTALL_CMD} ${PACKAGES}
117122
${CLEANUP_CACHE_CMD}
118123
chmod a+rX -R "${PKG_CACHE_DIR}"
119-
find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true
124+
( find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true; ) | head -n 25
120125
git config --global --add safe.directory /workspace
121126
mkdir -p build
122127
cd build
@@ -134,4 +139,4 @@ jobs:
134139
uses: actions/cache/save@v4
135140
with:
136141
path: pkg-cache
137-
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ github.sha }}
142+
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-${{ github.sha }}

0 commit comments

Comments
 (0)