-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI workflow for clang-format (#610)
Should fail if the contribution doesn't match the format and provide a diff that someone can download and apply locally. Signed-off-by: Tristan Partin <[email protected]>
- Loading branch information
1 parent
3990cd4
commit 3912217
Showing
3 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# | ||
# SPDX-FileCopyrightText: Copyright 2023 Micron Technology, Inc. | ||
|
||
name: ClangFormat | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths-ignore: | ||
- "**.c" | ||
- "**.h" | ||
- "**.h.in" | ||
- "!subprojects/*" | ||
- .github/workflows/clang-format.yaml | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-ignore-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: | | ||
echo "Skipping ${{ github.workflow }}/${{ github.job }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# | ||
# SPDX-FileCopyrightText: Copyright 2023 Micron Technology, Inc. | ||
|
||
name: ClangFormat | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- master | ||
- "v[0-9]+.[0-9]+" | ||
paths: | ||
- "**.c" | ||
- "**.h" | ||
- "**.h.in" | ||
- "!subprojects/*" | ||
- .github/workflows/clang-format.yaml | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
clang-format: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/hse-project/ci-images/fedora-37:${{ github.base_ref }} | ||
|
||
steps: | ||
- name: Checkout HSE | ||
uses: actions/checkout@v3 | ||
|
||
- name: Run clang-format | ||
run: | | ||
./scripts/dev/clang-format.sh -c "$GITHUB_WORKSPACE" | ||
- name: Generate diff | ||
if: failure() | ||
run: | | ||
git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
git fetch origin --depth=1 "$GITHUB_BASE_REF" "$GITHUB_HEAD_REF" | ||
git diff -U0 --no-color --relative \ | ||
"origin/$GITHUB_BASE_REF" "origin/$GITHUB_HEAD_REF" | | ||
clang-format-diff -p1 -sort-includes -regex \ | ||
'(cli|include|lib|samples|tests|tools)\/.*\.(c|h|h\.in)$' | | ||
tee clang-format.patch | ||
- name: Upload diff | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: diff | ||
path: clang-format.patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters