-
Notifications
You must be signed in to change notification settings - Fork 51
42 lines (42 loc) · 1.3 KB
/
clang-format.yaml
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
37
38
39
40
41
42
name: Clang format
on: [push, pull_request]
jobs:
pre_job:
name: Prerequisite checks
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
cancel_others: 'true'
clang-format-pull:
name: Clang Format
needs: pre_job
if: "needs.pre_job.outputs.should_skip != 'true'"
runs-on: ubuntu-latest
steps:
- name: Define variables
run: |
echo "BASE=$(\
if [[ ${{ github.event_name }} = 'pull_request' ]]; then \
echo 'origin/${{ github.base_ref }}'; \
else \
echo '${{ github.event.before }}'; \
fi)" \
>> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Install clang-format
run: sudo apt-get install clang-format
- name: Download git-clang-format
run: wget https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/git-clang-format
- name: Install git-clang-format
run: sudo install -t /bin git-clang-format
- name: Fetch origin
run: git fetch origin
- name: clang-format
run: git clang-format ${{ env.BASE }}
- name: diff
run: git diff --exit-code