Skip to content

Commit 717f126

Browse files
authored
Merge pull request #53 from adrianreber/2024-12-30-clang-format
Run clang-format check during CI
2 parents acbbc28 + 1b16d70 commit 717f126

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/lint.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run code linter
2+
3+
on: [push, pull_request]
4+
5+
# Cancel any preceding run on the pull request.
6+
concurrency:
7+
group: lint-test-${{ github.event.pull_request.number || github.ref }}
8+
cancel-in-progress: ${{ github.ref != 'refs/heads/criu-dev' }}
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: registry.fedoraproject.org/fedora:latest
15+
steps:
16+
- name: Install tools
17+
run: sudo dnf -y install git make clang-tools-extra which git-clang-format
18+
19+
- uses: actions/checkout@v4
20+
21+
- name: Set git safe directory
22+
# https://github.com/actions/checkout/issues/760
23+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
24+
25+
- name: Run make indent
26+
run: |
27+
if [ -z "${{github.base_ref}}" ]; then
28+
git fetch --deepen=1
29+
git clang-format --diff --style file --extensions c,h "HEAD~1"
30+
else
31+
git fetch origin ${{github.base_ref}}
32+
git clang-format --diff --style file --extensions c,h origin/${{github.base_ref}}
33+
fi

0 commit comments

Comments
 (0)