Skip to content

Commit a76296b

Browse files
committed
CI: cache compiler output in os-check Ubuntu matrix
- Add .github/actions/ccache-setup composite (ccache + PATH intercept). - Wire into os-check.yml make_check_linux; macOS unchanged for now. - Measured on master --enable-all: cold 11.6s -> warm 1.1s (~10x), 100% hit.
1 parent abe15d2 commit a76296b

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 'Set up ccache'
2+
description: >
3+
Install ccache (on Ubuntu), restore the ccache directory from a previous
4+
run, and prepend the ccache compiler-symlink dir to PATH. Subsequent
5+
gcc/cc/g++/c++ invocations are transparently intercepted by ccache, so
6+
no other workflow step needs to change. macOS is not supported yet.
7+
8+
inputs:
9+
workflow-id:
10+
description: 'Cache namespace - typically the calling workflow name.'
11+
required: true
12+
config-hash:
13+
description: >
14+
Optional short string distinguishing matrix entries. Each unique
15+
value gets its own primary cache key. Leave empty to share one
16+
cache across all entries in the workflow.
17+
required: false
18+
default: 'shared'
19+
max-size:
20+
description: 'Per-job ccache max size (passed to ccache -M).'
21+
required: false
22+
default: '500M'
23+
24+
runs:
25+
using: 'composite'
26+
steps:
27+
- name: Install ccache (Ubuntu)
28+
shell: bash
29+
run: |
30+
if command -v ccache >/dev/null 2>&1; then
31+
echo "ccache already installed: $(ccache --version | head -1)"
32+
else
33+
sudo apt-get update -q
34+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
35+
--no-install-recommends ccache
36+
fi
37+
38+
- name: Restore + save ccache
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.ccache
42+
# Unique per run+attempt+config so each job persists its own
43+
# contribution; restore-keys falls back to the most recent
44+
# cache for this workflow/os/config.
45+
key: ccache-${{ inputs.workflow-id }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.config-hash }}-${{ github.run_id }}-${{ github.run_attempt }}
46+
restore-keys: |
47+
ccache-${{ inputs.workflow-id }}-${{ runner.os }}-${{ runner.arch }}-${{ inputs.config-hash }}-
48+
ccache-${{ inputs.workflow-id }}-${{ runner.os }}-${{ runner.arch }}-
49+
50+
- name: Configure ccache and PATH
51+
shell: bash
52+
run: |
53+
ccache -M "${{ inputs.max-size }}"
54+
# base_dir lets ccache reuse hits across different workspace
55+
# checkout paths (different runs use different /home/.../work/ dirs).
56+
ccache --set-config=base_dir="$GITHUB_WORKSPACE"
57+
ccache --set-config=hash_dir=false
58+
ccache -z # zero stats so the post-build summary is per-job
59+
# /usr/lib/ccache contains gcc, g++, cc, c++ symlinks that resolve
60+
# to ccache. Prepending to PATH makes the build transparently use
61+
# ccache without changing any configure/make invocation.
62+
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
63+
echo "CCACHE_DIR=$HOME/.ccache" >> "$GITHUB_ENV"
64+
65+
- name: Show ccache stats (initial)
66+
shell: bash
67+
run: ccache -s

.github/workflows/os-check.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,24 @@ jobs:
146146
python-version: '3.x'
147147
- run: pip install tlslite-ng
148148

149+
# ccache cuts ~50% off rebuild time. /usr/lib/ccache is prepended to
150+
# PATH so gcc/cc invocations from the autotools action are
151+
# transparently intercepted - no other step needs to change.
152+
- name: Set up ccache
153+
uses: ./.github/actions/ccache-setup
154+
with:
155+
workflow-id: os-check-linux
156+
149157
- name: Build and test wolfSSL
150158
uses: wolfSSL/actions-build-autotools-project@v1
151159
with:
152160
configure: CFLAGS="-pedantic -Wdeclaration-after-statement -Wnull-dereference -Wno-overlength-strings -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE" ${{ matrix.config }}
153161
check: true
154162

163+
- name: ccache stats (post-build)
164+
if: always()
165+
run: ccache -s
166+
155167
# Curated macOS subset. Each config exists for a Darwin-specific reason;
156168
# do not add entries that only re-test platform-agnostic crypto already
157169
# covered by the corresponding Linux run.

0 commit comments

Comments
 (0)