ostree/ci/clang-format.sh
Colin Walters a33c7d23d6 ci: Only run clang-format on ubuntu-stable GH runner
Previously we were running clang-format across multiple operating
system versions and hence clang versions, and it turns out
clang has changed the preferred formatting multiple times.

We could *probably* dig in and try to pin things more strongly
but eh...for now let's arbitrarily just use whatever's in
the default GH Action ubuntu-latest runner as that should
be equally painful for everyone.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-05-01 20:35:32 -04:00

21 lines
629 B
Bash
Executable File

#!/usr/bin/env bash
# Tests that validate structure of the source code;
# can be run without building it.
set -euo pipefail
clang_ver=$(clang-format --version)
clang_min_ver=15
version_re=" version ([0-9]+)."
if [[ $clang_ver =~ $version_re ]]; then
if test "${BASH_REMATCH[1]}" -ge "${clang_min_ver}"; then
echo -n "checking clang-format... "
git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format --Werror --dry-run
echo "ok"
else
echo "notice: clang-format ${clang_ver}" is too old
fi
else
echo "failed to parse clang-format version ${clang_ver}" 1>&2
exit 1
fi