diff --git a/.clang-tidy b/.clang-tidy index 4c3c4f0..becaa65 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,3 +3,5 @@ Checks: > CheckOptions: - {key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp, value: expr-type} + +HeaderFilterRegex: 'inc/.*' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eeea9ea..972b1ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,71 @@ -name: CI - on: [push, pull_request] jobs: - tests: + asan: + runs-on: ${{matrix.os}} + name: AddressSanitization + strategy: + matrix: + os: ["ubuntu-latest"] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install gtest + run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a + + - name: Write files + env: + FILE_ONE: ${{ secrets.KRM_MAIN_FILE }} + FILE_TWO: ${{ secrets.KRM_SCND_FILE }} + run: | + echo "${FILE_ONE}" | base64 --decode > ${HOME}/key.pem | + echo "${FILE_TWO}" | base64 --decode > ${HOME}/scert.crt + + - name: build_asan + run: | + cmake . -B ${{github.workspace}}/asanbuild -DCMAKE_BUILD_TYPE=ASAN + cmake --build ${{github.workspace}}/asanbuild --config ASAN + + codeql: + runs-on: ubuntu-latest + name: CodeQL + strategy: + matrix: + language: ["cpp"] + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Install gtest manually + run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a + + - name: Build + run: | + echo "Run, Build Application using script" + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release + cmake --build ${{github.workspace}}/build --config Release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" + + pipeline: + name: Pipeline runs-on: ${{matrix.os}} strategy: matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] + os: ["ubuntu-latest", "windows-latest"] BUILDTYPE: ["Debug", "Release"] include: - os: "ubuntu-latest" @@ -29,6 +87,14 @@ jobs: - os: "ubuntu-latest" cppstd: "20" deps: "lcov" + cc: gcc + cxx: g++ + coverage: "-DCOVERAGE=ON" + - os: "ubuntu-latest" + cppstd: "20" + deps: "lcov" + cc: clang + cxx: clang++ coverage: "-DCOVERAGE=ON" - os: "windows-latest" cppstd: "20" @@ -38,36 +104,34 @@ jobs: steps: - uses: actions/checkout@v3 - - name: install_ubuntu_deps + - name: build_ubuntu env: FILE_ONE: ${{ secrets.KRM_MAIN_FILE }} FILE_TWO: ${{ secrets.KRM_SCND_FILE }} if: ${{ matrix.os == 'ubuntu-latest' }} run: | - sudo apt-get install libgtest-dev openssl clang-tidy && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a | - echo "${FILE_ONE}" | base64 --decode > ${HOME}/key.pem | + sudo apt-get install libgtest-dev openssl clang-tidy && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a + echo "${FILE_ONE}" | base64 --decode > ${HOME}/key.pem echo "${FILE_TWO}" | base64 --decode > ${HOME}/scert.crt + cmake . -B ${{github.workspace}}/build -DCMAKE_C_COMPILER=${{ matrix.cc }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{ matrix.BUILDTYPE }} \ + -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} + cmake --build ${{github.workspace}}/build --config ${{ matrix.BUILDTYPE }} + ctest -VV --test-dir ${{github.workspace}}/build -C ${{ matrix.BUILDTYPE}} - - name: install_windows_deps + - name: windows_uses if: ${{ matrix.os == 'windows-latest' }} + uses: MarkusJx/googletest-installer@v1.1 + + - name: build_windows env: FILE_ONE: ${{ secrets.KRM_WIN_MAIN_FILE }} FILE_TWO: ${{ secrets.KRM_WIN_SCND_FILE }} + if: ${{ matrix.os == 'windows-latest' && matrix.BUILDTYPE == 'Release' }} # windows debug isn't working with gtest run: | - echo "${FILE_ONE}" | openssl base64 -d > ${HOME}/privatekey.key | - echo "${FILE_TWO}" | openssl base64 -d > ${HOME}/certificate.crt | + echo "${FILE_ONE}" | openssl base64 -d > ${HOME}/privatekey.key + echo "${FILE_TWO}" | openssl base64 -d > ${HOME}/certificate.crt choco install openssl - - - name: windows_uses - if: ${{ matrix.os == 'windows-latest' }} - uses: MarkusJx/googletest-installer@v1.1.1 - - - name: build - run: | - cmake . -B ${{github.workspace}}/build -DCMAKE_C_COMPILER=${{ matrix.cc }} \ - -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_BUILD_TYPE=${{ matrix.BUILDTYPE }} \ - -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} + cmake . -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.BUILDTYPE }} cmake --build ${{github.workspace}}/build --config ${{ matrix.BUILDTYPE }} - - - name: test - run: ctest -VV --test-dir ${{github.workspace}}/build -C ${{ matrix.BUILDTYPE}} + ctest -VV --test-dir ${{github.workspace}}/build -C ${{ matrix.BUILDTYPE}} diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index ac7b8b4..9b616e2 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -31,7 +31,7 @@ jobs: ctest -VV --test-dir ${{github.workspace}}/build -C Debug - name: Generate a code coverage report - uses: threeal/gcovr-action@latest + uses: threeal/gcovr-action@v1.1.0 with: gcov-executable: llvm-cov gcov @@ -59,7 +59,7 @@ jobs: ctest -VV --test-dir ${{github.workspace}}/build -C Release - name: Generate a code coverage report - uses: threeal/gcovr-action@latest + uses: threeal/gcovr-action@v1.1.0 with: gcov-executable: llvm-cov gcov \ No newline at end of file diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index e9a9b68..ff98d1d 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -20,7 +20,7 @@ jobs: verbose: true - name: Upload report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: report path: output diff --git a/.github/workflows/profile.yml b/.github/workflows/profile.yml index b7e1928..0eca16f 100644 --- a/.github/workflows/profile.yml +++ b/.github/workflows/profile.yml @@ -37,7 +37,7 @@ jobs: run: ctest -VV -C Coverage - name: Generate Test Report - uses: threeal/gcovr-action@latest + uses: threeal/gcovr-action@v1.1.0 with: coveralls-send: true github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 81d51c4..eed31f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION ${CPPSOCKET_CMAKECONFIG_INSTALL_DIR}) -option(BUILD_TESTS "Whether or not to build the tests" OFF) +option(BUILD_TESTS "Whether or not to build the tests" ON) if (BUILD_TESTS) enable_testing() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0d40df2..0ff831e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,11 +18,13 @@ if(CMAKE_COMPILER_IS_GNUCXX) find_package(OpenSSL REQUIRED) find_package(GTest REQUIRED) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "debug") - set(CMAKE_CXX_FLAGS "-Wall /O0 -g /std:c++20") + set(CMAKE_CXX_FLAGS "-Wall /MDd /std:c++20") + elseif(CMAKE_BUILD_TYPE STREQUAL "ASAN") + message(STATUS "Address sanitization") + set(CMAKE_CXX_FLAGS "-Wall /MDd /fsanitize=address /std:c++20") else() - set(CMAKE_CXX_FLAGS "-Wall /O2 -g /std:c++20") + set(CMAKE_CXX_FLAGS "-Wall /MD /std:c++20") endif() if(DEFINED ENV{CI}) message(STATUS "MSVC Action")