From: Kirill Isakov Date: Mon, 23 May 2022 13:48:59 +0000 (+0600) Subject: CI: use compilation database for clang-tidy job X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=c789d94e0508c8d61219b2b042954209166b84a1;p=tinc CI: use compilation database for clang-tidy job --- 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: