From c789d94e0508c8d61219b2b042954209166b84a1 Mon Sep 17 00:00:00 2001 From: Kirill Isakov Date: Mon, 23 May 2022 19:48:59 +0600 Subject: [PATCH] CI: use compilation database for clang-tidy job --- .ci/tidy/run.sh | 38 -------------------------------------- .ci/warn/run.sh | 21 +++++++++++++++++---- .github/workflows/test.yml | 15 ++++++--------- 3 files changed, 23 insertions(+), 51 deletions(-) delete mode 100755 .ci/tidy/run.sh diff --git a/.ci/tidy/run.sh b/.ci/tidy/run.sh deleted file mode 100755 index a2439f7d..00000000 --- a/.ci/tidy/run.sh +++ /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='.*' '{}' + diff --git a/.ci/warn/run.sh b/.ci/warn/run.sh index b84bc2ec..2add1a5c 100755 --- a/.ci/warn/run.sh +++ b/.ci/warn/run.sh @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87a758f8..52dd0ef7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: -- 2.20.1