|
6 | 6 | paths: |
7 | 7 | - '**/*.cpp' |
8 | 8 | - '**/*.hpp' |
9 | | - - 'CMakeLists.txt' |
10 | | - - 'CMakePresets.json' |
11 | 9 | - 'cmake/**' |
12 | | - - '.github/workflows/ci.yml' |
13 | | - pull_request: |
14 | | - branches: [ master ] |
15 | | - paths: |
16 | | - - '**/*.cpp' |
17 | | - - '**/*.hpp' |
18 | 10 | - 'CMakeLists.txt' |
19 | 11 | - 'CMakePresets.json' |
20 | | - - 'cmake/**' |
21 | 12 | - '.github/workflows/ci.yml' |
| 13 | + workflow_dispatch: |
22 | 14 |
|
23 | 15 | jobs: |
24 | 16 | build-and-test: |
25 | | - name: ${{ matrix.build_type }} on ${{ matrix.os }} with ${{ matrix.compiler }} |
| 17 | + name: ${{ matrix.compiler }}-${{ matrix.build_type }} on ${{ matrix.os }} |
26 | 18 | runs-on: ${{ matrix.os }} |
27 | 19 | strategy: |
28 | 20 | matrix: |
29 | 21 | os: [ubuntu-latest] |
30 | 22 | compiler: [gcc, clang] |
31 | | - build_type: [RelWithDebInfo] |
| 23 | + build_type: [Sanitize, Release] |
32 | 24 |
|
33 | 25 | steps: |
34 | | - - name: Checkout code |
| 26 | + - name: Checkout repository |
35 | 27 | 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 |
36 | 35 |
|
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 }} |
50 | 47 |
|
51 | 48 | - 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 |
52 | 53 | run: cmake --preset ${{ matrix.compiler }}-${{ matrix.build_type }} |
53 | 54 |
|
54 | | - - name: Build |
| 55 | + - name: Build (Ninja) |
55 | 56 | run: cmake --build --preset ${{ matrix.compiler }}-${{ matrix.build_type }} |
56 | 57 |
|
57 | | - - name: Run tests |
| 58 | + - name: Run tests (ctest) |
58 | 59 | 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