Skip to content

Commit 1049872

Browse files
authored
Merge pull request #500 from SCOREC/apw/ci-ccache
add ccache to Github CI
2 parents e13e1e7 + 03ef7cf commit 1049872

3 files changed

Lines changed: 142 additions & 16 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Cleanup caches on closed PRs
2+
# From https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
3+
on:
4+
pull_request:
5+
types: [ closed ]
6+
jobs:
7+
cleanup:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
actions: write
11+
steps:
12+
- name: Cleanup
13+
run: |
14+
echo "Fetching list of cache keys"
15+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
16+
17+
## Setting this to not fail the workflow while deleting cache keys.
18+
set +e
19+
echo "Deleting caches..."
20+
for cacheKey in $cacheKeysForPR
21+
do
22+
gh cache delete $cacheKey
23+
done
24+
echo "Done"
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
GH_REPO: ${{ github.repository }}
28+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/cmake.yml

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ on:
44
branches: [ develop ]
55
pull_request:
66
branches: [ develop ]
7+
paths:
8+
- .github/workflows/cmake.yml
9+
- .gitmodules
10+
- '**/CMakeLists.txt'
11+
- '**/*.cmake'
12+
- '**/*.in'
13+
- '**/*.h'
14+
- '**/*.c'
15+
- '**/*.cc'
16+
- '**/*.cpp'
17+
- '**/*.f'
718
jobs:
819
build:
920
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
@@ -18,6 +29,18 @@ jobs:
1829
no_mpi: [OFF, ON]
1930
cxx_standard: [11, 20]
2031
metis: [OFF, ON]
32+
exclude:
33+
- compiler: { name: LLVM }
34+
build_type: Release
35+
- cxx_standard: 20
36+
build_type: Release
37+
env:
38+
CCACHE_DIR: ${{github.workspace}}/.ccache
39+
CCACHE_BASEDIR: ${{github.workspace}}
40+
CCACHE_COMPRESS: true
41+
CCACHE_MAXSIZE: 100M
42+
CMAKE_C_COMPILER_LAUNCHER: ccache
43+
CMAKE_CXX_COMPILER_LAUNCHER: ccache
2144

2245
steps:
2346
- uses: actions/checkout@v4
@@ -32,6 +55,31 @@ jobs:
3255
if: matrix.metis == 'ON'
3356
run: sudo apt install libmetis-dev
3457

58+
- name: setup ccache
59+
id: setup-ccache
60+
run: |
61+
sudo apt-get install ccache
62+
ccache -p # Print ccache config
63+
echo timestamp=$(date -u '+%Y-%m-%dT%T') >> "$GITHUB_OUTPUT"
64+
65+
- name: ccache
66+
uses: actions/cache@v4
67+
with:
68+
path: ${{github.workspace}}/.ccache
69+
key: "${{matrix.compiler.name}}-\
70+
cxx:${{matrix.cxx_standard}}-\
71+
${{matrix.build_type}}-\
72+
nompi:${{matrix.no_mpi}}-\
73+
ccache-${{steps.setup-ccache.outputs.timestamp}}"
74+
restore-keys: "${{matrix.compiler.name}}-\
75+
cxx:${{matrix.cxx_standard}}-\
76+
${{matrix.build_type}}-\
77+
nompi:${{matrix.no_mpi}}-\
78+
ccache-"
79+
80+
- name: Clear ccache statistics
81+
run: ccache -z
82+
3583
- name: Configure CMake
3684
env:
3785
MPICH_CXX: ${{matrix.compiler.CXX}}
@@ -53,23 +101,26 @@ jobs:
53101
env:
54102
MPICH_CXX: ${{matrix.compiler.CXX}}
55103
MPICH_CC: ${{matrix.compiler.CC}}
56-
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j --target install
104+
run: cmake --build ${{github.workspace}}/build --target install
57105

58106
- name: Test
59107
env:
60108
MPICH_CXX: ${{matrix.compiler.CXX}}
61109
MPICH_CC: ${{matrix.compiler.CC}}
62110
working-directory: ${{github.workspace}}/build
63-
run: ctest --output-on-failure -C ${{matrix.build_type}}
111+
run: ctest --output-on-failure
64112

65113
- name: Build User Project
66114
# only need to test with a single build config if the installed cmake config files work
67115
if: matrix.compiler.name == 'GNU' && matrix.build_type == 'Release'
68116
env:
69117
MPICH_CXX: ${{matrix.compiler.CXX}}
70118
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
119+
run: >
120+
cmake
121+
-S ${{github.workspace}}/doc -B ${{github.workspace}}/buildExample
122+
-DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx
123+
-DSCOREC_PREFIX=${{github.workspace}}/build/install ;
73124
cmake --build ${{github.workspace}}/buildExample
74125
75126
- name: Build MPI-NoMPI Example
@@ -81,10 +132,17 @@ jobs:
81132
MPICH_CXX: ${{matrix.compiler.CXX}}
82133
MPICH_CC: ${{matrix.compiler.CC}}
83134
run: >
84-
cmake -S ${{github.workspace}}/example/mpi-nompi
135+
cmake
136+
-S ${{github.workspace}}/example/mpi-nompi
85137
-B ${{github.workspace}}/example/mpi-nompi/build
86-
-DCMAKE_CXX_COMPILER=mpicxx
138+
-DCMAKE_C_COMPILER=mpicxx -DCMAKE_CXX_COMPILER=mpicxx
87139
-DSCOREC_PREFIX=${{github.workspace}}/build/install ;
88140
cmake --build ${{github.workspace}}/example/mpi-nompi/build ;
89141
ctest --test-dir ${{github.workspace}}/example/mpi-nompi/build
90142
--output-on-failure
143+
144+
- name: CCache statistics and recompression
145+
run: |
146+
ccache -sv
147+
ccache -X 5
148+

