From 57033849143ed1745c4c90294d073598bbd71b21 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 18 Aug 2025 21:31:59 +0000 Subject: [PATCH 1/2] fixed CI/CD by changing lcov to gcovr made the action run on fix/CI_CD typo fix added lcov dependency made lcov a separate action added gcovr as alternative to the lcov that doesn't work well with macro coverage errors ignoring made full switch to gcovr removed lcov and glaze that was from other pr fix of wrong configuring of preset possible fix fix made gcovr generate .info file fix made cmake use current binary dir propper syntax for output file tried fixing build folder inclusion naming fix switched to the new coverage --- .github/actions/install/gcovr/action.yml | 22 +++++++++++++++ .github/actions/install/gtest/action.yml | 2 +- .github/actions/install/lcov/action.yml | 34 ++++++++++++++++++++++++ .github/workflows/jwt.yml | 32 ++++++++++++---------- tests/CMakeLists.txt | 27 ++++++++++++++++++- 5 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 .github/actions/install/gcovr/action.yml create mode 100644 .github/actions/install/lcov/action.yml diff --git a/.github/actions/install/gcovr/action.yml b/.github/actions/install/gcovr/action.yml new file mode 100644 index 000000000..f4ab5ce8f --- /dev/null +++ b/.github/actions/install/gcovr/action.yml @@ -0,0 +1,22 @@ +name: Install gcovr +description: Install gcovr for generating coverage reports + +inputs: + version: + description: gcovr version to install + required: false + default: "8.3" # pick the latest stable version + +runs: + using: composite + steps: + - name: Install Python and pip + run: | + sudo apt-get install -y python3 python3-pip + shell: bash + + - name: Install gcovr + run: | + python3 -m pip install --upgrade pip + python3 -m pip install gcovr==${{ inputs.version }} + shell: bash diff --git a/.github/actions/install/gtest/action.yml b/.github/actions/install/gtest/action.yml index 11a6c5f34..4b4008f65 100644 --- a/.github/actions/install/gtest/action.yml +++ b/.github/actions/install/gtest/action.yml @@ -3,7 +3,7 @@ description: Install and setup GTest for linking and building test application runs: using: composite steps: - - run: sudo apt-get install libgtest-dev lcov + - run: sudo apt-get install libgtest-dev # lcov shell: bash - run: (cd /usr/src/gtest && sudo `which cmake` .) shell: bash diff --git a/.github/actions/install/lcov/action.yml b/.github/actions/install/lcov/action.yml new file mode 100644 index 000000000..f90c471ea --- /dev/null +++ b/.github/actions/install/lcov/action.yml @@ -0,0 +1,34 @@ +name: Install lcov +description: Install lcov from official tarball and required Perl modules + +inputs: + version: + description: The lcov version to install + required: false + default: "2.3.1" + +runs: + using: composite + steps: + - name: Install system dependencies + run: | + sudo apt-get install -y \ + libcapture-tiny-perl \ + libdatetime-perl \ + libfile-slurp-perl \ + libfile-copy-recursive-perl \ + libsort-naturally-perl + shell: bash + + - name: Download lcov tarball + run: | + cd /tmp + wget https://github.com/linux-test-project/lcov/releases/download/v${{ inputs.version }}/lcov-${{ inputs.version }}.tar.gz + tar -zxf lcov-${{ inputs.version }}.tar.gz + shell: bash + + - name: Build and install lcov + run: | + cd /tmp/lcov-${{ inputs.version }} + sudo make install + shell: bash diff --git a/.github/workflows/jwt.yml b/.github/workflows/jwt.yml index 46eed9718..b9764b624 100644 --- a/.github/workflows/jwt.yml +++ b/.github/workflows/jwt.yml @@ -13,13 +13,17 @@ jobs: - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest - uses: ./.github/actions/install/gtest + # - uses: ./.github/actions/install/lcov + - uses: ./.github/actions/install/gcovr - uses: ./.github/actions/install/danielaparker-jsoncons - uses: ./.github/actions/install/boost-json - uses: ./.github/actions/install/open-source-parsers-jsoncpp - name: configure run: cmake --preset coverage - - name: run + # - name: run-lcov + # run: cmake --build --preset coverage + - name: run-gcovr run: cmake --build --preset coverage - uses: coverallsapp/github-action@v2 @@ -31,19 +35,19 @@ jobs: fuzzing: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: lukka/get-cmake@latest - - - name: configure - run: cmake --preset ci-fuzzing - - name: build - run: cmake --build --preset ci-fuzzing - - - name: run - run: | - cmake --build --preset ci-fuzzing --target jwt-cpp-fuzz-BaseEncodeFuzz-run - cmake --build --preset ci-fuzzing --target jwt-cpp-fuzz-BaseDecodeFuzz-run - cmake --build --preset ci-fuzzing --target jwt-cpp-fuzz-TokenDecodeFuzz-run + - uses: actions/checkout@v4 + - uses: lukka/get-cmake@latest + + - name: configure + run: cmake --preset ci-fuzzing + - name: build + run: cmake --build --preset ci-fuzzing + + - name: run + run: | + cmake --build --preset ci-fuzzing --target jwt-cpp-fuzz-BaseEncodeFuzz-run + cmake --build --preset ci-fuzzing --target jwt-cpp-fuzz-BaseDecodeFuzz-run + cmake --build --preset ci-fuzzing --target jwt-cpp-fuzz-TokenDecodeFuzz-run asan: runs-on: ubuntu-latest diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6c7b75504..7251868c3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -81,5 +81,30 @@ if(JWT_ENABLE_COVERAGE) setup_coverage(jwt-cpp-test) set(COVERAGE_EXCLUDES "/usr/**" "/home/*/.conan/**" "*test*" "*build*" "**/nlohmann/json.hpp" "**/picojson/picojson.h" "*boost*" "*jsoncons*") - setup_target_for_coverage_lcov(NAME coverage EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test) + + # --- LCOV target with ignore flags --- + # setup_target_for_coverage_lcov( + # NAME coverage + # EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test + # EXCLUDE ${COVERAGE_EXCLUDES} + # LCOV_ARGS --ignore-errors inconsistent,mismatch,unused,count + # ) + + # --- GCOVR target --- + add_custom_target(coverage + COMMAND ${CMAKE_COMMAND} -E echo "Running gcovr coverage..." + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$ENV{PYTHONPATH} gcovr + -r ${CMAKE_SOURCE_DIR} + --lcov=${CMAKE_BINARY_DIR}/coverage.info + --exclude '.*test.*' + --exclude '/.*/build/' + --exclude '.*nlohmann/json.hpp' + --exclude '.*picojson/picojson.h' + --exclude '.*boost.*' + --exclude '.*jsoncons.*' + DEPENDS jwt-cpp-test + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generate coverage report with gcovr" + ) endif() From 01947578ecbb4e4fa2c97f2d8840ad693327a9f2 Mon Sep 17 00:00:00 2001 From: StormLord07 Date: Mon, 18 Aug 2025 23:46:41 +0000 Subject: [PATCH 2/2] changed name back to run --- .github/workflows/jwt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jwt.yml b/.github/workflows/jwt.yml index b9764b624..85b9b504f 100644 --- a/.github/workflows/jwt.yml +++ b/.github/workflows/jwt.yml @@ -23,7 +23,7 @@ jobs: run: cmake --preset coverage # - name: run-lcov # run: cmake --build --preset coverage - - name: run-gcovr + - name: run run: cmake --build --preset coverage - uses: coverallsapp/github-action@v2