Skip to content

Commit

Permalink
[ci] Skip clang-format for disabled directories
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grandchild committed Jun 29, 2024
1 parent 0c3a994 commit 7d2dd9c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d2dd9c

Please sign in to comment.