Skip to content

Commit c02b4c1

Browse files
committed
Add clang format check
Same as in the samples repo
1 parent dfe3cba commit c02b4c1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Quality Checks
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
8+
env:
9+
TARGET_BRANCH: main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
clang_format:
17+
name: Clang Format Check
18+
container: ghcr.io/khronosgroupactions/clang-tools:15.0.0
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- run: git config --global --add safe.directory /__w/Vulkan-Tutorial/Vulkan-Tutorial
23+
- run: git fetch origin $TARGET_BRANCH:$TARGET_BRANCH
24+
- name: Run Clang Format diff
25+
id: clang-diff
26+
run: |
27+
echo "changes=$(echo $(git diff -- '***.cpp' `***.h' -U0 --no-color $TARGET_BRANCH | python3 /usr/share/clang/clang-format-diff.py -p1 -v -sort-include))" >> $GITHUB_OUTPUT
28+
echo "$(echo $(git diff -- '***.cpp' `***.h' -U0 --no-color $TARGET_BRANCH | python3 /usr/share/clang/clang-format-diff.py -p1 -v -sort-include))" >> clang-issues.diff
29+
- name: Count Diff Lines
30+
continue-on-error: true
31+
id: count-diff
32+
run: echo "line-count=$(echo "${{ steps.clang-diff.outputs.changes }}" | grep -c +++)" >> $GITHUB_OUTPUT
33+
- name: 'Upload Artifact'
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: clang-issues.diff
37+
path: clang-issues.diff
38+
retention-days: 3
39+
- name: Assert
40+
run: if test ${{ steps.count-diff.outputs.line-count }} -gt 0; then echo "${{ steps.clang-diff.outputs.changes }}"; exit 1; fi
41+

0 commit comments

Comments
 (0)