在每次提交时,我都会在不同的操作系统上构建我的项目。因此,我使用 CMake 作为我的 C++ 代码的构建系统。为了使构建速度更快,我尝试缓存较旧的构建,因此不必重新构建未更改的文件。我编写了以下 GH 动作脚本:
name: Build for MacOS, Ubuntu and Windows
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-11, windows-2022 ]
steps:
- uses: actions/checkout@v2
- name: Cache build
uses: actions/cache@v3
with:
path: ${{github.workspace}}/build
key: ${{ matrix.os }}-build
restore-keys: ${{ matrix.os }}-build
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFORCE_COLORED_OUTPUT=1
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Run Code Online (Sandbox Code Playgroud)
宽度 ...
- name: Cache build
uses: actions/cache@v3
with:
path: ${{github.workspace}}/build
key: ${{ matrix.os }}-build
restore-keys: ${{ matrix.os }}-build
Run Code Online (Sandbox Code Playgroud)
...我尝试缓存所有构建文件写入的目录,但看起来项目每次都完全重建。我做错了什么吗?我将所有日志上传到https://pastebin.com/JLErAPyD
| 归档时间: |
|
| 查看次数: |
1122 次 |
| 最近记录: |