Skip to content

Commit 2a3271b

Browse files
authored
[Devops] Fix clang-format step in the CI lint
Fix lint by fetching enough commits (number of commits in pull request plus one) and using GITHUB_SHA that corresponds to sycl HEAD for pull_request_target instead of GITHUB_SHA^1 that corresponds to the first parent (previous state of sycl branch) of merge commit for pull_request used before.
1 parent 9fdf7f1 commit 2a3271b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.github/workflows/sycl_precommit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ jobs:
2727
container:
2828
image: ghcr.io/intel/llvm/sycl_ubuntu2004_nightly:no-drivers
2929
steps:
30+
- name: 'PR commits + 1'
31+
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
3032
- uses: actions/checkout@v2
3133
with:
3234
ref: ${{ github.event.pull_request.head.sha }}
3335
persist-credentials: false
34-
fetch-depth: 2
36+
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
3537
- name: Run clang-format
3638
uses: ./devops/actions/clang-format
3739

devops/actions/clang-format/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ runs:
77
shell: bash {0}
88
run: |
99
git config --global --add safe.directory /__w/llvm/llvm
10-
git clang-format ${GITHUB_SHA}^1
10+
git fetch origin sycl
11+
git clang-format ${GITHUB_SHA}
1112
git diff > ./clang-format.patch
1213
# Add patch with formatting fixes to CI job artifacts
1314
- uses: actions/upload-artifact@v1

0 commit comments

Comments
 (0)