From b44e73b38e4a5552e475547a45530b9babdbb9d3 Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Sat, 22 Feb 2020 18:12:17 +0300 Subject: [PATCH 1/3] [CI] Add clang-format checker to pre-commit checks Signed-off-by: Alexey Bader --- .github/workflows/clang-format.yml | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/clang-format.yml diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000000000..ca455c9394f12 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -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 + + # Add patch with formatting fixes to CI job artifacts + - uses: actions/upload-artifact@v1 + with: + name: clang-format-patch + path: ./clang-format.patch + + - name: Check if clang-format patch is empty + run: bash -c "if [ -s ./clang-format.patch ]; then cat ./clang-format.patch; exit 1; fi" From 209556da67fec9bf106e7371193885ba8714faec Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Sun, 23 Feb 2020 12:55:55 +0300 Subject: [PATCH 2/3] [CI] Fix commit range validated by this job Signed-off-by: Alexey Bader --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index ca455c9394f12..3a1fb4dfdea1b 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -22,7 +22,7 @@ jobs: - 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 + 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 # Add patch with formatting fixes to CI job artifacts - uses: actions/upload-artifact@v1 From e5586f19b85601e81c467728728fe87ae4193622 Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Sun, 23 Feb 2020 19:11:40 +0300 Subject: [PATCH 3/3] Update .github/workflows/clang-format.yml Signed-off-by: Alexey Bader alexey.bader@intel.com Co-Authored-By: Alexander Batashev --- .github/workflows/clang-format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 3a1fb4dfdea1b..9a060005564da 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -18,7 +18,7 @@ jobs: 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 + run: sudo apt-get install -yqq clang-format-9 - name: Run clang-format for the patch run: |