-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require fixed version of clang-format (#3454)
* Force a fixed required version of clang-format * Update github action to install clang-format 12 instead of 10 * Update GitHub actions agent OS to Ubuntu 20.04 instead of 18.04 * More verbose CI script
- Loading branch information
Showing
13 changed files
with
92 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CLANG_FORMAT="clang-format" | ||
if [ $(builtin type -p "$CLANG_FORMAT") ]; then | ||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
cd "$REPO_ROOT" | ||
./ci/update-clang-format | ||
find nano -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs "$CLANG_FORMAT" -i | ||
else | ||
echo "'$CLANG_FORMAT' could not be detected in your PATH. Do you have it installed?" | ||
fi | ||
source $(dirname $BASH_SOURCE)/detect-clang-format.sh | ||
source $(dirname $BASH_SOURCE)/common.sh | ||
|
||
cd "$REPO_ROOT" | ||
./ci/update-clang-format | ||
find nano -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs "$CLANG_FORMAT" -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if ! command -v cmake-format &>/dev/null; then | ||
source "$(dirname "$BASH_SOURCE")/common.sh" | ||
|
||
if ! [[ $(builtin type -p cmake-format) ]]; then | ||
echo "pip install cmake-format to continue" | ||
exit 1 | ||
fi | ||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
cd "${REPO_ROOT}" | ||
find "${REPO_ROOT}" -iwholename "${REPO_ROOT}/nano/*/CMakeLists.txt" -o -iwholename "${REPO_ROOT}/CMakeLists.txt" -o -iwholename "${REPO_ROOT}/coverage/CMakeLists.txt" | xargs cmake-format -i | ||
|
||
cd "$REPO_ROOT" | ||
|
||
find "$REPO_ROOT" -iwholename "$REPO_ROOT/nano/*/CMakeLists.txt" \ | ||
-o \ | ||
-iwholename "$REPO_ROOT/CMakeLists.txt" \ | ||
-o \ | ||
-iwholename "$REPO_ROOT/coverage/CMakeLists.txt" \ | ||
| xargs -i{} cmake-format -i {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
REPO_ROOT=$(git rev-parse --show-toplevel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
is_clang_format_usable() | ||
{ | ||
if [[ $(builtin type -p $1) ]]; then | ||
local output=$($1 --version) | ||
if [[ $output =~ ^(.)*clang-format\ version\ $2(.)*$ ]]; then | ||
echo "0" | ||
else | ||
echo $output | ||
fi | ||
else | ||
echo "1" | ||
fi | ||
} | ||
|
||
CLANG_FORMAT="" | ||
CLANG_FORMAT_VERSION="12" | ||
|
||
clang_format_attempts=("clang-format" | ||
"clang-format-$CLANG_FORMAT_VERSION") | ||
|
||
for itr in ${clang_format_attempts[@]}; do | ||
result=$(is_clang_format_usable $itr $CLANG_FORMAT_VERSION) | ||
if [[ $result == "0" ]]; then | ||
CLANG_FORMAT=$itr | ||
break | ||
elif [[ $result == "1" ]]; then | ||
continue | ||
else | ||
echo "Detected '$itr' with version '$result' " \ | ||
"(different than '$CLANG_FORMAT_VERSION'), skipping it." | ||
fi | ||
done | ||
|
||
if [[ -z $CLANG_FORMAT ]]; then | ||
echo "No 'clang-format' of version '$CLANG_FORMAT_VERSION' could be detected in your PATH." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters