From b413fd3a3da20facaec803be16ca35fe0400c458 Mon Sep 17 00:00:00 2001 From: nihui Date: Tue, 13 Jul 2021 17:28:11 +0800 Subject: [PATCH] auto code-format bot and disable restyled (#3075) --- .github/workflows/code-format.yml | 52 +++++++++++++++++++++++++++++++ .restyled.yaml | 2 +- src/simpleocv.h | 9 ++++-- tests/test_packing.cpp | 6 ++-- 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/code-format.yml diff --git a/.github/workflows/code-format.yml b/.github/workflows/code-format.yml new file mode 100644 index 000000000..cea332c64 --- /dev/null +++ b/.github/workflows/code-format.yml @@ -0,0 +1,52 @@ +name: code-format + +on: [push, pull_request, pull_request_target] + +jobs: + code-format: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: cache-clang-format + id: cache-clang-format + uses: actions/cache@v2.1.6 + with: + path: clang-format-install + key: clang-format-install-4 + - name: clang-format + if: steps.cache-clang-format.outputs.cache-hit != 'true' + run: | + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-project-10.0.1.tar.xz + tar -xf llvm-project-10.0.1.tar.xz + cd llvm-project-10.0.1 + mkdir build + cd build + cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_DOCS=OFF ../llvm/ + make -j2 clang-format + mkdir $GITHUB_WORKSPACE/clang-format-install + cp -r bin/clang-format $GITHUB_WORKSPACE/clang-format-install + cd ../../ + rm -rf llvm-project-10.0.1 + rm llvm-project-10.0.1.tar.xz + + - name: astyle + run: | + sudo apt-get update + sudo apt-get install -y astyle + + - name: code-format + run: | + mkdir -p ~/bin + mv $GITHUB_WORKSPACE/clang-format-install/clang-format ~/bin/clang-format + rm -rf $GITHUB_WORKSPACE/clang-format-install + export PATH=~/bin:$PATH + sh codeformat.sh + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: apply code-format changes + + - name: restore-clang-format-cache + run: | + mkdir $GITHUB_WORKSPACE/clang-format-install + cp -r ~/bin/clang-format $GITHUB_WORKSPACE/clang-format-install diff --git a/.restyled.yaml b/.restyled.yaml index a7a83a155..3c79bdde6 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -1,6 +1,6 @@ # See https://github.com/restyled-io/restyled.io/wiki/Configuring-Restyled -enabled: true +enabled: false pull_requests: true diff --git a/src/simpleocv.h b/src/simpleocv.h index 19b8a7268..55ede15b7 100644 --- a/src/simpleocv.h +++ b/src/simpleocv.h @@ -124,7 +124,8 @@ struct Point_ { } - template operator Point_<_Tp2>() const + template + operator Point_<_Tp2>() const { return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); } @@ -148,7 +149,8 @@ struct Size_ { } - template operator Size_<_Tp2>() const + template + operator Size_<_Tp2>() const { return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); } @@ -176,7 +178,8 @@ struct Rect_ { } - template operator Rect_<_Tp2>() const + template + operator Rect_<_Tp2>() const { return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); } diff --git a/tests/test_packing.cpp b/tests/test_packing.cpp index 8bcc8a88d..1f65943a2 100644 --- a/tests/test_packing.cpp +++ b/tests/test_packing.cpp @@ -601,7 +601,7 @@ static int test_packing_0() || test_packing_gpu_image2buffer(a, 4, 8) || test_packing_gpu_image2buffer(a, 8, 4) #endif // NCNN_VULKAN - ; + ; } static int test_packing_1() @@ -656,7 +656,7 @@ static int test_packing_1() || test_packing_gpu_image2buffer(a, 4, 8) || test_packing_gpu_image2buffer(a, 8, 4) #endif // NCNN_VULKAN - ; + ; } static int test_packing_2() @@ -711,7 +711,7 @@ static int test_packing_2() || test_packing_gpu_image2buffer(a, 4, 8) || test_packing_gpu_image2buffer(a, 8, 4) #endif // NCNN_VULKAN - ; + ; } int main()