Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/actions/install/gcovr/action.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/actions/install/gtest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions .github/actions/install/lcov/action.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 17 additions & 13 deletions .github/workflows/jwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ 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-lcov
# run: cmake --build --preset coverage
- name: run
run: cmake --build --preset coverage

Expand All @@ -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
Expand Down
27 changes: 26 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading