1010 - ' CMakeLists.txt'
1111 - ' CMakePresets.json'
1212 - ' .github/workflows/ci.yml'
13+
14+ pull_request :
15+ branches : [ master ]
16+ paths :
17+ - ' **/*.cpp'
18+ - ' **/*.hpp'
19+ - ' cmake/**'
20+ - ' CMakeLists.txt'
21+ - ' CMakePresets.json'
22+ - ' .github/workflows/ci.yml'
23+
1324 workflow_dispatch :
1425
1526jobs :
@@ -21,52 +32,56 @@ jobs:
2132 os : [ubuntu-latest]
2233 compiler : [gcc, clang]
2334 build_type : [Sanitize, Release]
35+ env :
36+ CMAKE_C_COMPILER_LAUNCHER : ccache
37+ CMAKE_CXX_COMPILER_LAUNCHER : ccache
38+ CCACHE_DIR : ${{ github.workspace }}/.ccache
2439
2540 steps :
2641 - name : Checkout repository
2742 uses : actions/checkout@v4
2843 with : { fetch-depth: 0 }
2944
30- - name : Install CMake
45+ - name : Cache APT packages
46+ uses : actions/cache@v3
47+ with :
48+ path : /var/cache/apt
49+ key : ${{ runner.os }}-apt-ci-${{ hashFiles('.github/workflows/ci.yml') }}
50+ restore-keys : |
51+ ${{ runner.os }}-apt-ci-
52+
53+ - name : Install CMake and Ninja
3154 uses : lukka/get-cmake@latest
55+ with :
56+ cmakeVersion : ^3.28.0
57+ ninjaVersion : ^1.11.0
3258
33- - name : Install build tools
34- run : sudo apt update && sudo apt install -y clang lld gcc g++ ccache ninja-build
59+ - name : Install dependencies
60+ run : |
61+ sudo apt-get -qq update
62+ sudo apt-get -qq install -y clang lld gcc g++ ccache --no-install-recommends
3563
36- - name : Restore ccache
64+ - name : Cache ccache
3765 uses : actions/cache@v3
3866 with :
3967 path : ${{ github.workspace }}/.ccache
40- key : ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}
68+ key : ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ hashFiles('CMakeLists.txt') }}
69+ restore-keys : |
70+ ${{ runner.os }}-ccache-
4171
42- - name : Restore build directory
72+ - name : Cache build directory
4373 uses : actions/cache@v3
4474 with :
45- path : build/${{ matrix.compiler }}-${{ matrix.build_type }}
46- key : ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}
75+ path : build/
76+ key : ${{ runner.os }}-build-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ github.sha }}
77+ restore-keys : |
78+ ${{ runner.os }}-build-
4779
4880 - name : Configure with CMake Preset
49- env :
50- CCACHE_DIR : ${{ github.workspace }}/.ccache
51- CMAKE_C_COMPILER_LAUNCHER : ccache
52- CMAKE_CXX_COMPILER_LAUNCHER : ccache
5381 run : cmake --preset ${{ matrix.compiler }}-${{ matrix.build_type }}
5482
5583 - name : Build (Ninja)
5684 run : cmake --build --preset ${{ matrix.compiler }}-${{ matrix.build_type }}
5785
5886 - name : Run tests (ctest)
5987 run : ctest --preset ${{ matrix.compiler }}-${{ matrix.build_type }}
60-
61- # not sure if next steps are required
62- - name : Save ccache
63- uses : actions/cache@v3
64- with :
65- path : ${{ github.workspace }}/.ccache
66- key : ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}
67-
68- - name : Save build directory
69- uses : actions/cache@v3
70- with :
71- path : build/${{ matrix.compiler }}-${{ matrix.build_type }}
72- key : ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}
0 commit comments