diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9c8eaaa..8ceee9d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -38,10 +38,7 @@ jobs: - name: Clang-Format working-directory: ${{github.workspace}}/ports/cpp - run: | - find source test -iname '*.hpp' -o -iname '*.cpp' \ - | xargs clang-format-18 -Werror --dry-run \ - --fallback-style=Google --verbose + run: sh ./ci/check-format.sh - name: Configure working-directory: ${{github.workspace}}/ports/cpp @@ -59,13 +56,9 @@ jobs: - name: Unit Test working-directory: ${{github.workspace}}/ports/cpp/build/test - run: | - ctest - cat Testing/Temporary/LastTest.log + run: sh ./ci/test.sh - name: Clang-Tidy on sources if: matrix.cmake_build_type == 'Release' working-directory: ${{github.workspace}}/ports/cpp - run: | - find source -iname '*.hpp' -o -iname '*.cpp' \ - | xargs clang-tidy-18 -p build/compile_commands.json + run: sh ./ci/check-style.sh diff --git a/ports/cpp/ci/check-format.sh b/ports/cpp/ci/check-format.sh new file mode 100755 index 0000000..9ec023a --- /dev/null +++ b/ports/cpp/ci/check-format.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +CLANG_FORMAT="clang-format" +if command -v clang-format-18 > /dev/null 2>&1; then + CLANG_FORMAT="clang-format-18" +fi + +find source test -iname '*.hpp' -o -iname '*.cpp' \ +| xargs "$CLANG_FORMAT" -Werror --dry-run \ + --fallback-style=Google --verbose diff --git a/ports/cpp/ci/check-style.sh b/ports/cpp/ci/check-style.sh new file mode 100644 index 0000000..600782d --- /dev/null +++ b/ports/cpp/ci/check-style.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +CLANG_TIDY="clang-tidy" +if command -v clang-tidy-18 > /dev/null 2>&1; then + CLANG_TIDY="clang-tidy-18" +fi + +find source -iname '*.hpp' -o -iname '*.cpp' \ +| xargs "$CLANG_TIDY" -p build/compile_commands.json diff --git a/ports/cpp/ci/test.sh b/ports/cpp/ci/test.sh new file mode 100644 index 0000000..8812865 --- /dev/null +++ b/ports/cpp/ci/test.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +cd "$(dirname "$0")"/../build/test + +ctest +if [ $? -ne 0 ]; then + cat Testing/Temporary/LastTest.log + exit 1 +fi + +set -e + +TESTS=" +whitebox +expr +cpp14 +" + +for test in $TESTS; do + for i in $(seq 5); do + (cd "./$test" && "./antlr4-c3-test-$test" --gtest_shuffle) + done +done