Skip to content

Commit

Permalink
Add addition CMake "run" targets to simplify calling exes (#344)
Browse files Browse the repository at this point in the history
* Add addition CMake "run" targets to simplify calling exes

* fix bad replace
  • Loading branch information
prince-chrismc authored Apr 22, 2024
1 parent e9cd684 commit f698216
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
sudo make install
- name: test
working-directory: tests/cmake
run: |
cd tests/cmake
cmake . -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1
cmake --build .
Expand All @@ -43,12 +43,12 @@ jobs:
run: |
mkdir build
cd build
cmake ..
cmake .. -DJWT_BUILD_EXAMPLES=ON
sudo cmake --install .
- name: test
working-directory: tests/cmake
run: |
cd tests/cmake
cmake . -DTEST:STRING="defaults-enabled"
cmake --build .
Expand Down Expand Up @@ -114,6 +114,25 @@ jobs:
cmake . -DCMAKE_PREFIX_PATH="/opt/jwt-cpp" -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1
cmake --build .
root-hint-install-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: lukka/get-cmake@latest

- name: setup
run: |
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:STRING="/opt/jwt-cpp" -DJWT_BUILD_EXAMPLES=OFF
make install
- name: test
run: |
cd tests/cmake
cmake . -Djwt-cpp_ROOT="/opt/jwt-cpp" -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1
cmake --build .
custom-install-win:
runs-on: windows-latest
steps:
Expand Down Expand Up @@ -214,7 +233,7 @@ jobs:
cmake . -DTEST:STRING="wolfssl-is-used"
cmake --build .
with-hunter:
with-hunter: # This is actually testing the integration with the package management
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@ jobs:
shell: bash
run: cmake --build .

- if: matrix.os != 'windows-latest'
name: test
working-directory: ${{ github.workspace }}/build
shell: bash
run: |
./example/rsa-create
./example/rsa-verify
- if: matrix.os == 'windows-latest'
name: test
working-directory: ${{ github.workspace }}/build
- name: test
run: |
example\Debug\rsa-create.exe
example\Debug\rsa-verify.exe
cmake --build build/ --target rsa-create-run
cmake --build build/ --target rsa-verify-run
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/jwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ jobs:
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DJWT_ENABLE_FUZZING=ON
- name: run
working-directory: build
run: |
make jwt-cpp-fuzz-BaseEncodeFuzz jwt-cpp-fuzz-BaseDecodeFuzz jwt-cpp-fuzz-TokenDecodeFuzz
./tests/fuzz/jwt-cpp-fuzz-BaseEncodeFuzz -runs=100000
./tests/fuzz/jwt-cpp-fuzz-BaseDecodeFuzz -runs=100000 ../tests/fuzz/decode-corpus
./tests/fuzz/jwt-cpp-fuzz-TokenDecodeFuzz -runs=100000 ../tests/fuzz/token-corpus
cmake --build build/ --target jwt-cpp-fuzz-BaseEncodeFuzz-run
cmake --build build/ --target jwt-cpp-fuzz-BaseDecodeFuzz-run
cmake --build build/ --target jwt-cpp-fuzz-TokenDecodeFuzz-run
asan: # Based on https://gist.github.com/jlblancoc/44be9d4d466f0a973b1f3808a8e56782
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nuget CD
name: Release CD

on:
# Allows you to run this workflow manually from the Actions tab
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
mkdir build
cd build
cmake ..
cmake --build .
cmake --install .
- name: test
working-directory: tests/cmake
Expand All @@ -45,6 +46,7 @@ jobs:
cmake --build .
gcc-12:
name: GCC 12
runs-on: ubuntu-latest
container:
image: ubuntu:jammy-20231004 # 22.04
Expand All @@ -66,6 +68,7 @@ jobs:
mkdir build
cd build
cmake ..
cmake --build .
cmake --install .
- name: test
Expand Down
4 changes: 4 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ endif()

add_executable(print-claims print-claims.cpp)
target_link_libraries(print-claims jwt-cpp::jwt-cpp)
add_custom_target(print-claims-run COMMAND print-claims)

add_executable(private-claims private-claims.cpp)
target_link_libraries(private-claims jwt-cpp::jwt-cpp)

add_executable(rsa-create rsa-create.cpp)
target_link_libraries(rsa-create jwt-cpp::jwt-cpp)
add_custom_target(rsa-create-run COMMAND rsa-create)

add_executable(rsa-verify rsa-verify.cpp)
target_link_libraries(rsa-verify jwt-cpp::jwt-cpp)
add_custom_target(rsa-verify-run COMMAND rsa-verify)

add_executable(jwks-verify jwks-verify.cpp)
target_link_libraries(jwks-verify jwt-cpp::jwt-cpp)
add_custom_target(jwks-verify-run COMMAND jwks-verify)

add_executable(es256k es256k.cpp)
target_link_libraries(es256k jwt-cpp::jwt-cpp)
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp nlohmann_json::nlohmann_json
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${CMAKE_DL_LIBS}>)

gtest_discover_tests(jwt-cpp-test)
add_custom_target(jwt-cpp-test-run COMMAND jwt-cpp-test)

if(JWT_ENABLE_COVERAGE)
include("code-coverage")
Expand Down
18 changes: 11 additions & 7 deletions tests/fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ endif()
function(ADD_FUZZING_EXECUTABLE TARGET)
add_executable(jwt-cpp-fuzz-${TARGET} "${TARGET}.cpp")
target_compile_options(
jwt-cpp-fuzz-${TARGET}
PRIVATE -g -O1 -fsanitize=fuzzer,address,signed-integer-overflow,undefined
-fno-omit-frame-pointer)
target_link_options(
jwt-cpp-fuzz-${TARGET} PRIVATE
-fsanitize=fuzzer,address,signed-integer-overflow,undefined
-fno-omit-frame-pointer)
jwt-cpp-fuzz-${TARGET} PRIVATE -g -O1 -fsanitize=fuzzer,address,signed-integer-overflow,undefined
-fno-omit-frame-pointer)
target_link_options(jwt-cpp-fuzz-${TARGET} PRIVATE -fsanitize=fuzzer,address,signed-integer-overflow,undefined
-fno-omit-frame-pointer)
target_link_libraries(jwt-cpp-fuzz-${TARGET} PRIVATE jwt-cpp::jwt-cpp)
endfunction()

add_fuzzing_executable(BaseEncodeFuzz)
add_custom_target(jwt-cpp-fuzz-BaseEncodeFuzz-run COMMAND jwt-cpp-fuzz-BaseEncodeFuzz -runs=100000)

add_fuzzing_executable(BaseDecodeFuzz)
add_custom_target(jwt-cpp-fuzz-BaseDecodeFuzz-run COMMAND jwt-cpp-fuzz-BaseDecodeFuzz -runs=100000 decode-corpus
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

add_fuzzing_executable(TokenDecodeFuzz)
add_custom_target(jwt-cpp-fuzz-TokenDecodeFuzz-run COMMAND jwt-cpp-fuzz-TokenDecodeFuzz -runs=100000 token-corpus
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

0 comments on commit f698216

Please sign in to comment.