Skip to content

Commit 8fb5bac

Browse files
committed
Update ci.yml to run on the latest ubuntu image and enable -fsanitize.
Also enables -Werror and -Wno-error=pedantic so that new warnings cause a failed CI build. This includes FORTIFY_SOURCE warnings.
1 parent 1a647bf commit 8fb5bac

File tree

1 file changed

+47
-13
lines changed

1 file changed

+47
-13
lines changed

.github/workflows/ci.yml

+47-13
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,68 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
unittest:
11+
unittests-sanitizer:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Clone This Repo
1515
uses: actions/checkout@v2
16-
- name: Build
16+
- name: Build with Sanitizers
1717
run: |
18-
sudo apt-get install -y lcov
19-
cmake -S test -B build/ \
18+
sudo apt-get install -y cmake lcov
19+
CFLAGS=" -O0 -Wall -Wextra"
20+
CFLAGS+=" -Werror -Wno-error=pedantic"
21+
CFLAGS+=" -D_FORTIFY_SOURCE=2"
22+
CFLAGS+=" -Wformat"
23+
CLFAGS+=" -Wformat-security"
24+
CFLAGS+=" -Warray-bounds"
25+
CFLAGS+=" -fsanitize=address,undefined"
26+
CFLAGS+=" -fsanitize=pointer-compare -fsanitize=pointer-subtract"
27+
CFLAGS+=" -fsanitize-recover=undefined"
28+
CFLAGS+=" -fsanitize-address-use-after-scope"
29+
CFLAGS+=" -fsanitize-undefined-trap-on-error"
30+
CFLAGS_=" -fstack-protector-all"
31+
cmake -S test -B build \
2032
-G "Unix Makefiles" \
2133
-DCMAKE_BUILD_TYPE=Debug \
22-
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG'
23-
make -C build/ all
24-
- name: Test
34+
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
35+
-DCMAKE_C_FLAGS="${CFLAGS}"
36+
make -C build all
37+
- name: Run Tests with Sanitizers
2538
run: |
26-
cd build/
39+
cd build
40+
make coverage
2741
ctest -E system --output-on-failure
2842
cd ..
29-
- name: Run Coverage
43+
unittests-coverage:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Clone This Repo
47+
uses: actions/checkout@v2
48+
- name: Build Tests for Coverage
3049
run: |
31-
make -C build/ coverage
50+
CFLAGS=" --coverage -O0 -Wall -Wextra"
51+
CFLAGS+=" -Werror -Wno-error=pedantic"
52+
CFLAGS+=" -DFORTIFY_SOURCE=0"
53+
CFLAGS+=" -DNDEBUG"
54+
cmake -S test -B build_cov \
55+
-G "Unix Makefiles" \
56+
-DCMAKE_BUILD_TYPE=Debug \
57+
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
58+
-DCMAKE_C_FLAGS="${CFLAGS}"
59+
make -C build_cov all
60+
- name: Run Tests for Coverage
61+
run: |
62+
cd build_cov
63+
make coverage
64+
ctest -E system --output-on-failure
65+
cd ..
3266
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*3rdparty\*")
33-
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
34-
lcov --rc lcov_branch_coverage=1 --list build/coverage.info
67+
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build_cov/coverage.info -o build_cov/coverage.info
68+
lcov --rc lcov_branch_coverage=1 --list build_cov/coverage.info
3569
- name: Check Coverage
3670
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
3771
with:
38-
path: ./build/coverage.info
72+
path: ./build_cov/coverage.info
3973
complexity:
4074
runs-on: ubuntu-latest
4175
steps:

0 commit comments

Comments
 (0)