Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update clang-format checks for full history #3395

Merged
merged 2 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/analyzers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 34 additions & 2 deletions ci/check-commit-format.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 16 additions & 16 deletions nano/core_test/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down