Skip to content

Commit 6745024

Browse files
awegrzynkostorr
authored andcommitted
Move Travis format job to GH Actions
1 parent be6eedc commit 6745024

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

.github/workflows/format.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Clang format
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
clang-format-8:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
ref: ${{ github.event.pull_request.head.sha }}
12+
- name: Run clang-foramt on changed files
13+
run: |
14+
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+
exit 0
22+
else
23+
git-clang-format-8 --commit $BASE_COMMIT --diff --binary $(which clang-format-8)
24+
echo "$RESULT_OUTPUT"
25+
exit 1
26+
fi

.travis.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)