Commit b6c370b6

b6c370b69b72Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

ci: wrap cc with sccache + GitHub Actions cache backend

Adds mozilla-actions/[email protected] to each CI job and wraps the compiler invocation as CC="sccache <cc>". sccache uses GitHub Actions cache as its storage backend (SCCACHE_GHA_ENABLED=true), so per-test .c → .o compiles hit across runs.

Builds on PR #230 (test/bench rules already split into compile + link), which gives sccache the pure-compile invocation pattern it can cache. Without that split, sccache would have classified the combined compile+link calls as non-cacheable and skipped them.

Expected effect on warm cache: per-test cc time drops from "compile + link" to "link only" (object files served from cache), and the bootstrap cc gen1.c -o spinel_codegen also caches when gen1.c hasn't changed. Windows mingw, the bottleneck job at ~388s build+test, should benefit most. Cold cache (first run, or after a spinel_codegen.rb edit invalidates gen1.c) reverts to current timing plus a small action overhead.

A few setup details:

  • Each job ends with sccache --show-stats so the hit/miss rate is visible in CI logs without enabling debug mode. We can use this to decide whether the integration is paying off after a week or two; if hit rate is consistently low the action can be reverted with no other effect on the pipeline.
  • For the Windows job, setup-msys2 is given path-type: inherit so the MSYS2 bash shell sees the Windows-side PATH where sccache.exe was installed by sccache-action. Without this, make would invoke sccache and the shell wouldn't find it.
  • sccache-action runs after setup-msys2 on Windows so the inherited PATH ordering is correct; on POSIX jobs the order doesn't matter.

Cache scoping note: PRs read from the base branch (master) cache read-only and write to their own scope. So a PR that touches spinel_codegen.rb will miss on the bootstrap chain (gen1.c changes) but hit on every test whose generated .c content is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
b6c370b69b72
Parent
43d5c4b693d4

.github/workflows/ci.ymlmodifiedView file

@@ -21,10 +21,21 @@
2121 - os: macos-latest
2222 cc: clang
2323 env:
24- CC: ${{ matrix.cc }}
24+ # `sccache <cc>` wrapper. sccache forwards through to the
25+ # underlying compiler when its cache misses, so this stays
26+ # transparent. `SCCACHE_GHA_ENABLED=true` tells sccache to
27+ # use the GitHub Actions cache as its storage backend (set
28+ # up by the sccache-action step below). PR #230 split the
29+ # test/bench rules into separate compile and link steps so
30+ # the compile step is in sccache's cacheable pattern.
31+ CC: sccache ${{ matrix.cc }}
32+ SCCACHE_GHA_ENABLED: "true"
2533 steps:
2634 - uses: actions/checkout@v6
2735
36+ - name: Set up sccache
37+ uses: mozilla-actions/[email protected]
38+
2839 - name: Set up Ruby
2940 uses: ruby/setup-ruby@v1
3041 with:
@@ -50,6 +61,10 @@
5061 # -j$(...) overlaps the per-test cc invocations.
5162 run: make -j$(getconf _NPROCESSORS_ONLN) test OPT=-O0
5263
64+ - name: sccache stats
65+ if: always()
66+ run: sccache --show-stats
67+
5368 windows-mingw:
5469 name: windows-mingw
5570 runs-on: windows-latest
@@ -57,7 +72,8 @@
5772 run:
5873 shell: msys2 {0}
5974 env:
60- CC: gcc
75+ CC: sccache gcc
76+ SCCACHE_GHA_ENABLED: "true"
6177 steps:
6278 - uses: actions/checkout@v6
6379
@@ -69,6 +85,7 @@
6985 # Reuse the pacman package set across runs — saves ~1m of
7086 # download/install on every job.
7187 cache: true
88+ path-type: inherit
7289 install: >-
7390 base-devel
7491 mingw-w64-x86_64-toolchain
@@ -78,12 +95,20 @@
7895 curl
7996 tar
8097
98+ # Install the sccache binary on the Windows-side PATH; MSYS2
99+ # inherits Windows PATH (path-type: inherit, above) so the
100+ # `sccache` command resolves from the bash shell that make
101+ # invokes.
102+ - name: Set up sccache
103+ uses: mozilla-actions/[email protected]
104+
81105 - name: Show toolchain
82106 run: |
83107 uname -a
84108 gcc --version
85109 ruby --version
86110 make --version | head -1
111+ sccache --version
87112
88113 - name: Fetch libprism sources
89114 run: make deps
@@ -93,3 +118,7 @@
93118
94119 - name: Run tests
95120 run: make -j$(nproc) test OPT=-O0
121+
122+ - name: sccache stats
123+ if: always()
124+ run: sccache --show-stats