【发布时间】:2020-12-12 08:48:05
【问题描述】:
在our C++ project 中,我们设法设置GitHub Actions 使用ccache 构建我们的源代码。
它在 Linux 上运行良好,感谢 ccache,构建在不到 5 分钟的时间内成功。
不幸的是,当尝试在 macOS 上构建时,ccache 似乎不起作用,给出:
cache directory /Users/runner/.ccache
primary config /Users/runner/.ccache/ccache.conf
secondary config (readonly) /usr/local/Cellar/ccache/3.7.11_1/etc/ccache.conf
stats updated Sun Aug 23 11:57:31 2020
cache hit (direct) 0
cache hit (preprocessed) 0
cache miss 7175
cache hit rate 0.00 %
cache file missing 1
cleanups performed 2976
files in cache 165
cache size 422.4 MB
max cache size 500.0 MB
因此,macOS 构建大约需要 40 分钟才能完成。
-
构建示例:https://github.com/azerothcore/azerothcore-wotlk/runs/1018358261
-
这是定义动作的地方:https://github.com/azerothcore/azerothcore-wotlk/blob/master/.github/workflows/core_build.yml
-
整个项目的源代码公开在:https://github.com/azerothcore/azerothcore-wotlk
因此,尽管我尝试以与 ubuntu-* 相同的方式设置 macOS 构建,但我无法让 ccache 正常工作,我不知道为什么。
如何使ccache 也可以与macOS 一起使用?
【问题讨论】:
-
首先记录构建代码时使用的编译器选项。如果 ccache 看到它认为编译器选项意味着构建不能被缓存,它将拒绝缓存构建。
-
您在密钥上使用 GitHub sha。此 sha 将在您执行的每次提交时更改,因此当您尝试获取包含提交哈希的缓存命中时,它总是会丢失。
-
@EdwardRomero 有真正的答案,我想。请照此张贴。另外,Github,请发布此常见用例的配方。即使是非常简单的事情,例如为 repo 的所有分支共享一个 ccache,也可能适合许多项目并为 GH Actions 节省许多周期。
标签: c++ macos github-actions azerothcore ccache