Skip to content

Commit c433f90

Browse files
authored
use ccache for Linux gcc CMake CI builds (cppcheck-opensource#4426)
* modernized some CMake invocations * CI-unixish.yml: use `ccache` for Linux gcc CMake builds * CI-unixish-docker.yml: use `ccache` for Linux gcc CMake builds * CI-unixish-docker.yml: enabled CMake build with tests for more images * CI-unixish-docker.yml: adjusted some step checks
1 parent 31118fd commit c433f90

5 files changed

Lines changed: 51 additions & 38 deletions

File tree

.github/workflows/CI-unixish-docker.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ jobs:
2727
if: matrix.image == 'centos:7'
2828
run: |
2929
yum install -y cmake gcc-c++ make pcre-devel
30+
yum --enablerepo=extras install -y epel-release
31+
yum install -y ccache
3032
3133
- name: Install missing software on ubuntu
32-
if: matrix.image != 'centos:7'
34+
if: contains(matrix.image, 'ubuntu')
3335
run: |
3436
apt-get update
3537
apt-get install -y cmake g++ make libxml2-utils libpcre3-dev
@@ -40,24 +42,40 @@ jobs:
4042
run: |
4143
sudo apt-get install qt5-default
4244
43-
# tests require CMake 3.4
45+
# needs to be called after the package installation since
46+
# - it doesn't call "apt-get update"
47+
# - it doesn't support centos
48+
- name: ccache
49+
uses: hendrikmuhs/[email protected]
50+
if: matrix.image != 'ubuntu:14.04' # no support for --set-config
51+
with:
52+
key: ${{ github.workflow }}-${{ matrix.image }}
53+
54+
# tests require CMake 3.9 - no ccache available
4455
- name: Test CMake build (no tests)
45-
if: matrix.image != 'ubuntu:22.10'
56+
if: matrix.image == 'ubuntu:14.04'
4657
run: |
4758
mkdir cmake.output
4859
cd cmake.output
4960
cmake -G "Unix Makefiles" -DHAVE_RULES=On ..
5061
cmake --build . -- -j$(nproc)
51-
cd ..
62+
63+
# tests require CMake 3.9 - ccache available
64+
- name: Test CMake build (no tests)
65+
if: matrix.image == 'centos:7' || matrix.image == 'ubuntu:16:04'
66+
run: |
67+
mkdir cmake.output
68+
cd cmake.output
69+
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ..
70+
cmake --build . -- -j$(nproc)
5271
5372
- name: Test CMake build
54-
if: matrix.image == 'ubuntu:22.10'
73+
if: matrix.image != 'centos:7' && matrix.image != 'ubuntu:14.04' && matrix.image != 'ubuntu:16.04'
5574
run: |
5675
mkdir cmake.output
5776
cd cmake.output
5877
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On ..
5978
cmake --build . --target check -- -j$(nproc)
60-
cd ..
6179
6280
build_make:
6381

@@ -82,7 +100,7 @@ jobs:
82100
yum install -y ccache
83101
84102
- name: Install missing software on ubuntu
85-
if: matrix.image != 'centos:7'
103+
if: contains(matrix.image, 'ubuntu')
86104
run: |
87105
apt-get update
88106
apt-get install -y g++ make python3 libxml2-utils libpcre3-dev

.github/workflows/CI-unixish.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v2
2222

23+
- name: ccache
24+
uses: hendrikmuhs/[email protected]
25+
if: contains(matrix.os, 'ubuntu')
26+
with:
27+
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
28+
2329
- name: Install missing software on ubuntu
2430
if: contains(matrix.os, 'ubuntu')
2531
run: |
@@ -35,11 +41,8 @@ jobs:
3541
- name: CMake build on ubuntu (with GUI / system tinyxml2)
3642
if: contains(matrix.os, 'ubuntu')
3743
run: |
38-
mkdir cmake.output.tinyxml2
39-
cd cmake.output.tinyxml2
40-
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_BUNDLED_TINYXML2=Off ..
41-
cmake --build . -- -j$(nproc)
42-
cd ..
44+
cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
45+
cmake --build cmake.output.tinyxml2 -- -j$(nproc)
4346
4447
- name: Run CMake test (system tinyxml2)
4548
if: contains(matrix.os, 'ubuntu')
@@ -58,6 +61,12 @@ jobs:
5861
steps:
5962
- uses: actions/checkout@v2
6063

64+
- name: ccache
65+
uses: hendrikmuhs/[email protected]
66+
if: contains(matrix.os, 'ubuntu')
67+
with:
68+
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}
69+
6170
- name: Install missing software on ubuntu
6271
if: contains(matrix.os, 'ubuntu')
6372
run: |
@@ -73,18 +82,14 @@ jobs:
7382
- name: CMake build on ubuntu (with GUI)
7483
if: contains(matrix.os, 'ubuntu')
7584
run: |
76-
mkdir cmake.output
77-
pushd cmake.output
78-
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On ..
79-
cmake --build . -- -j$(nproc)
85+
cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
86+
cmake --build cmake.output -- -j$(nproc)
8087
8188
- name: CMake build on macos (with GUI)
8289
if: contains(matrix.os, 'macos')
8390
run: |
84-
mkdir cmake.output
85-
pushd cmake.output
86-
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DQt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5 ..
87-
cmake --build . -- -j$(nproc)
91+
cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DQt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5
92+
cmake --build cmake.output -- -j$(nproc)
8893
8994
- name: Run CMake test
9095
run: |

