Skip to content

Commit 0a275ff

Browse files
authored
Update ci.yml
1 parent 7b931b3 commit 0a275ff

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,67 @@ on:
66
paths:
77
- '**/*.cpp'
88
- '**/*.hpp'
9-
- 'CMakeLists.txt'
10-
- 'CMakePresets.json'
119
- 'cmake/**'
12-
- '.github/workflows/ci.yml'
13-
pull_request:
14-
branches: [ master ]
15-
paths:
16-
- '**/*.cpp'
17-
- '**/*.hpp'
1810
- 'CMakeLists.txt'
1911
- 'CMakePresets.json'
20-
- 'cmake/**'
2112
- '.github/workflows/ci.yml'
13+
workflow_dispatch:
2214

2315
jobs:
2416
build-and-test:
25-
name: ${{ matrix.build_type }} on ${{ matrix.os }} with ${{ matrix.compiler }}
17+
name: ${{ matrix.compiler }}-${{ matrix.build_type }} on ${{ matrix.os }}
2618
runs-on: ${{ matrix.os }}
2719
strategy:
2820
matrix:
2921
os: [ubuntu-latest]
3022
compiler: [gcc, clang]
31-
build_type: [RelWithDebInfo]
23+
build_type: [Sanitize, Release]
3224

3325
steps:
34-
- name: Checkout code
26+
- name: Checkout repository
3527
uses: actions/checkout@v4
28+
with: { fetch-depth: 0 }
29+
30+
- name: Install CMake
31+
uses: lukka/get-cmake@latest
32+
33+
- name: Install build tools
34+
run: sudo apt update && sudo apt install -y clang lld gcc g++ ccache ninja-build
3635

37-
- name: Set up ${{ matrix.compiler }}
38-
run: |
39-
sudo apt update
40-
sudo apt update && sudo apt install -y cmake ninja-build
41-
if [ "${{ matrix.compiler }}" = "clang" ]; then
42-
sudo apt install -y clang lld
43-
echo "CC=clang" >> $GITHUB_ENV
44-
echo "CXX=clang++" >> $GITHUB_ENV
45-
else
46-
sudo apt install -y g++ gcc
47-
echo "CC=gcc" >> $GITHUB_ENV
48-
echo "CXX=g++" >> $GITHUB_ENV
49-
fi
36+
- name: Restore ccache
37+
uses: actions/cache@v3
38+
with:
39+
path: ${{ github.workspace }}/.ccache
40+
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}
41+
42+
- name: Restore build directory
43+
uses: actions/cache@v3
44+
with:
45+
path: build/${{ matrix.compiler }}-${{ matrix.build_type }}
46+
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}
5047

5148
- 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
5253
run: cmake --preset ${{ matrix.compiler }}-${{ matrix.build_type }}
5354

54-
- name: Build
55+
- name: Build (Ninja)
5556
run: cmake --build --preset ${{ matrix.compiler }}-${{ matrix.build_type }}
5657

57-
- name: Run tests
58+
- name: Run tests (ctest)
5859
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

Comments
 (0)