-
Notifications
You must be signed in to change notification settings - Fork 796
[CI] Add clang-format checker to pre-commit checks #1163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: clang-format-check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- sycl | ||
types: [open, edit, reopen, synchronize] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# checkout PR head | ||
ref: '${{github.event.pull_request.head.sha}}' | ||
- name: Fetch target branch | ||
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}} | ||
|
||
- name: Get clang-format first | ||
run: sudo apt-get install clang-format-9 | ||
|
||
- name: Run clang-format for the patch | ||
run: | | ||
git diff -U0 --no-color origin/${{github.base_ref}}...HEAD | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch | ||
alexbatashev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Add patch with formatting fixes to CI job artifacts | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: clang-format-patch | ||
path: ./clang-format.patch | ||
Comment on lines
+27
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose if this step? Would it be possible to download this patch-file somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. You will be able to download the patch and apply it to your PR to fix formatting issues. |
||
|
||
- name: Check if clang-format patch is empty | ||
run: bash -c "if [ -s ./clang-format.patch ]; then cat ./clang-format.patch; exit 1; fi" |
Uh oh!
There was an error while loading. Please reload this page.