1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00

Test clang-format project wide in same pipeline

This commit is contained in:
ζeh Matt 2022-09-20 22:03:44 +03:00
parent 9a9c7fa7cf
commit 3e9fccd7f0
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
3 changed files with 49 additions and 0 deletions

View File

@ -4,6 +4,7 @@ default:
# Note: We set `needs` on each job to control the job DAG.
# See https://docs.gitlab.com/ee/ci/yaml/#needs
stages:
- checks
- build
- test
@ -118,6 +119,18 @@ Ubuntu_GCC:
CCACHE_SIZE: 4G
# When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks.
timeout: 2h
Clang_Format:
extends: .Ubuntu_Image
stage: checks
cache:
key: Ubuntu_Clang_Format.ubuntu_22.04.v1
paths:
- apt-cache/
before_script:
- CI/install_debian_deps.sh openmw-clang-format
script:
- CI/check_clang_format.sh
Ubuntu_GCC_Debug:
extends: .Ubuntu

31
CI/check_clang_format.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
CLANG_FORMAT="clang-format-14"
HAS_DIFFS=0
check_format() {
local path=$1
local tempfile=$(mktemp)
for item in $(find $path -type f -name "*");
do
if [[ "$item" =~ .*\.(cpp|hpp|h) ]]; then
echo "Checking code formatting on $item"
$CLANG_FORMAT $item > $tempfile
git diff --color=always --no-index $item $tempfile
if [[ $? = 1 ]]; then
HAS_DIFFS=1
fi
fi;
done;
rm -f $tempfile
}
check_format "./apps"
check_format "./components"
if [[ $HAS_DIFFS -eq 1 ]]; then
echo "clang-format differences detected"
exit 1
fi;
exit 0

View File

@ -77,6 +77,11 @@ declare -rA GROUPED_DEPS=(
"
[android]="binutils build-essential cmake ccache curl unzip git pkg-config"
[openmw-clang-format]="
clang-format-14
git-core
"
)
if [[ $# -eq 0 ]]; then