Skip to content

Commit a342513

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 98327e8 commit a342513

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

.github/workflows/ci.yml

+41-12
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,58 @@ jobs:
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=" --coverage -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+
- name: Build Tests for Coverage
3044
run: |
31-
make -C build/ coverage
45+
CFLAGS=" --coverage -O0 -Wall -Wextra"
46+
CFLAGS+=" -Werror -Wno-error=pedantic"
47+
CFLAGS+=" -DFORTIFY_SOURCE=0"
48+
CFLAGS+=" -DNDEBUG"
49+
cmake -S test -B build_cov \
50+
-G "Unix Makefiles" \
51+
-DCMAKE_BUILD_TYPE=Debug \
52+
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
53+
-DCMAKE_C_FLAGS="${CFLAGS}"
54+
make -C build_cov all
55+
- name: Run Tests for Coverage
56+
run: |
57+
cd build_cov
58+
make coverage
59+
ctest -E system --output-on-failure
60+
cd ..
3261
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
62+
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build_cov/coverage.info -o build_cov/coverage.info
63+
lcov --rc lcov_branch_coverage=1 --list build_cov/coverage.info
3564
- name: Check Coverage
3665
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
3766
with:
38-
path: ./build/coverage.info
67+
path: ./build_cov/coverage.info
3968
complexity:
4069
runs-on: ubuntu-latest
4170
steps:

0 commit comments

Comments
 (0)