update clang-format checks for full history (#3395)

* update clang-format checks for full history
checks for clang-format 10.0.0

* no need to explicitly install as clang-format, installed versions suffice
This commit is contained in:
Russel Waters 2021-07-26 09:10:06 -07:00 committed by GitHub
commit 18640c19dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 22 deletions

View file

@ -12,10 +12,6 @@ jobs:
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt-get install clang-format-10
- name: Setting clang-format 10 as the default
env:
DEBIAN_FRONTEND: noninteractive
run: sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-10 1000
- name: Clang Format
run: ci/check-commit-format.sh

View file

@ -1,12 +1,44 @@
#!/usr/bin/env bash
FOUND=0
# hard requirement of clang-format 10.0.0
CF_EXECUTABLE='
clang-format-10.0.0
clang-format-10.0
clang-format-10
clang-format
'
# check different executable strings
for executable in $CF_EXECUTABLE; do
if type -p "$executable" >/dev/null; then
clang_format="$executable"
FOUND=1
break
fi
done
# alert if not installed
if [ $FOUND == 0 ]; then
echo "clang-format not found, please install 10.0.0 first"
exit 1
fi
# check if old version is found
if ! "$clang_format" --version | grep '10.0.0' &>/dev/null; then
echo "clang-format version 10.0.0 is required, please update it"
exit 1
fi
REPO_ROOT=$(git rev-parse --show-toplevel)
"${REPO_ROOT}/ci/update-clang-format"
RESULT=$(python $REPO_ROOT/ci/git-clang-format.py --diff -f --commit HEAD~1 --extensions "hpp,cpp")
RESULT=$(python $REPO_ROOT/ci/git-clang-format.py --diff --extensions "hpp,cpp")
if [ "$RESULT" != "no modified files to format" ] && [ "$RESULT" != "clang-format did not modify any files" ]; then
python $REPO_ROOT/ci/git-clang-format.py --diff -f --commit HEAD~1 --extensions "hpp,cpp"
python $REPO_ROOT/ci/git-clang-format.py --diff --extensions "hpp,cpp"
echo
echo "Code formatting differs from expected - please run ci/clang-format-all.sh"
exit 1

View file

@ -555,14 +555,14 @@ TEST (telemetry, remove_peer_different_genesis)
// Possible TSAN issue in the future if something else uses this, but will only appear in tests.
nano::state_block_builder builder;
auto junk = builder
.account (nano::dev::genesis_key.pub)
.previous (0)
.representative (nano::dev::genesis_key.pub)
.balance (0)
.link (0)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (0)
.build_shared ();
.account (nano::dev::genesis_key.pub)
.previous (0)
.representative (nano::dev::genesis_key.pub)
.balance (0)
.link (0)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (0)
.build_shared ();
node1->network_params.ledger.genesis = junk;
node1->start ();
system.nodes.push_back (node1);
@ -593,14 +593,14 @@ TEST (telemetry, remove_peer_different_genesis_udp)
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.logging, system.work, node_flags));
nano::state_block_builder builder;
auto junk = builder
.account (nano::dev::genesis_key.pub)
.previous (0)
.representative (nano::dev::genesis_key.pub)
.balance (0)
.link (0)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (0)
.build_shared ();
.account (nano::dev::genesis_key.pub)
.previous (0)
.representative (nano::dev::genesis_key.pub)
.balance (0)
.link (0)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (0)
.build_shared ();
node1->network_params.ledger.genesis = junk;
node1->start ();
system.nodes.push_back (node1);