-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/add-clang-format'
- Loading branch information
Showing
9 changed files
with
1,279 additions
and
1,429 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,33 @@ | ||
# NOTE: The content of this file has been directly adapted from /godot-cpp/.workflows/static_checks.yml | ||
name: 📊 Static Checks | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
static-checks: | ||
name: Format (clang-format) | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: recursive | ||
|
||
# Azure repositories are not reliable, we need to prevent Azure giving us packages. | ||
- name: Make apt sources.list use the default Ubuntu repositories | ||
run: | | ||
sudo rm -f /etc/apt/sources.list.d/* | ||
sudo cp -f godot-cpp/misc/ci/sources.list /etc/apt/sources.list | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | ||
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | ||
sudo apt-get update | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get install -qq clang-format-15 | ||
sudo update-alternatives --remove-all clang-format || true | ||
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 | ||
- name: Style checks via clang-format (clang_format.sh) | ||
run: | | ||
bash ./misc/scripts/clang_format.sh |
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,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script runs clang-format on all relevant files in the repo. | ||
# This is the primary script responsible for fixing style violations. | ||
|
||
set -uo pipefail | ||
|
||
# Loops through all code files tracked by Git. | ||
git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' ':!:src/sqlite/*' | | ||
while read -r f; do | ||
# Run clang-format. | ||
clang-format --style=file:godot-cpp/.clang-format --Wno-error=unknown -i "$f" | ||
done | ||
|
||
diff=$(git diff --color) | ||
|
||
# If no patch has been generated all is OK, clean up, and exit. | ||
if [ -z "$diff" ] ; then | ||
printf "Files in this commit comply with the clang-tidy style rules.\n" | ||
exit 0 | ||
fi | ||
|
||
# A patch has been created, notify the user, clean up, and exit. | ||
printf "\n*** The following changes have been made to comply with the formatting rules:\n\n" | ||
echo "$diff" | ||
printf "\n*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n" | ||
exit 1 |
Oops, something went wrong.