From 7d2dd9c2c72f8135cfe9510d30c7595234911a04 Mon Sep 17 00:00:00 2001 From: jakob Date: Sat, 29 Jun 2024 02:19:32 +0200 Subject: [PATCH] [ci] Skip clang-format for disabled directories Search for ".clang-format" files with "DisableFormat" lines and remove any files whose path is below their location (i.e. their path with the filename removed). This reduces the runtime of the clang-format CI step by ~5 minutes, because it takes that long for clang-format to work through the json.h library header. --- .github/workflows/check-and-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/check-and-build.yml b/.github/workflows/check-and-build.yml index 378d2ba9..67604f7f 100644 --- a/.github/workflows/check-and-build.yml +++ b/.github/workflows/check-and-build.yml @@ -30,8 +30,11 @@ jobs: -verbose ) set -x -u -o pipefail + shopt -s globstar # Enable **/ for recursive globbing clang-format --version git ls-files '*.c' '*.cpp' '*.h' \ + | grep -vf <(grep -rl "^DisableFormat: *true" **/.clang-format \ + | sed 's:/.clang-format::') \ | xargs clang-format "${clang_format_args[@]}" git diff --exit-code # i.e. fail CI on non-empty diff