Skip to content

Commit 17fe01c

Browse files
author
Christian A. Ehrhardt
committed
ci: Run the PtrToIntCast clang-tidy check
When building the cheri riscv kernel also run the PtrToIntCast clang tidy check to warn about dubious capability conversions. Signed-off-by: Christian A. Ehrhardt <[email protected]>
1 parent 9482ace commit 17fe01c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ jobs:
138138
set -o pipefail
139139
ARGS=""
140140
LLVM_DIR=
141+
TARGETS="all"
141142
if [ "${{ matrix.arch }}" = "aarch64" ]; then
142143
ARGS="$ARGS ARCH=arm64"
143144
CROSS="aarch64-linux-gnu-"
@@ -148,6 +149,7 @@ jobs:
148149
ARGS="$ARGS ARCH=arm64"
149150
elif [ "${{ matrix.arch }}" = "riscv64cheri" ]; then
150151
ARGS="$ARGS ARCH=riscv"
152+
TARGETS="${TARGETS} compile_commands.json"
151153
fi
152154
153155
if [[ "${{ matrix.compiler }}" == "llvm-morello" ]]; then
@@ -160,7 +162,25 @@ jobs:
160162
fi
161163
make $ARGS O=build ${{ matrix.config }}
162164
# Pipe output to tee so we can see it and save it for counting warnings
163-
make $ARGS O=build -j$(nproc) 2>&1 | tee build.log
165+
make $ARGS O=build -j$(nproc) ${TARGETS} 2>&1 | tee build.log
166+
167+
- name: Run clang-tidy
168+
if: matrix.compiler == 'llvm-cheri'
169+
shell: bash
170+
run: |
171+
set -o pipefail
172+
grep "file.:.*\.c.$" build/compile_commands.json | \
173+
sed 's/.*file.:..//; s/.$//' | \
174+
xargs -n $(nproc) -P 12 -- /usr/lib/llvm-cheri/bin/clang-tidy \
175+
--checks='-*,cheri-PtrToIntCast' \
176+
--header-filter='.*' \
177+
--system-headers \
178+
-p build 2>&1 | tee tidy.log
179+
echo "CHECKING clang-tidy messages"
180+
if egrep "(warning|error):" tidy.log; then
181+
echo "ERROR: Unexpected clang-tidy warnings"
182+
false # Fail
183+
fi
164184
165185
- name: Process Logs (Errors & Warnings)
166186
if: always()
@@ -169,15 +189,16 @@ jobs:
169189
GH_TOKEN: ${{ github.token }}
170190
JOB_NAME: "Build ${{ matrix.arch }} ${{ matrix.compiler }} ${{ matrix.config }}"
171191
run: |
192+
touch tidy.log
172193
echo "::group::📝 Build Issues (Errors & Warnings)"
173-
if grep -iE "warning:|error:" build.log; then
194+
if grep -iE "warning:|error:" build.log tidy.log; then
174195
echo "--------------------------------------------------"
175196
echo "Full list above."
176197
else
177198
echo "🎉 Clean build - No warnings or errors found."
178199
fi
179200
echo "::endgroup::"
180-
COUNT=$(grep -c -i "warning:" build.log || true)
201+
COUNT=$(grep -c -i "warning:" build.log tidy.log || true)
181202
OUTCOME="${{ steps.kbuild.outcome }}"
182203
FULL_LINK="${{ steps.job-link.outputs.url }}#step:${{ steps.job-link.outputs.build_step_num }}:1"
183204
COUNT_CLEAN=$(echo $COUNT | xargs)

0 commit comments

Comments
 (0)