Skip to content

Commit 78e487b

Browse files
TimoWilkenkostorr
authored andcommitted
Upgrade clang-format check to clang-format-11
Due to a recent update of GitHub's ubuntu-latest containers, git-clang-format-8 stopped working. This updates it to clang-format-11, which is in line with the clang version used for compilation.
1 parent cb908a5 commit 78e487b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

.github/workflows/format.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@ name: Clang format
33
on: [pull_request]
44

55
jobs:
6-
clang-format-8:
6+
clang-format:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
1010
with:
1111
ref: ${{ github.event.pull_request.head.sha }}
12-
- name: Run clang-foramt on changed files
12+
13+
- name: Install prerequisites
14+
run: |
15+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
16+
sudo update-alternatives --install /usr/bin/git-clang-format git-clang-format /usr/bin/git-clang-format-11 100
17+
18+
- name: Run clang-format on changed files
1319
run: |
1420
set -x
15-
git fetch origin ${{ github.event.pull_request.base.ref }}
16-
git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}
17-
BASE_COMMIT=$(git rev-parse ${{ github.event.pull_request.base.sha }})
18-
COMMIT_FILES=$(git diff --name-only ${BASE_COMMIT} | grep -i -v LinkDef)
19-
RESULT_OUTPUT=$(git-clang-format-8 --commit ${BASE_COMMIT} --diff --binary $(which clang-format-8) ${COMMIT_FILES})
20-
if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ]; then
21+
git fetch origin ${{ github.event.pull_request.base.ref }} pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}
22+
base_commit=$(git rev-parse ${{ github.event.pull_request.base.sha }})
23+
result_output=$(git diff --diff-filter d --name-only "$base_commit" -- . ':^LinkDef' |
24+
xargs -d '\n' git-clang-format --commit "$base_commit" --diff --style file)
25+
if [ "$result_output" = 'no modified files to format' ] ||
26+
[ "$result_output" = 'clang-format did not modify any files' ]
27+
then
2128
exit 0
2229
else
23-
git-clang-format-8 --commit $BASE_COMMIT --diff --binary $(which clang-format-8)
24-
echo "$RESULT_OUTPUT"
30+
git-clang-format --commit "$base_commit" --diff --style file
31+
echo "$result_output"
2532
exit 1
2633
fi

0 commit comments

Comments
 (0)