|
9 | 9 |
|
10 | 10 | env: |
11 | 11 | BUILD_TYPE: Release |
| 12 | + # GitHub runners reinstall toolchains under changing file mtimes. Hashing |
| 13 | + # compiler contents and normalizing the checkout directory makes ccache |
| 14 | + # reusable across runs while still invalidating on a real compiler change. |
| 15 | + CCACHE_BASEDIR: ${{ github.workspace }} |
| 16 | + CCACHE_COMPILERCHECK: content |
| 17 | + CCACHE_COMPRESS: "true" |
| 18 | + CCACHE_MAXSIZE: 2G |
| 19 | + CCACHE_NOHASHDIR: "true" |
12 | 20 |
|
13 | 21 | jobs: |
14 | 22 | build: |
|
30 | 38 | steps: |
31 | 39 | - uses: actions/checkout@v4 |
32 | 40 |
|
33 | | - # ========== 缓存:ccache(Linux) ========== |
34 | | - - name: Cache ccache (Linux) |
35 | | - if: runner.os == 'Linux' |
36 | | - uses: actions/cache@v4 |
37 | | - with: |
38 | | - path: ~/.cache/ccache |
39 | | - key: ${{ runner.os }}-ccache-${{ github.sha }} |
40 | | - restore-keys: | |
41 | | - ${{ runner.os }}-ccache- |
42 | | -
|
43 | | - # ========== 缓存:ccache(Windows) ========== |
44 | | - - name: Cache ccache (Windows) |
45 | | - if: runner.os == 'Windows' |
46 | | - uses: actions/cache@v4 |
47 | | - with: |
48 | | - path: C:\Users\runneradmin\AppData\Local\ccache |
49 | | - key: ${{ runner.os }}-ccache-${{ github.sha }} |
50 | | - restore-keys: | |
51 | | - ${{ runner.os }}-ccache- |
52 | | -
|
53 | 41 | # 注意:不缓存整个 build 目录——旧 CMakeCache.txt 会跨运行携带已移除的 |
54 | 42 | # -D 设置(如历史上的 CMAKE_CXX_FLAGS=-stdlib=libc++),导致编译/链接 |
55 | 43 | # 标准库 ABI 不匹配(std::__cxx11::* 未定义)。编译产物由 ccache 缓存。 |
@@ -132,6 +120,23 @@ jobs: |
132 | 120 | $llvmPath = "C:\Program Files\LLVM\bin" |
133 | 121 | echo "$llvmPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
134 | 122 |
|
| 123 | + # 两边工具链安装完成后统一挂载 ccache。由 action 自己管理平台的默认 |
| 124 | + # CCACHE_DIR、restore/save 与统计,避免手写 runner 路径漂移。 |
| 125 | + - name: Mount ccache |
| 126 | + uses: hendrikmuhs/ccache-action@v1.2 |
| 127 | + with: |
| 128 | + key: ${{ runner.os }}-ccache-v2-release-clang |
| 129 | + restore-keys: | |
| 130 | + ${{ runner.os }}-ccache-v2- |
| 131 | + ${{ runner.os }}-ccache- |
| 132 | + max-size: 2G |
| 133 | + verbose: 1 |
| 134 | + |
| 135 | + - name: Inspect ccache mount |
| 136 | + run: | |
| 137 | + ccache --show-stats --verbose |
| 138 | + ccache --zero-stats |
| 139 | +
|
135 | 140 | # ========== Windows: 缓存 Vulkan SDK(避免重复下载安装) ========== |
136 | 141 | - name: Cache Vulkan SDK (Windows) |
137 | 142 | id: cache-vulkan-windows |
@@ -210,6 +215,9 @@ jobs: |
210 | 215 | - name: Build |
211 | 216 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} |
212 | 217 |
|
| 218 | + - name: Report ccache usage |
| 219 | + run: ccache --show-stats --verbose |
| 220 | + |
213 | 221 | # ========== 真跑测试(roadmap P0-1)========== |
214 | 222 | # 需 Vulkan 的用例在无 GPU 的 runner 上按退出码 77 记 skip(非失败)。 |
215 | 223 | - name: Test ctest (Linux) |
|
0 commit comments