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
This commit is contained in:
parent
75149ef6b5
commit
89e6f44f61
13 changed files with 92 additions and 69 deletions
8
.github/workflows/analyzers.yml
vendored
8
.github/workflows/analyzers.yml
vendored
|
|
@ -4,19 +4,19 @@ on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
clang_format:
|
clang_format:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e
|
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e
|
||||||
- name: Installing clang-format 10
|
- name: Installing clang-format 12
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: sudo apt-get install clang-format-10
|
run: sudo apt-get install clang-format-12
|
||||||
- name: Clang Format
|
- name: Clang Format
|
||||||
run: ci/check-commit-format.sh
|
run: ci/check-commit-format.sh
|
||||||
|
|
||||||
cmake_format:
|
cmake_format:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e
|
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e
|
||||||
|
|
|
||||||
4
.github/workflows/beta_artifacts.yml
vendored
4
.github/workflows/beta_artifacts.yml
vendored
|
|
@ -41,7 +41,7 @@ jobs:
|
||||||
AWS_DEFAULT_REGION: us-east-2
|
AWS_DEFAULT_REGION: us-east-2
|
||||||
|
|
||||||
linux_job:
|
linux_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
steps:
|
steps:
|
||||||
- name: tag
|
- name: tag
|
||||||
|
|
@ -66,7 +66,7 @@ jobs:
|
||||||
AWS_DEFAULT_REGION: us-east-2
|
AWS_DEFAULT_REGION: us-east-2
|
||||||
|
|
||||||
linux_docker_job:
|
linux_docker_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
steps:
|
steps:
|
||||||
- name: tag
|
- name: tag
|
||||||
|
|
|
||||||
4
.github/workflows/coverage.yml
vendored
4
.github/workflows/coverage.yml
vendored
|
|
@ -17,7 +17,7 @@ jobs:
|
||||||
LCOV: 1
|
LCOV: 1
|
||||||
COMPILER: gcc
|
COMPILER: gcc
|
||||||
BOOST_ROOT: /tmp/boost
|
BOOST_ROOT: /tmp/boost
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
TEST_USE_ROCKSDB: [0, 1]
|
TEST_USE_ROCKSDB: [0, 1]
|
||||||
|
|
@ -48,7 +48,7 @@ jobs:
|
||||||
parallel: true
|
parallel: true
|
||||||
finish:
|
finish:
|
||||||
needs: coverage_test
|
needs: coverage_test
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: coverallsapp/github-action@8cbef1dea373ebce56de0a14c68d6267baa10b44
|
- uses: coverallsapp/github-action@8cbef1dea373ebce56de0a14c68d6267baa10b44
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
2
.github/workflows/develop.yml
vendored
2
.github/workflows/develop.yml
vendored
|
|
@ -6,7 +6,7 @@ on:
|
||||||
- develop
|
- develop
|
||||||
jobs:
|
jobs:
|
||||||
linux_job:
|
linux_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
4
.github/workflows/live_artifacts.yml
vendored
4
.github/workflows/live_artifacts.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
AWS_DEFAULT_REGION: us-east-2
|
AWS_DEFAULT_REGION: us-east-2
|
||||||
|
|
||||||
linux_job:
|
linux_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
steps:
|
steps:
|
||||||
- name: tag
|
- name: tag
|
||||||
|
|
@ -65,7 +65,7 @@ jobs:
|
||||||
AWS_DEFAULT_REGION: us-east-2
|
AWS_DEFAULT_REGION: us-east-2
|
||||||
|
|
||||||
linux_docker_job:
|
linux_docker_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
steps:
|
steps:
|
||||||
- name: tag
|
- name: tag
|
||||||
|
|
|
||||||
4
.github/workflows/test_network_artifacts.yml
vendored
4
.github/workflows/test_network_artifacts.yml
vendored
|
|
@ -41,7 +41,7 @@ jobs:
|
||||||
AWS_DEFAULT_REGION: us-east-2
|
AWS_DEFAULT_REGION: us-east-2
|
||||||
|
|
||||||
linux_job:
|
linux_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
steps:
|
steps:
|
||||||
- name: tag
|
- name: tag
|
||||||
|
|
@ -66,7 +66,7 @@ jobs:
|
||||||
AWS_DEFAULT_REGION: us-east-2
|
AWS_DEFAULT_REGION: us-east-2
|
||||||
|
|
||||||
linux_docker_job:
|
linux_docker_job:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
steps:
|
steps:
|
||||||
- name: tag
|
- name: tag
|
||||||
|
|
|
||||||
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
|
@ -48,7 +48,7 @@ jobs:
|
||||||
COMPILER: [gcc, clang-6]
|
COMPILER: [gcc, clang-6]
|
||||||
RELEASE:
|
RELEASE:
|
||||||
- ${{ startsWith(github.ref, 'refs/tags/') }}
|
- ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
env:
|
env:
|
||||||
COMPILER: ${{ matrix.COMPILER }}
|
COMPILER: ${{ matrix.COMPILER }}
|
||||||
TEST_USE_ROCKSDB: ${{ matrix.TEST_USE_ROCKSDB }}
|
TEST_USE_ROCKSDB: ${{ matrix.TEST_USE_ROCKSDB }}
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,16 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
FOUND=0
|
set -e
|
||||||
|
|
||||||
# hard requirement of clang-format 10.0.0
|
source "$(dirname "$BASH_SOURCE")/detect-clang-format.sh"
|
||||||
CF_EXECUTABLE='
|
source "$(dirname "$BASH_SOURCE")/common.sh"
|
||||||
clang-format-10.0.0
|
|
||||||
clang-format-10.0
|
|
||||||
clang-format-10
|
|
||||||
clang-format
|
|
||||||
'
|
|
||||||
|
|
||||||
# check different executable strings
|
"$REPO_ROOT/ci/update-clang-format"
|
||||||
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
|
clang_format_result=$(python "$REPO_ROOT/ci/git-clang-format.py" --diff --extensions "hpp,cpp")
|
||||||
if [ $FOUND == 0 ]; then
|
if [[ $clang_format_result != "no modified files to format" ]] &&
|
||||||
echo "clang-format not found, please install 10.0.0 first"
|
[[ $clang_format_result != "clang-format did not modify any files" ]]; then
|
||||||
exit 1
|
python "$REPO_ROOT/ci/git-clang-format.py" --diff --extensions "hpp,cpp"
|
||||||
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 --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 --extensions "hpp,cpp"
|
|
||||||
echo
|
echo
|
||||||
echo "Code formatting differs from expected - please run ci/clang-format-all.sh"
|
echo "Code formatting differs from expected - please run ci/clang-format-all.sh"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
CLANG_FORMAT="clang-format"
|
source $(dirname $BASH_SOURCE)/detect-clang-format.sh
|
||||||
if [ $(builtin type -p "$CLANG_FORMAT") ]; then
|
source $(dirname $BASH_SOURCE)/common.sh
|
||||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
||||||
cd "$REPO_ROOT"
|
cd "$REPO_ROOT"
|
||||||
./ci/update-clang-format
|
./ci/update-clang-format
|
||||||
find nano -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs "$CLANG_FORMAT" -i
|
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
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
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"
|
echo "pip install cmake-format to continue"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
||||||
cd "${REPO_ROOT}"
|
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
|
|
||||||
|
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 {}
|
||||||
|
|
|
||||||
5
ci/common.sh
Normal file
5
ci/common.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||||
41
ci/detect-clang-format.sh
Normal file
41
ci/detect-clang-format.sh
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
ci_dir="$(dirname "${BASH_SOURCE[0]}")"
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cd "${ci_dir}/.."
|
source "$(dirname "$BASH_SOURCE")/common.sh"
|
||||||
|
|
||||||
|
cd "$REPO_ROOT"
|
||||||
|
|
||||||
retval='1'
|
retval='1'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue