Skip to content

Commit 5ee30ef

Browse files
committed
fix: coverage
1 parent 64ddb9d commit 5ee30ef

File tree

2 files changed

+55
-19
lines changed

2 files changed

+55
-19
lines changed

.cirrus.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ jammy_task:
55
image: ghcr.io/dairlab/docker-dair/jammy-dair-base:v1.42
66
cpu: 8
77
memory: 24
8+
format_script:
9+
- apt update && apt install -y clang-format
10+
- ./tools/scripts/check_format.sh
811
test_script:
912
- export CC=clang-15
1013
- export CXX=clang++-15
@@ -14,6 +17,13 @@ jammy_task:
1417
--jobs=8
1518
--remote_cache=http://$CIRRUS_HTTP_CACHE_HOST
1619
//...
20+
- bazel test
21+
--local_resources=ram=24000
22+
--local_resources=cpu=8
23+
--jobs=8
24+
--remote_cache=http://$CIRRUS_HTTP_CACHE_HOST
25+
//...
26+
coverage_script:
1727
- apt update && apt install -y lcov
1828
# Coverage will run tests, as well as coverage for the code.
1929
- bazel coverage
@@ -22,33 +32,31 @@ jammy_task:
2232
--local_resources=cpu=8
2333
--remote_cache=http://$CIRRUS_HTTP_CACHE_HOST
2434
--remote_download_minimal
35+
--strategy=CoverageReport=local
36+
--experimental_split_coverage_postprocessing
37+
--experimental_fetch_all_coverage_outputs
2538
//...
39+
- ls -R
2640
- genhtml --branch-coverage
2741
--output genhtml
2842
"bazel-out/_coverage/_coverage_report.dat"
29-
format_script:
30-
- apt update && apt install -y clang-format-15
31-
- find .
32-
-name "*.cc" -o -name "*.h" -o -name "*.hpp" |
33-
xargs clang-format-15 --dry-run --Werror
34-
--output-replacements-xml > replacements.xml 2>&1
3543
always:
3644
jammy_test_artifacts:
3745
path: "bazel-testlogs/**/test.xml"
3846
format: junit
3947
jammy_coverage_artifacts:
4048
path: "genhtml/index.html"
4149
type: text/html
42-
jammy_format_artifacts:
43-
path: "replacements.xml"
44-
type: text/xml
4550

4651
noble_task:
4752
timeout_in: 120m
4853
container:
4954
image: ghcr.io/dairlab/docker-dair/noble-dair-base:v1.42
5055
cpu: 8
5156
memory: 24
57+
format_script:
58+
- apt update && apt install -y clang-format
59+
- ./tools/scripts/check_format.sh
5260
test_script:
5361
- export CC=clang-15
5462
- export CXX=clang++-15
@@ -58,31 +66,33 @@ noble_task:
5866
--jobs=8
5967
--remote_cache=http://$CIRRUS_HTTP_CACHE_HOST
6068
//...
69+
- bazel test
70+
--local_resources=ram=24000
71+
--local_resources=cpu=8
72+
--jobs=8
73+
--remote_cache=http://$CIRRUS_HTTP_CACHE_HOST
74+
//...
75+
coverage_script:
6176
- apt update && apt install -y lcov
62-
# Coverage will run tests, as well as coverage for the code.
6377
- bazel coverage
6478
--combined_report=lcov
6579
--local_resources=ram=24000
6680
--local_resources=cpu=8
6781
--remote_cache=http://$CIRRUS_HTTP_CACHE_HOST
6882
--remote_download_minimal
83+
--remote_download_minimal
84+
--strategy=CoverageReport=local
85+
--experimental_split_coverage_postprocessing
86+
--experimental_fetch_all_coverage_outputs
6987
//...
88+
- ls -R
7089
- genhtml --branch-coverage
7190
--output genhtml
7291
"bazel-out/_coverage/_coverage_report.dat"
73-
format_script:
74-
- apt update && apt install -y clang-format-15
75-
- find .
76-
-name "*.cc" -o -name "*.h" -o -name "*.hpp" |
77-
xargs clang-format-15 --dry-run --Werror
78-
--output-replacements-xml > replacements.xml 2>&1
7992
always:
8093
noble_test_artifacts:
8194
path: "bazel-testlogs/**/test.xml"
8295
format: junit
8396
noble_coverage_artifacts:
8497
path: "genhtml/index.html"
8598
type: text/html
86-
noble_format_artifacts:
87-
path: "replacements.xml"
88-
type: text/xml

tools/scripts/check_format.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Directory to check (can be customized)
4+
DIR="."
5+
6+
# Find all C++ source/header files
7+
FILES=$(find "$DIR" -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.cc" -o -name "*.h" \))
8+
9+
NOT_FORMATTED=()
10+
11+
for file in $FILES; do
12+
# Check formatting using clang-format
13+
if ! diff -q "$file" <(clang-format "$file") >/dev/null; then
14+
NOT_FORMATTED+=("$file")
15+
fi
16+
done
17+
18+
if [ ${#NOT_FORMATTED[@]} -eq 0 ]; then
19+
echo "All files are properly formatted. Good job!"
20+
else
21+
echo "The following files are not properly formatted:"
22+
for f in "${NOT_FORMATTED[@]}"; do
23+
echo "$f"
24+
done
25+
exit 1
26+
fi

0 commit comments

Comments
 (0)