.github/workflows/python-api-test.yml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,57 @@ jobs:
1313
env:
1414
PYTHONPATH: ${{ github.workspace }}/build/python_wrappers
1515
LD_LIBRARY_PATH: ${{ github.workspace }}/libs/install/lib:${LD_LIBRARY_PATH}
16+
CCACHE_DIR: ${{github.workspace}}/.ccache
17+
CCACHE_BASEDIR: ${{github.workspace}}
18+
CCACHE_COMPRESS: true
19+
CCACHE_MAXSIZE: 100M
20+
CMAKE_C_COMPILER_LAUNCHER: ccache
21+
CMAKE_CXX_COMPILER_LAUNCHER: ccache
1622

1723
steps:
1824
- name: Checkout repository
1925
uses: actions/checkout@v3
2026

27+
- name: setup cache timestamp
28+
id: setup-cache
29+
run: |
30+
echo timestamp=$(date -u '+%Y-%m-%dT%T') >> "$GITHUB_OUTPUT"
31+
32+
- name: Cache pip
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.cache/pip
36+
key: "pyapi-pip-${{steps.setup-cache.outputs.timestamp}}"
37+
restore-keys: pyapi-pip-
38+
2139
- name: Install dependencies
2240
run: |
2341
sudo apt-get update
24-
sudo apt-get install -y cmake mpich build-essential libbz2-dev
42+
sudo apt-get install -y mpich libbz2-dev ccache
43+
mkdir -p /opt/ccache/libexec
44+
ln -s $(which ccache) /opt/ccache/libexec/gcc
45+
ln -s $(which ccache) /opt/ccache/libexec/g++
46+
ln -s $(which ccache) /opt/ccache/libexec/cc
47+
ln -s $(which ccache) /opt/ccache/libexec/c++
2548
pip3 install mpi4py
26-
49+
50+
- name: ccache
51+
uses: actions/cache@v4
52+
with:
53+
path: ${{github.workspace}}/.ccache
54+
key: "pyapi-ccache-${{steps.setup-cache.outputs.timestamp}}"
55+
restore-keys: "pyapi-ccache-"
56+
57+
- name: Clear ccache statistics
58+
run: |
59+
ccache -p # Print ccache config
60+
ccache -z
61+
2762
- name: Build SWIG
2863
run: |
2964
git clone https://github.com/swig/swig.git
3065
cd swig
66+
export PATH=/opt/ccache/libexec:$PATH
3167
./autogen.sh
3268
./configure --prefix=${{ github.workspace }}/libs/install
3369
make
@@ -56,10 +92,9 @@ jobs:
5692
5793
- name: Build Zoltan from Trilinos (minimal)
5894
run: |
59-
git clone https://github.com/trilinos/Trilinos.git
60-
mkdir build-zoltan
61-
cd build-zoltan
62-
cmake ../Trilinos \
95+
git clone --depth 1 https://github.com/trilinos/Trilinos.git
96+
cmake -S Trilinos -B build-zoltan \
97+
-GNinja \
6398
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/libs/install \
6499
-DTPL_ENABLE_MPI:BOOL=ON \
65100
-DCMAKE_C_FLAGS="-O3 -fPIC" \
@@ -71,12 +106,12 @@ jobs:
71106
-DZoltan_ENABLE_ParMETIS:BOOL=ON \
72107
-DParMETIS_INCLUDE_DIRS=${{ github.workspace }}/libs/install \
73108
-DParMETIS_LIBRARY_DIRS=${{ github.workspace }}/libs/install
74-
make
75-
make install
109+
cmake --build build-zoltan -t install
76110
77111
- name: Configure PUMI
78112
run: |
79113
cmake -S . -B build \
114+
-GNinja \
80115
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build/install \
81116
-DCMAKE_C_COMPILER=mpicc \
82117
-DCMAKE_CXX_COMPILER=mpicxx \
@@ -93,11 +128,16 @@ jobs:
93128
-DPARMETIS_PREFIX=${{ github.workspace }}/libs/install \
94129
-DENABLE_SIMMETRIX=OFF
95130
96-
- name: Build and install
131+
- name: Build and install PUMI
97132
run: |
98-
cmake --build build -j 4 --target install
133+
cmake --build build --target install
99134
100135
- name: Run Python test
101136
working-directory: ${{github.workspace}}/python_wrappers
102137
run: |
103138
python3 test_pyCore.py -g input/cube.dmg -m input/cube.smb
139+
140+
- name: Ccache statistics and recompression
141+
run: |
142+
ccache -sv
143+
ccache -X 5

0 commit comments

Comments
 (0)