Skip to content

Commit b2e4584

Browse files
committed
feat: Add ccache to kernel build workflows
Restoration of the previous cache is intentionally skipped for tagged releases
1 parent 64219c3 commit b2e4584

3 files changed

Lines changed: 97 additions & 3 deletions

File tree

.github/workflows/arch.yaml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
rm -rf /opt-host/hostedtoolcache
3030
rm -rf /opt-host/az
3131
df -h
32+
3233
- name: Checkout sources
3334
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3435
with:
@@ -41,6 +42,14 @@ jobs:
4142
cp -vR * /home/build/linux
4243
chown -vR build /home/build/linux
4344
45+
- name: Restore ccache
46+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
47+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
48+
with:
49+
path: .ccache
50+
key: ccache-arch-${{ hashFiles('config') }}
51+
restore-keys: ccache-arch-
52+
4453
- name: Set up pacman keyring
4554
run: |
4655
pacman-key --init
@@ -49,13 +58,33 @@ jobs:
4958
5059
- name: Install dependencies
5160
run: |
52-
pacman -Syu --noconfirm bc cpio gettext libelf pahole perl python rust rust-bindgen rust-src tar xz graphviz imagemagick python-sphinx python-yaml texlive-latexextra
61+
pacman -Syu --noconfirm bc ccache cpio gettext libelf pahole perl python rust rust-bindgen rust-src tar xz graphviz imagemagick python-sphinx python-yaml texlive-latexextra
62+
63+
- name: Configure ccache
64+
run: |
65+
mkdir -p $GITHUB_WORKSPACE/.ccache
66+
chown -R build $GITHUB_WORKSPACE/.ccache
67+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
68+
ccache -M 3G
69+
ccache -z
5370
5471
- name: Build linux package
5572
id: build-kernel-package
5673
shell: bash
5774
run: |
58-
su build bash -c "cd /home/build/linux/arch && MAKEFLAGS=-j$(nproc) makepkg --skippgpcheck"
75+
su build bash -c "export CC='ccache gcc' CCACHE_DIR=$GITHUB_WORKSPACE/.ccache CCACHE_BASEDIR=/home/build/linux/arch/src/linux-6.19.6 && cd /home/build/linux/arch && MAKEFLAGS=-j$(nproc) makepkg --skippgpcheck"
5976
. /home/build/linux/arch/PKGBUILD
6077
full_version=${pkgver}-${pkgrel}
6178
echo "full_version=$full_version" >> "$GITHUB_OUTPUT"
79+
80+
- name: ccache statistics
81+
if: success() || failure()
82+
run: |
83+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
84+
85+
- name: Save ccache
86+
if: success() || failure()
87+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
88+
with:
89+
path: .ccache
90+
key: ccache-arch-${{ hashFiles('config') }}

.github/workflows/nobara.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,52 @@ jobs:
2929
rm -rf /opt-host/hostedtoolcache
3030
rm -rf /opt-host/az
3131
df -h
32+
3233
- name: Checkout sources
3334
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3435
with:
3536
persist-credentials: false
3637

38+
- name: Restore ccache
39+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
40+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
41+
with:
42+
path: .ccache
43+
key: ccache-nobara-${{ hashFiles('config') }}
44+
restore-keys: ccache-nobara-
45+
3746
- name: Dependencies
3847
run: |
48+
dnf -y install ccache
3949
dnf -y builddep nobara/kernel.spec
50+
51+
- name: Configure ccache
52+
run: |
53+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
54+
ccache -M 3G
55+
ccache -z
56+
4057
- name: build
4158
run: |
59+
export CC="ccache gcc"
60+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
61+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE/rpmbuild/BUILD
62+
4263
TOPDIR="$(pwd)/rpmbuild"
4364
4465
mkdir -p "$TOPDIR"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
4566
cp nobara/* $TOPDIR/SOURCES
4667
4768
rpmbuild --define "_topdir $TOPDIR" -ba ./nobara/kernel.spec
69+
70+
- name: ccache statistics
71+
if: success() || failure()
72+
run: |
73+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
74+
75+
- name: Save ccache
76+
if: success() || failure()
77+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
78+
with:
79+
path: .ccache
80+
key: ccache-nobara-${{ hashFiles('config') }}

.github/workflows/ubuntu.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,33 @@ jobs:
2929
rm -rf /opt-host/hostedtoolcache
3030
rm -rf /opt-host/az
3131
df -h
32+
3233
- name: Checkout sources
3334
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3435
with:
3536
persist-credentials: false
3637

38+
- name: Restore ccache
39+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
40+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
41+
with:
42+
path: .ccache
43+
key: ccache-ubuntu-${{ hashFiles('config') }}
44+
restore-keys: ccache-ubuntu-
45+
3746
- name: Dependencies
3847
run: |
3948
export DEBIAN_FRONTEND=noninteractive
4049
apt-get update -y
41-
apt-get install -y build-essential devscripts debhelper dh-python asciidoc-base bc bison cpio dwarves flex kmod libdw-dev libiberty-dev libnuma-dev libslang2-dev lz4 rsync wget xmlto git
50+
apt-get install -y build-essential devscripts debhelper dh-python asciidoc-base bc bison cpio dwarves flex kmod libdw-dev libiberty-dev libnuma-dev libslang2-dev lz4 rsync wget xmlto git ccache
4251
apt-get install -y libunwind-dev libpfm4-dev coccinelle openjdk-17-jdk libcapstone-dev libbabeltrace-dev systemtap-sdt-dev libzstd-dev dwarves zstd libbfd-dev libperl-dev libssl-dev
52+
53+
- name: Configure ccache
54+
run: |
55+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
56+
ccache -M 3G
57+
ccache -z
58+
4359
- name: Get sources
4460
run: |
4561
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.19.6.tar.xz
@@ -48,8 +64,24 @@ jobs:
4864
cd linux-6.19.6
4965
cp ../config .config
5066
patch -Np1 < "../monolithic.patch"
67+
5168
- name: Build
5269
run: |
70+
export CC="ccache gcc"
71+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
72+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE/linux-6.19.6
5373
cd linux-6.19.6
5474
make olddefconfig
5575
fakeroot make -j$(nproc) bindeb-pkg
76+
77+
- name: ccache statistics
78+
if: success() || failure()
79+
run: |
80+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
81+
82+
- name: Save ccache
83+
if: success() || failure()
84+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
85+
with:
86+
path: .ccache
87+
key: ccache-ubuntu-${{ hashFiles('config') }}

0 commit comments

Comments
 (0)