-
Notifications
You must be signed in to change notification settings - Fork 2
36 lines (32 loc) · 1.15 KB
/
enforce-clang-format-clean.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Enforce clang-format clean
on:
- pull_request
- push
jobs:
build_and_test:
name: Enforce clang-format clean
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install clang-format
run: |-
clang_major_version=14
set -x -u -o pipefail
source /etc/os-release
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${clang_major_version} main"
sudo apt-get update
sudo apt-get install --yes --no-install-recommends -V clang-format-${clang_major_version}
echo "/usr/lib/llvm-${clang_major_version}/bin" >> "${GITHUB_PATH}"
- name: Enforce clang-format clean
run: |-
clang_format_args=(
-i
-style=file
-verbose
)
set -x -u -o pipefail
clang-format --version
git ls-files '*.c' '*.cpp' '*.h' \
| xargs clang-format "${clang_format_args[@]}"
git diff --exit-code # i.e. fail CI on non-empty diff