Skip to content

Commit 161069b

Browse files
committed
add ccache to Github CI
- add ccache config in jobs.build.env. - limit cache size to 200mb for now. - compression can also be recomputed at the end with -X - add ccache setup and ccache action (not sure if I will need to change to explicit restore/save). - add CMake ccache argument to config for normal build and examples. - remove --config from the build step because ninja is a single config builder. - reflow strings for the example projects - for mpi-nompi example set c_compiler to be safe. Signed-off-by: Aiden Woodruff <woodra@rpi.edu>
1 parent a1df7b8 commit 161069b

1 file changed

Lines changed: 48 additions & 7 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ jobs:
1818
no_mpi: [OFF, ON]
1919
cxx_standard: [11, 20]
2020
metis: [OFF, ON]
21+
env:
22+
CCACHE_DIR: ${{github.workspace}}
23+
CCACHE_BASEDIR: ${{github.workspace}}/.ccache
24+
CCACHE_COMPRESS: true
25+
CCACHE_MAXSIZE: 200M
2126

2227
steps:
2328
- uses: actions/checkout@v4
@@ -32,6 +37,21 @@ jobs:
3237
if: matrix.metis == 'ON'
3338
run: sudo apt install libmetis-dev
3439

40+
- name: setup ccache
41+
id: setup-ccache
42+
run: |
43+
sudo apt install ccache
44+
ccache -p # Print ccache config
45+
ccache -z # Zero ccache statistics
46+
echo ::set-output name=key::$(date -u '+%Y-%m-%dT%T')
47+
48+
- name: ccache
49+
uses: actions/cache@v4
50+
with:
51+
path: ${{github.workspace}}/.ccache
52+
key: ${{matrix.compiler.name}}-ccache-${{steps.setup-ccache.outputs.timestamp}}
53+
restore-keys: ${{matrix.compiler.name}}-ccache-
54+
3555
- name: Configure CMake
3656
env:
3757
MPICH_CXX: ${{matrix.compiler.CXX}}
@@ -41,6 +61,8 @@ jobs:
4161
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install
4262
-GNinja -DCMAKE_VERBOSE_MAKEFILE=ON
4363
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
64+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
65+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
4466
-DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_C_COMPILER=mpicc
4567
-DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}}
4668
-DSCOREC_CXX_WARNINGS=ON
@@ -53,7 +75,10 @@ jobs:
5375
env:
5476
MPICH_CXX: ${{matrix.compiler.CXX}}
5577
MPICH_CC: ${{matrix.compiler.CC}}
56-
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j --target install
78+
run: |
79+
cmake
80+
--build ${{github.workspace}}/build
81+
--target install
5782
5883
- name: Test
5984
env:
@@ -68,8 +93,16 @@ jobs:
6893
env:
6994
MPICH_CXX: ${{matrix.compiler.CXX}}
7095
MPICH_CC: ${{matrix.compiler.CC}}
71-
run: |
72-
cmake -S ${{github.workspace}}/doc -B ${{github.workspace}}/buildExample -DCMAKE_CXX_COMPILER=mpicxx -DSCOREC_PREFIX=${{github.workspace}}/build/install
96+
run: >
97+
cmake
98+
-S ${{github.workspace}}/doc
99+
-B ${{github.workspace}}/buildExample
100+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
101+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
102+
-DCMAKE_C_COMPILER=mpicc
103+
-DCMAKE_CXX_COMPILER=mpicxx
104+
-DSCOREC_PREFIX=${{github.workspace}}/build/install
105+
;
73106
cmake --build ${{github.workspace}}/buildExample
74107
75108
- name: Build MPI-NoMPI Example
@@ -81,10 +114,18 @@ jobs:
81114
MPICH_CXX: ${{matrix.compiler.CXX}}
82115
MPICH_CC: ${{matrix.compiler.CC}}
83116
run: >
84-
cmake -S ${{github.workspace}}/example/mpi-nompi
85-
-B ${{github.workspace}}/example/mpi-nompi/build
86-
-DCMAKE_CXX_COMPILER=mpicxx
87-
-DSCOREC_PREFIX=${{github.workspace}}/build/install ;
117+
cmake
118+
-S ${{github.workspace}}/example/mpi-nompi
119+
-B ${{github.workspace}}/example/mpi-nompi/build
120+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
121+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
122+
-DCMAKE_C_COMPILER=mpicxx
123+
-DCMAKE_CXX_COMPILER=mpicxx
124+
-DSCOREC_PREFIX=${{github.workspace}}/build/install
125+
;
88126
cmake --build ${{github.workspace}}/example/mpi-nompi/build ;
89127
ctest --test-dir ${{github.workspace}}/example/mpi-nompi/build
90128
--output-on-failure
129+
130+
- name: CCache statistics
131+
run: cmake -sv

0 commit comments

Comments
 (0)