CI: use compilation database for clang-tidy job
authorKirill Isakov <bootctl@gmail.com>
Mon, 23 May 2022 13:48:59 +0000 (19:48 +0600)
committerKirill Isakov <bootctl@gmail.com>
Mon, 23 May 2022 18:32:07 +0000 (00:32 +0600)
.ci/tidy/run.sh [deleted file]
.ci/warn/run.sh
.github/workflows/test.yml

diff --git a/.ci/tidy/run.sh b/.ci/tidy/run.sh
deleted file mode 100755 (executable)
index a2439f7..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-./.ci/build.sh build "$@"
-
-# Which paths to ignore.
-paths='src/solaris src/windows src/gcrypt'
-
-case "$(uname -s)" in
-Linux)
-  paths="$paths src/bsd"
-  ;;
-
-FreeBSD)
-  paths="$paths src/linux src/bsd/darwin src/bsd/openbsd"
-  ;;
-
-Darwin)
-  paths="$paths src/linux src/vde_device.c"
-  ;;
-
-*) exit 1 ;;
-esac
-
-path_filters=''
-for path in $paths; do
-  path_filters=" $path_filters ! ( -path $path -prune ) "
-done
-
-echo >&2 "Running clang-tidy without $paths"
-
-# This is fine, our paths are relative and do not contain any whitespace.
-# shellcheck disable=SC2086
-find src \
-  $path_filters \
-  -name '*.c' \
-  -exec clang-tidy -p build --header-filter='.*' '{}' +
index b84bc2e..2add1a5 100755 (executable)
@@ -6,12 +6,25 @@ test -n "$CC"
 
 result=0
 
+clang_tidy() {
+  rm -f compile_commands.json
+  ln -s "$1"/compile_commands.json .
+  run-clang-tidy || result=$?
+}
+
 check_warnings() {
-  git clean -dfx
-  ./.ci/build.sh build -Dwerror=true "$@" || result=$?
+  flavor="$1"
+  dir="${CC}_${flavor}"
+
+  ./.ci/build.sh "$dir" -Dwerror=true || result=$?
+
+  case "$CC" in
+  clang*) clang_tidy "$dir" ;;
+  esac
 }
 
-check_warnings
-check_warnings -Dcrypto=nolegacy
+check_warnings default
+check_warnings nolegacy
+check_warnings gcrypt
 
 exit $result
index 87a758f..52dd0ef 100644 (file)
@@ -61,7 +61,8 @@ jobs:
       - name: Install tools
         run: |
           sudo apt-get install -y astyle clang-tidy-$CLANG
-          sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$CLANG 100
+          sudo update-alternatives --install /usr/bin/clang-tidy     clang-tidy     /usr/bin/clang-tidy-$CLANG     100
+          sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-$CLANG 100
           curl -OL "https://github.com/koalaman/shellcheck/releases/download/v$SHELLCHECK/shellcheck-v${SHELLCHECK}.linux.x86_64.tar.xz"
           tar -C ~ --strip-components=1 --wildcards -xf ./shellcheck-*.tar.xz 'shellcheck-*/shellcheck'
           curl -o ~/shfmt -L "https://github.com/mvdan/sh/releases/download/v$SHFMT/shfmt_v${SHFMT}_linux_amd64"
@@ -83,20 +84,16 @@ jobs:
           PATH=$PATH:$HOME ./lint.py
         if: always()
 
-      - name: Run clang-tidy
-        run: sh .ci/tidy/run.sh
-        if: always()
-
-      - name: Check warnings (gcc)
+      - name: Check warnings (clang)
         run: bash .ci/warn/run.sh
         env:
-          CC: gcc-10
+          CC: clang-12
         if: always()
 
-      - name: Check warnings (clang)
+      - name: Check warnings (gcc)
         run: bash .ci/warn/run.sh
         env:
-          CC: clang-12
+          CC: gcc-10
         if: always()
 
   sanitizer: