Merge branch 'clang-format-ci-2' into 'master'

Test clang-format project wide in same pipeline

See merge request OpenMW/openmw!2423
make_linux_ci_do_zoomies
psi29a 2 years ago
commit f37d0be806

@ -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
@ -119,6 +120,20 @@ Ubuntu_GCC:
# 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
# TODO: Remove this once the entire project is formatted.
allow_failure: true
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
cache:

@ -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

@ -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

Loading…
Cancel
Save