From bfcc582b602ea8f7e7996de11e0763c5b58d9e7c Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 1 Jul 2020 17:52:35 -0400 Subject: [PATCH 1/9] Create documentation.yml --- .github/workflows/documentation.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/documentation.yml diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 000000000..0638c391d --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,24 @@ +name: Documentation CI + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: run doxygen + uses: mattnotmitt/doxygen-action@v1 + with: + working-directory: 'submodule/' + doxyfile-path: 'docs/Doxygen' + + - name: deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/html + force_orphan: true From d1c0a6712fa91a6a1a6b99da13ae039fdf8ab0cf Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 1 Jul 2020 17:53:43 -0400 Subject: [PATCH 2/9] Update documentation.yml --- .github/workflows/documentation.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 0638c391d..f412020e0 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -13,7 +13,6 @@ jobs: - name: run doxygen uses: mattnotmitt/doxygen-action@v1 with: - working-directory: 'submodule/' doxyfile-path: 'docs/Doxygen' - name: deploy From a4971496a0e53c2d66b506ba6fd661e3028ca439 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 1 Jul 2020 17:55:49 -0400 Subject: [PATCH 3/9] Update documentation.yml --- .github/workflows/documentation.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index f412020e0..dbe0a001f 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -12,8 +12,6 @@ jobs: - name: run doxygen uses: mattnotmitt/doxygen-action@v1 - with: - doxyfile-path: 'docs/Doxygen' - name: deploy uses: peaceiris/actions-gh-pages@v3 From 15ad4508851583f2b0f4049234f6860e1d230a69 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 1 Jul 2020 20:01:32 -0400 Subject: [PATCH 4/9] ignoring third party deps --- Doxyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index e3303d2b9..263466a7a 100644 --- a/Doxyfile +++ b/Doxyfile @@ -889,7 +889,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = *nlohmann*, *picojson* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the From 4425448e991901a5a680723faa2213f09af5a628 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 1 Jul 2020 22:37:40 -0400 Subject: [PATCH 5/9] tweak options --- Doxyfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doxyfile b/Doxyfile index 263466a7a..5921ff4a1 100644 --- a/Doxyfile +++ b/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "JWT-C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = 0.5.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -900,13 +900,13 @@ EXCLUDE_PATTERNS = *nlohmann*, *picojson* # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = jwt::details # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = examples # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -1666,7 +1666,7 @@ EXTRA_SEARCH_MAPPINGS = # If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output. # The default value is: YES. -GENERATE_LATEX = YES +GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of From e47a39fd4d11237c5282b06c8e5d6581b6aff9ff Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Sun, 5 Jul 2020 21:04:59 -0400 Subject: [PATCH 6/9] Create coverage.yml --- .github/workflows/coverage.yml | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..edcbb3bb5 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,39 @@ +name: C/C++ CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: install cmake + uses: lukka/get-cmake@v3.17.2 + + - name: configure + run: | + sudo apt update + sudo apt install libgtest-dev lcov + (cd /usr/src/gtest && sudo `which cmake` .) + sudo make -C /usr/src/gtest + sudo ln -s /usr/src/gtest/libgtest.a /usr/lib/libgtest.a + sudo ln -s /usr/src/gtest/libgtest_main.a /usr/lib/libgtest_main.a + mkdir build + cd build + cmake .. -DBUILD_TESTS=ON -DCOVERAGE=ON -DCMAKE_BUILD_TYPE=Debug + + - name: make + run: make jwt-cpp-test coverage + + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v1.1.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: build/coverage.info From 22e43afba89e2410229a38ec7a342edcfd95d042 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Sun, 5 Jul 2020 21:43:09 -0400 Subject: [PATCH 7/9] adding coverage testing (#2) * adding coverage testing surprisingly: Overall coverage rate: lines......: 80.6% (519 of 644 lines) functions..: 92.5% (235 of 254 functions) * Update coverage.yml --- .github/workflows/coverage.yml | 2 +- CMakeLists.txt | 3 +++ cmake/code-coverage.cmake | 15 +++++++++++++++ tests/CMakeLists.txt | 9 +++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 cmake/code-coverage.cmake diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index edcbb3bb5..0f3f30b3a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,7 +30,7 @@ jobs: cmake .. -DBUILD_TESTS=ON -DCOVERAGE=ON -DCMAKE_BUILD_TYPE=Debug - name: make - run: make jwt-cpp-test coverage + run: cd build && make jwt-cpp-test coverage - name: Coveralls GitHub Action uses: coverallsapp/github-action@v1.1.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e7e45931..136056db3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ if(CMAKE_TOOLCHAIN_FILE) endif() option(BUILD_TESTS "Configure CMake to build tests (or not)" ON) +option(COVERAGE "Enable code coverage testing" OFF) option(EXTERNAL_PICOJSON "Use find_package() to locate the picojson header" OFF) option(DISABLE_JWT_CPP_BASE64 "Do not include the base64 implementation from this library" OFF) @@ -16,6 +17,8 @@ project(jwt-cpp) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + find_package(OpenSSL 1.0.2 REQUIRED) if(EXTERNAL_PICOJSON) diff --git a/cmake/code-coverage.cmake b/cmake/code-coverage.cmake new file mode 100644 index 000000000..fd7da29ca --- /dev/null +++ b/cmake/code-coverage.cmake @@ -0,0 +1,15 @@ +set(COVERAGE_CMAKE "${CMAKE_BINARY_DIR}/cmake/CodeCoverage.cmake") +if(NOT EXISTS ${COVERAGE_CMAKE}) + set(COVERAGE_URL + "https://raw.githubusercontent.com/bilke/cmake-modules/master/CodeCoverage.cmake" + ) + file(DOWNLOAD ${COVERAGE_URL} ${COVERAGE_CMAKE}) +endif() + +include(${COVERAGE_CMAKE}) + +function(setup_coverage TARGET) + target_compile_options(${TARGET} PRIVATE -g -O0 -fprofile-arcs + -ftest-coverage) + target_link_libraries(${TARGET} PRIVATE gcov) +endfunction() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c0060b9d8..22e3b6f1f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -35,3 +35,12 @@ target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp::jwt-cpp GTest::GTest GTest::Main pthread) gtest_add_tests(TARGET jwt-cpp-test) + +if(${COVERAGE}) + include("code-coverage") + setup_coverage(jwt-cpp-test) + + set(COVERAGE_EXCLUDES "/usr/**" "/home/*/.conan/**" "*test*" "*build*" "*json*") + setup_target_for_coverage_lcov(NAME coverage EXECUTABLE + ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test) +endif() From 191b3cf216a211020e3d2e9f92a746e4417571c7 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Sun, 5 Jul 2020 21:49:17 -0400 Subject: [PATCH 8/9] adding coverage badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 611c41683..2792dd806 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/5f7055e294744901991fd0a1620b231d)](https://app.codacy.com/app/Thalhammer/jwt-cpp?utm_source=github.com&utm_medium=referral&utm_content=Thalhammer/jwt-cpp&utm_campaign=Badge_Grade_Settings) [![Build Status](https://travis-ci.com/Thalhammer/jwt-cpp.svg?branch=master)](https://travis-ci.com/Thalhammer/jwt-cpp) +[![Coverage Status](https://coveralls.io/repos/github/prince-chrismc/jwt-cpp/badge.svg?branch=master)](https://coveralls.io/github/prince-chrismc/jwt-cpp?branch=master) A header only library for creating and validating json web tokens in c++. From 98e767f019184b48b495ed10ada47effb59c9a9f Mon Sep 17 00:00:00 2001 From: Dominik Thalhammer Date: Mon, 6 Jul 2020 12:19:17 +0200 Subject: [PATCH 9/9] Change coverage url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2792dd806..741691a35 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/5f7055e294744901991fd0a1620b231d)](https://app.codacy.com/app/Thalhammer/jwt-cpp?utm_source=github.com&utm_medium=referral&utm_content=Thalhammer/jwt-cpp&utm_campaign=Badge_Grade_Settings) [![Build Status](https://travis-ci.com/Thalhammer/jwt-cpp.svg?branch=master)](https://travis-ci.com/Thalhammer/jwt-cpp) -[![Coverage Status](https://coveralls.io/repos/github/prince-chrismc/jwt-cpp/badge.svg?branch=master)](https://coveralls.io/github/prince-chrismc/jwt-cpp?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/Thalhammer/jwt-cpp/badge.svg?branch=master)](https://coveralls.io/github/Thalhammer/jwt-cpp?branch=master) A header only library for creating and validating json web tokens in c++.