From c1fa368fb24e8c4064deda85ac6f1eb0001d2b32 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Sun, 31 Mar 2024 02:39:59 -0400 Subject: [PATCH 1/4] add CI in master so that it could run in next --- .github/.workflows/c-cpp.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/.workflows/c-cpp.yml diff --git a/.github/.workflows/c-cpp.yml b/.github/.workflows/c-cpp.yml new file mode 100644 index 000000000..dbfa35bef --- /dev/null +++ b/.github/.workflows/c-cpp.yml @@ -0,0 +1,67 @@ +name: C/C++ CI + +on: + push: + branches: [ "master", "next" ] + pull_request: + branches: [ "master", "next" ] + +jobs: + ubuntu: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install ninja-build tool + uses: seanmiddleditch/gha-setup-ninja@v4 + - name: cmake + run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -Wall -Wextra -Wpedantic -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -Werror" + - name: ninja + run: ninja + - name: ninja test + run: ninja test + + windows: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - uses: ilammy/msvc-dev-cmd@v1.4.1 + - name: cmake + run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="-fsanitize=address" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl + - name: ninja + run: ninja + - name: ninja test + run: ninja test + + windows-debug: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - uses: ilammy/msvc-dev-cmd@v1.4.1 + - name: cmake + run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="-fsanitize=address" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl + - name: ninja + run: ninja + - name: ninja test + run: ninja test + + #macos: + + # runs-on: macos-latest + + # steps: + # - uses: actions/checkout@v3 + # - name: Install ninja-build tool + # uses: seanmiddleditch/gha-setup-ninja@v4 + # - name: cmake + # run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -Wall -Wextra -Wpedantic -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -Werror" + # - name: ninja + # run: ninja + # - name: ninja test + # run: ninja test + From 36e384dcde8f518b520c6473f6607e691a9b0ff9 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Sun, 31 Mar 2024 02:41:30 -0400 Subject: [PATCH 2/4] renamed: .workflows/c-cpp.yml -> workflows/c-cpp.yml --- .github/{.workflows => workflows}/c-cpp.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{.workflows => workflows}/c-cpp.yml (100%) diff --git a/.github/.workflows/c-cpp.yml b/.github/workflows/c-cpp.yml similarity index 100% rename from .github/.workflows/c-cpp.yml rename to .github/workflows/c-cpp.yml From 73a659111eb0757ace4ac04b44d63336657cfd09 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Sun, 31 Mar 2024 02:46:51 -0400 Subject: [PATCH 3/4] add a pesudo test to make CI happy --- CMakeLists.txt | 9 +++++++++ tests/0002.printscan/CMakeLists.txt | 4 ++++ tests/CMakeLists.txt | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 tests/0002.printscan/CMakeLists.txt create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d243fa3a..cd2c59e4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,4 +97,13 @@ endforeach() else() endif() +endif() + +if(${ENABLE_TESTS}) +include(CTest) +include_directories(include) +if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "Cygwin" OR CMAKE_SYSTEM_NAME STREQUAL "Msys") +link_libraries(ntdll) +endif() +include(${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt) endif() \ No newline at end of file diff --git a/tests/0002.printscan/CMakeLists.txt b/tests/0002.printscan/CMakeLists.txt new file mode 100644 index 000000000..78f115395 --- /dev/null +++ b/tests/0002.printscan/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(print print.cc) +add_test(print print) +add_executable(scan scan.cc) +add_test(scan scan) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..e0c21314a --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,3 @@ +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_EXTENSIONS off) +add_subdirectory(tests/0002.printscan) From a13c3ed1cd6da64b381322f3466f3b4fc9a80ff2 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Sun, 31 Mar 2024 02:49:29 -0400 Subject: [PATCH 4/4] option missing --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd2c59e4d..49703a86d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,8 @@ endif() endif() +option(ENABLE_TESTS "Enable tests" OFF) + if(${ENABLE_TESTS}) include(CTest) include_directories(include)