Skip to content

Commit

Permalink
ci: fail Ubuntu CI if there are compiler warnings
Browse files Browse the repository at this point in the history
Add a [`CMakePresets.json`][1] file that contains `ci-ubuntu` preset.
This preset contains most of the recommended compiler warnings from the
[`cmake-init`][2] project.

However, I had to remove the `-Wdouble-promotion` and
`-Werror=float-equal` flags since there are issues within the GTest
headers.

For compatibility with g++-7, `-Wextra-semi` was removed.

I also had to remove some of the following flags like:
`-fstack-protector-strong -fstack-clash-protection`.
These flags cause errors in Clang v10 (still run in CI), and to be
honest, with stuff like address sanitizer, we probably don't need them.

[1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
[2]: https:/friendlyanon/cmake-init/blob/aa42211c79ab5117b05a2d9f795427f078a0a3d5/cmake-init/templates/common/CMakePresets.json#L88
  • Loading branch information
aloisklink committed Sep 1, 2023
1 parent 683883b commit 209d67a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build-ubuntu-20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ jobs:
sudo apt-get update --fix-missing
sudo apt install -y ${{ matrix.compiler.pkg }}-${{ matrix.compiler.version }}
- name: Compile tests
working-directory: build
env:
CXX: ${{ matrix.compiler.exe }}-${{ matrix.compiler.version }}
run: |
cmake ${{ matrix.mode }} -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF ..
make -j2
cmake ${{ matrix.mode }} --preset ci-ubuntu
cmake --build build/ --parallel 2
- name: Run tests
working-directory: build
env:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build-ubuntu-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ jobs:
sudo apt-get update --fix-missing
sudo apt install -y ${{ matrix.compiler.pkg }}-${{ matrix.compiler.version }}
- name: Compile tests
working-directory: build
env:
CXX: ${{ matrix.compiler.exe }}-${{ matrix.compiler.version }}
run: |
cmake ${{ matrix.mode }} -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF ..
make -j2
cmake ${{ matrix.mode }} --preset ci-ubuntu
cmake --build build/ --parallel 2
- name: Run tests
working-directory: build
env:
Expand Down
59 changes: 59 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 13,
"patch": 0
},
"configurePresets": [
{
"name": "cmake-pedantic",
"description": "Enables all CMake warnings.`",
"hidden": true,
"warnings": {
"dev": true,
"deprecated": true,
"uninitialized": true,
"unusedCli": true,
"systemVars": false
}
},
{
"name": "dev-mode",
"hidden": true,
"description": "Common (non-OS specific) mode for development",
"inherits": "cmake-pedantic",
"cacheVariables": {
"BUILD_TESTING": true,
"libuv_buildtests": false
}
},
{
"name": "flags-linux",
"hidden": true,
"description": "Compiler flags for GNU and Clang compilers. When compiling in DEBUG mode, all warnings will be converted into errors.",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wimplicit-fallthrough -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast",
"CMAKE_CXX_FLAGS_DEBUG": "-Werror"
}
},
{
"name": "ci-linux",
"generator": "Unix Makefiles",
"hidden": true,
"inherits": ["flags-linux"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "ci-build",
"binaryDir": "${sourceDir}/build",
"hidden": true
},
{
"name": "ci-ubuntu",
"inherits": ["ci-build", "ci-linux", "dev-mode"]
}
]
}

0 comments on commit 209d67a

Please sign in to comment.