Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github: add ccache #82

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
sudo apt-get update

# Kernel deps
sudo apt install -y build-essential flex bison libelf-dev libssl-dev
sudo apt install -y build-essential flex bison libelf-dev libssl-dev ccache

# run_qemu deps
sudo apt install -y mkosi # this one pulls A LOT
Expand Down Expand Up @@ -87,12 +87,39 @@ jobs:
path: ndctl

- name: download kernel
id: kernel_checkout
uses: actions/checkout@v4
with:
repository: torvalds/linux
ref: v6.12
path: kernel

- name: set week number for ccache
id: weeks
run: |
printf 'now=%s\n' "$(date +%Y-w%U)" >> "$GITHUB_OUTPUT"
printf 'previous=%s\n' "$(date +%Y-w%U -d '7 days ago')" >> "$GITHUB_OUTPUT"

# Note there is "Caches" section in Actions->Management
- name: ccache
uses: actions/cache@v4
with:
# 'CCACHE_DIR' in https://manpages.ubuntu.com/manpages/noble/man1/ccache.1.html
# Max GitHub storage for this is 10G. Dunno what happens if a
# _single_ cache entry/key is bigger than 10G? ccache max_size is
# 5G, so we're good. Typical kernel compilation seems to use ~1G?
path: ~/.cache/ccache/

# The kernel takes MUCH longer than ndctl or anything else, so
# index the cache only based on the kernel version to keep
# things simple. But: invalidate and refresh .ccache weekly
# to regularly adjust to any .config, toolchain, ndctl, .dpkg
# upgrade or any other escaping change.
key: ${{ matrix.cfg.os }}_${{ matrix.arch }}_${{ steps.kernel_checkout.outputs.ref }}_${{ steps.weeks.outputs.now }}
# Don't start new week from scratch if available
restore-keys: |
${{ matrix.cfg.os }}_${{ matrix.arch }}_${{ steps.kernel_checkout.outputs.ref }}_${{ steps.weeks.outputs.previous }}

- name: defconfig
run: cd kernel &&
make defconfig ARCH=${{ matrix.arch }}
Expand All @@ -109,10 +136,20 @@ jobs:

- name: build
run: |
set -x
mkosi --version
ccache --show-stats
cd kernel
PATH=/usr/lib/ccache:"$PATH" \
distro=${{ matrix.cfg.img_distro }} rev=${{ matrix.cfg.img_rel }} \
ndctl='${{ github.workspace }}'/ndctl \
../run_qemu/run_qemu.sh -v --no-run ${{ matrix.run_opts }}

- name: ccache stats post build
run: |
# Pre-build stats printed at the start of the build step
set -x
ccache --show-stats
ccache --show-config | grep dir

# TODO: drop --no-run thanks to "nested KVM" or something?