Skip to content

Commit cb88953

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

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

.github/workflows/build.yaml

Lines changed: 17 additions & 11 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
;;
@@ -95,7 +100,7 @@ jobs:
95100
;;
96101
clearlinux:*)
97102
PKG_CACHE_DIR="/var/cache/swupd"
98-
INSTALL_CMD="swupd bundle-add"
103+
INSTALL_CMD="swupd --verbose --debug bundle-add"
99104
PACKAGES="git c-basic devpkg-curl devpkg-jansson devpkg-libsodium"
100105
PACKAGES_API="devpkg-libmicrohttpd"
101106
PACKAGES_CLANG="llvm"
@@ -112,11 +117,12 @@ 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
121+
chown -R root:root "${PKG_CACHE_DIR}"
116122
${INSTALL_CMD} ${PACKAGES}
117123
${CLEANUP_CACHE_CMD}
118124
chmod a+rX -R "${PKG_CACHE_DIR}"
119-
find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true
125+
( find "${PKG_CACHE_DIR}" || ls -d "${PKG_CACHE_DIR}"/* || true; ) | head -n 25
120126
git config --global --add safe.directory /workspace
121127
mkdir -p build
122128
cd build
@@ -134,4 +140,4 @@ jobs:
134140
uses: actions/cache/save@v4
135141
with:
136142
path: pkg-cache
137-
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ github.sha }}
143+
key: ${{ matrix.os }}-pkg-cache-${{ github.event_name == 'pull_request' && github.head_ref || 'main' }}-${{ matrix.config.id }}-${{ github.sha }}

0 commit comments

Comments
 (0)