Skip to content

Commit cb412ef

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

3 files changed

Lines changed: 78 additions & 3 deletions

File tree

.github/workflows/arch.yaml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ jobs:
6565
cp -vR * /home/build/linux
6666
chown -vR build /home/build/linux
6767
68+
- name: Restore ccache
69+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
70+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
71+
with:
72+
path: .ccache
73+
key: ccache-arch-${{ hashFiles('config') }}
74+
restore-keys: ccache-arch-
75+
6876
- name: Set up pacman keyring
6977
run: |
7078
pacman-key --init
@@ -73,13 +81,21 @@ jobs:
7381
7482
- name: Install dependencies
7583
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
84+
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
85+
86+
- name: Configure ccache
87+
run: |
88+
mkdir -p $GITHUB_WORKSPACE/.ccache
89+
chown -R build $GITHUB_WORKSPACE/.ccache
90+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
91+
ccache -M 3G
92+
ccache -z
7793
7894
- name: Build linux package
7995
id: build-kernel-package
8096
shell: bash
8197
run: |
82-
su build bash -c "cd /home/build/linux/arch && MAKEFLAGS=-j$(nproc) makepkg --skippgpcheck"
98+
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"
8399
. /home/build/linux/arch/PKGBUILD
84100
full_version=${pkgver}-${pkgrel}
85101
echo "full_version=$full_version" >> "$GITHUB_OUTPUT"
@@ -144,3 +160,15 @@ jobs:
144160
--certificate-identity-regexp=".*" \
145161
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
146162
"${REPO}:${VERSION}"
163+
164+
- name: ccache statistics
165+
if: success() || failure()
166+
run: |
167+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
168+
169+
- name: Save ccache
170+
if: success() || failure()
171+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
172+
with:
173+
path: .ccache
174+
key: ccache-arch-${{ hashFiles('config') }}

.github/workflows/nobara.yaml

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

61+
- name: Restore ccache
62+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
63+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
64+
with:
65+
path: .ccache
66+
key: ccache-nobara-${{ hashFiles('config') }}
67+
restore-keys: ccache-nobara-
68+
6169
- name: Dependencies
6270
run: |
71+
dnf -y install ccache jq
6372
dnf -y builddep nobara/kernel.spec
64-
dnf -y install jq
6573
6674
- name: build
6775
run: |
76+
export CC="ccache gcc"
77+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
78+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE/rpmbuild/BUILD
79+
6880
TOPDIR="$(pwd)/rpmbuild"
6981
7082
mkdir -p "$TOPDIR"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
@@ -136,3 +148,15 @@ jobs:
136148
--certificate-identity-regexp=".*" \
137149
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
138150
"${REPO}:${VERSION}"
151+
152+
- name: ccache statistics
153+
if: success() || failure()
154+
run: |
155+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
156+
157+
- name: Save ccache
158+
if: success() || failure()
159+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
160+
with:
161+
path: .ccache
162+
key: ccache-nobara-${{ hashFiles('config') }}

.github/workflows/ubuntu.yaml

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

61+
- name: Restore ccache
62+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
63+
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
64+
with:
65+
path: .ccache
66+
key: ccache-ubuntu-${{ hashFiles('config') }}
67+
restore-keys: ccache-ubuntu-
68+
6169
- name: Dependencies
6270
run: |
6371
export DEBIAN_FRONTEND=noninteractive
@@ -76,6 +84,9 @@ jobs:
7684
7785
- name: Build
7886
run: |
87+
export CC="ccache gcc"
88+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
89+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE/linux-6.19.6
7990
cd linux-6.19.6
8091
make olddefconfig
8192
fakeroot make -j$(nproc) bindeb-pkg
@@ -140,3 +151,15 @@ jobs:
140151
--certificate-identity-regexp=".*" \
141152
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
142153
"${REPO}:${VERSION}"
154+
155+
- name: ccache statistics
156+
if: success() || failure()
157+
run: |
158+
CCACHE_DIR=$GITHUB_WORKSPACE/.ccache ccache -s
159+
160+
- name: Save ccache
161+
if: success() || failure()
162+
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
163+
with:
164+
path: .ccache
165+
key: ccache-ubuntu-${{ hashFiles('config') }}

0 commit comments

Comments
 (0)