.github/workflows/CI-windows.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ jobs:
121121
- name: Build GUI release (CMake)
122122
if: startsWith(matrix.qt_ver, '6') && matrix.arch == 'x64'
123123
run: |
124-
md build || exit /b !errorlevel!
125-
cd build || exit /b !errorlevel!
126-
cmake -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_QT6=On .. || exit /b !errorlevel!
127-
cmake --build . --target cppcheck-gui || exit /b !errorlevel!
124+
cmake -S . -B build -DBUILD_GUI=On -DWITH_QCHART=On -DUSE_QT6=On || exit /b !errorlevel!
125+
cmake --build build --target cppcheck-gui || exit /b !errorlevel!
128126
129127
# TODO: deploy with Qt6
130128

@@ -135,9 +133,7 @@ jobs:
135133
if "${{ matrix.arch }}" == "x86" (
136134
set ARCH=Win32
137135
)
138-
md build || exit /b !errorlevel!
139-
cd build || exit /b !errorlevel!
140-
cmake -DBUILD_TESTS=On .. || exit /b !errorlevel!
136+
cmake -S . -B build -DBUILD_TESTS=On || exit /b !errorlevel!
141137
142138
- name: Build CLI debug configuration using MSBuild
143139
if: matrix.qt_ver == ''

.github/workflows/format.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ jobs:
2828
run: |
2929
wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.72.0.tar.gz
3030
tar xzvf uncrustify-0.72.0.tar.gz && cd uncrustify-uncrustify-0.72.0
31-
mkdir build
32-
cd build
33-
cmake -DCMAKE_BUILD_TYPE=Release ..
34-
cmake --build . -- -j$(nproc) -s
31+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
32+
cmake --build build -- -j$(nproc) -s
3533
mkdir ~/uncrustify
36-
cp uncrustify ~/uncrustify/
34+
cd build && cp uncrustify ~/uncrustify/
3735
3836
- name: Uncrustify check
3937
run: |

.github/workflows/selfcheck.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ jobs:
4545
4646
- name: CMake
4747
run: |
48-
mkdir cmake.output
49-
pushd cmake.output
50-
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On ..
48+
cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On
5149
5250
- name: Generate dependencies
5351
run: |
@@ -69,9 +67,7 @@ jobs:
6967
# the following steps are duplicated from above since setting up the build node in a parallel step takes longer than the actual steps
7068
- name: CMake (no test)
7169
run: |
72-
mkdir cmake.output.notest
73-
pushd cmake.output.notest
74-
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=0 -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On ..
70+
cmake -S . -B cmake.output.notest -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=0 -DBUILD_GUI=ON -DWITH_QCHART=ON -DCMAKE_GLOBAL_AUTOGEN_TARGET=On
7571
7672
- name: Generate dependencies (no test)
7773
run: |

0 commit comments

Comments
 (0)