MinecraftConsoles/.github/workflows/clang-format.yml
rtm516 38d58f2d8b
Some checks failed
Nightly Server Release / build (Windows64) (push) Has been cancelled
Nightly Release / build (Windows64) (push) Has been cancelled
Nightly Server Release / release (push) Has been cancelled
Nightly Server Release / Build and Push Docker Image (push) Has been cancelled
Nightly Server Release / cleanup (push) Has been cancelled
Nightly Release / release (push) Has been cancelled
Nightly Release / cleanup (push) Has been cancelled
Update actions workflows and add clang format check for PRs (#1418)
* Add clang-format workflow for pull request checks

* Modify push paths in nightly workflow

Updated paths for push event to include all files except specified ones.

* Update paths for nightly-server workflow triggers

* Modify paths for pull request triggers

Update pull request workflow to include specific paths.

* Tidy up clang-format installation in workflow
2026-03-28 23:35:25 -05:00

49 lines
1.4 KiB
YAML

name: Check formatting
on:
pull_request:
paths:
- '**'
- '!.gitignore'
- '!*.md'
- '!.github/**'
- '.github/workflows/clang-format.yml'
permissions:
contents: read
pull-requests: write
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fetch base commit
run: git fetch origin ${{ github.event.pull_request.base.sha }}
- name: Install clang-format-20
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main"
sudo apt-get install -y -qq clang-format-20
- uses: reviewdog/action-setup@v1
- name: Check formatting on changed lines
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git clang-format-20 --binary clang-format-20 \
--diff ${{ github.event.pull_request.base.sha }} -- \
'*.c' '*.cpp' '*.cc' '*.h' '*.hpp' \
| reviewdog \
-name="clang-format" \
-f=diff \
-reporter=github-pr-check \
-fail-level=error \
-filter-mode=added