@@ -81,12 +81,39 @@ jobs:
8181
8282 - name : Install deps (Ubuntu)
8383 if : startsWith(matrix.os, 'ubuntu')
84- run : sudo apt-get update && sudo apt-get install -y zlib1g-dev
84+ run : sudo apt-get update && sudo apt-get install -y zlib1g-dev ccache
85+
86+ - name : Install ccache (macOS)
87+ if : startsWith(matrix.os, 'macos')
88+ run : command -v ccache >/dev/null 2>&1 || brew install ccache
89+
90+ # Verified compiler cache: CCACHE_COMPILERCHECK=content keys every entry
91+ # on the compiler-binary CONTENT plus the fully preprocessed input, so a
92+ # hit is provably the identical compilation — a stale or foreign cache
93+ # can only miss, never return wrong output (see scripts/env.sh).
94+ # Keys embed github.ref on top of GitHub's own branch scoping: caches are
95+ # STRICTLY per-ref by policy — no base-branch fallback, a new PR builds
96+ # cold once and only its own pushes warm it.
97+ - name : Compiler cache (content-verified)
98+ uses : actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
99+ with :
100+ path : ${{ github.workspace }}/.ccache
101+ key : ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-${{ github.sha }}
102+ restore-keys : |
103+ ccache-test-${{ matrix.os }}-${{ matrix.cc }}-${{ github.ref }}-
85104
86105 - name : Test
87106 run : scripts/test.sh CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
88107 env :
89108 CBM_SKIP_PERF : ${{ inputs.skip_perf && '1' || '' }}
109+ CCACHE_DIR : ${{ github.workspace }}/.ccache
110+ CCACHE_MAXSIZE : 1500M
111+
112+ - name : ccache stats
113+ if : always()
114+ run : ccache -s || true
115+ env :
116+ CCACHE_DIR : ${{ github.workspace }}/.ccache
90117
91118 test-tsan :
92119 runs-on : ubuntu-latest
@@ -95,10 +122,33 @@ jobs:
95122 - uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
96123
97124 - name : Install deps (Ubuntu)
98- run : sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
125+ run : sudo apt-get update && sudo apt-get install -y clang zlib1g-dev ccache
126+
127+ - name : Compiler cache (content-verified)
128+ uses : actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
129+ with :
130+ path : ${{ github.workspace }}/.ccache
131+ key : ccache-tsan-${{ github.ref }}-${{ github.sha }}
132+ restore-keys : |
133+ ccache-tsan-${{ github.ref }}-
99134
100135 - name : ThreadSanitizer tests
101- run : make -f Makefile.cbm test-tsan CC=clang CXX=clang++
136+ # This job calls make directly (no env.sh), so route the compilers
137+ # through ccache's Debian masquerade dir; update-ccache-symlinks in the
138+ # ccache postinst has already linked the clang installed above.
139+ run : |
140+ export PATH=/usr/lib/ccache:$PATH
141+ export CCACHE_COMPILERCHECK=content
142+ make -f Makefile.cbm test-tsan CC=clang CXX=clang++
143+ env :
144+ CCACHE_DIR : ${{ github.workspace }}/.ccache
145+ CCACHE_MAXSIZE : 1500M
146+
147+ - name : ccache stats
148+ if : always()
149+ run : ccache -s || true
150+ env :
151+ CCACHE_DIR : ${{ github.workspace }}/.ccache
102152
103153 test-windows :
104154 needs : setup-matrix
@@ -119,6 +169,7 @@ jobs:
119169 mingw-w64-clang-${{ matrix.pkg }}-clang
120170 mingw-w64-clang-${{ matrix.pkg }}-compiler-rt
121171 mingw-w64-clang-${{ matrix.pkg }}-zlib
172+ mingw-w64-clang-${{ matrix.pkg }}-ccache
122173 make
123174 git
124175
@@ -146,6 +197,14 @@ jobs:
146197 Set-Acl -LiteralPath $root -AclObject $acl
147198 "CBM_CI_TEMP_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
148199
200+ - name : Compiler cache (content-verified)
201+ uses : actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
202+ with :
203+ path : ${{ github.workspace }}/.ccache
204+ key : ccache-test-${{ matrix.os }}-${{ matrix.msystem }}-${{ github.ref }}-${{ github.sha }}
205+ restore-keys : |
206+ ccache-test-${{ matrix.os }}-${{ matrix.msystem }}-${{ github.ref }}-
207+
149208 - name : Test
150209 shell : msys2 {0}
151210 # AddressSanitizer is unavailable on native ARM64 Windows (LLVM ships no
@@ -164,6 +223,15 @@ jobs:
164223 scripts/test.sh CC=clang CXX=clang++ ${{ matrix.os == 'windows-11-arm' && 'SANITIZE=' || '' }}
165224 env :
166225 CBM_SKIP_PERF : ${{ inputs.skip_perf && '1' || '' }}
226+ CCACHE_DIR : ${{ github.workspace }}/.ccache
227+ CCACHE_MAXSIZE : 1500M
228+
229+ - name : ccache stats
230+ if : always()
231+ shell : msys2 {0}
232+ run : ccache -s || true
233+ env :
234+ CCACHE_DIR : ${{ github.workspace }}/.ccache
167235
168236 # Windows product-surface regression guards. Distinct from test-windows above
169237 # (the sanitizer C suite): these drive a real product binary + embedded HTTP UI
@@ -186,6 +254,7 @@ jobs:
186254 install : >-
187255 mingw-w64-clang-x86_64-clang
188256 mingw-w64-clang-x86_64-zlib
257+ mingw-w64-clang-x86_64-ccache
189258 make
190259 git
191260
@@ -197,11 +266,22 @@ jobs:
197266 working-directory : pkg/npm
198267 run : npm test
199268
269+ - name : Compiler cache (content-verified)
270+ uses : actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
271+ with :
272+ path : ${{ github.workspace }}/.ccache
273+ key : ccache-guards-${{ github.ref }}-${{ github.sha }}
274+ restore-keys : |
275+ ccache-guards-${{ github.ref }}-
276+
200277 - name : Build product binary with embedded UI
201278 shell : msys2 {0}
202279 # --with-ui builds the frontend (npm) and embeds it, so the drive-picker
203280 # guard's HTTP UI is available. Functional gate only (no sanitizers).
204281 run : scripts/build.sh --with-ui CC=clang CXX=clang++
282+ env :
283+ CCACHE_DIR : ${{ github.workspace }}/.ccache
284+ CCACHE_MAXSIZE : 1500M
205285
206286 - name : Windows regression guards (#636/#357, # 618, #548, #423/#20)
207287 shell : pwsh
0 commit comments