Skip to content

Commit 0ade32a

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

3 files changed

Lines changed: 75 additions & 3 deletions

File tree

.github/workflows/arch.yaml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ jobs:
6565
cp -vR * /home/build/linux
6666
chown -vR build /home/build/linux
6767
68+
- name: Restore ccache
69+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
70+
with:
71+
path: .ccache
72+
key: ccache-arch-${{ hashFiles('config') }}
73+
restore-keys: ccache-arch-
74+
6875
- name: Set up pacman keyring
6976
run: |
7077
pacman-key --init
@@ -73,13 +80,21 @@ jobs:
7380
7481
- name: Install dependencies
7582
run: |
76-
pacman -Syu --noconfirm bc cpio gettext jq libelf pahole perl python rust rust-bindgen rust-src tar xz graphviz imagemagick python-sphinx python-yaml texlive-latexextra
83+
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
84+
85+
- name: Configure ccache
86+
run: |
87+
mkdir -p $GITHUB_WORKSPACE/.ccache
88+
chown -R build $GITHUB_WORKSPACE/.ccache
89+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
90+
ccache -M 3G
91+
ccache -z
7792
7893
- name: Build linux package
7994
id: build-kernel-package
8095
shell: bash
8196
run: |
82-
su build bash -c "cd /home/build/linux/arch && MAKEFLAGS=-j$(nproc) makepkg --skippgpcheck"
97+
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"
8398
. /home/build/linux/arch/PKGBUILD
8499
full_version=${pkgver}-${pkgrel}
85100
echo "full_version=$full_version" >> "$GITHUB_OUTPUT"
@@ -144,3 +159,15 @@ jobs:
144159
--certificate-identity-regexp=".*" \
145160
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
146161
"${REPO}:${VERSION}"
162+
163+
- name: ccache statistics
164+
if: success() || failure()
165+
run: |
166+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
167+
168+
- name: Save ccache
169+
if: startsWith(github.ref, 'refs/tags/')
170+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
171+
with:
172+
path: .ccache
173+
key: ccache-arch-${{ hashFiles('config') }}

.github/workflows/nobara.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,24 @@ jobs:
5858
with:
5959
persist-credentials: false
6060

61+
- name: Restore ccache
62+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
63+
with:
64+
path: .ccache
65+
key: ccache-nobara-${{ hashFiles('config') }}
66+
restore-keys: ccache-nobara-
67+
6168
- name: Dependencies
6269
run: |
70+
dnf -y install ccache jq
6371
dnf -y builddep nobara/kernel.spec
64-
dnf -y install jq
6572
6673
- name: build
6774
run: |
75+
export CC="ccache gcc"
76+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
77+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE/rpmbuild/BUILD
78+
6879
TOPDIR="$(pwd)/rpmbuild"
6980
7081
mkdir -p "$TOPDIR"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
@@ -136,3 +147,15 @@ jobs:
136147
--certificate-identity-regexp=".*" \
137148
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
138149
"${REPO}:${VERSION}"
150+
151+
- name: ccache statistics
152+
if: success() || failure()
153+
run: |
154+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
155+
156+
- name: Save ccache
157+
if: startsWith(github.ref, 'refs/tags/')
158+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
159+
with:
160+
path: .ccache
161+
key: ccache-nobara-${{ hashFiles('config') }}

.github/workflows/ubuntu.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ jobs:
5858
with:
5959
persist-credentials: false
6060

61+
- name: Restore ccache
62+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
63+
with:
64+
path: .ccache
65+
key: ccache-ubuntu-${{ hashFiles('config') }}
66+
restore-keys: ccache-ubuntu-
67+
6168
- name: Dependencies
6269
run: |
6370
export DEBIAN_FRONTEND=noninteractive
@@ -76,6 +83,9 @@ jobs:
7683
7784
- name: Build
7885
run: |
86+
export CC="ccache gcc"
87+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
88+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE/linux-6.19.6
7989
cd linux-6.19.6
8090
make olddefconfig
8191
fakeroot make -j$(nproc) bindeb-pkg
@@ -140,3 +150,15 @@ jobs:
140150
--certificate-identity-regexp=".*" \
141151
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
142152
"${REPO}:${VERSION}"
153+
154+
- name: ccache statistics
155+
if: success() || failure()
156+
run: |
157+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
158+
159+
- name: Save ccache
160+
if: startsWith(github.ref, 'refs/tags/')
161+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
162+
with:
163+
path: .ccache
164+
key: ccache-ubuntu-${{ hashFiles('config') }}

0 commit comments

Comments
 (0)