Skip to content

Commit

Permalink
Merge branch 'master' into wolfssl-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-chrismc authored Jun 15, 2024
2 parents b4352e8 + a6927cb commit 871af79
Show file tree
Hide file tree
Showing 15 changed files with 351 additions and 80 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ jobs:

- name: setup
run: |
mkdir build
cd build
cmake .. -DJWT_BUILD_EXAMPLES=OFF
sudo make install
cmake --preset release
sudo cmake --build --preset release --target install
- name: test
working-directory: tests/cmake
Expand Down Expand Up @@ -95,6 +93,29 @@ jobs:
cmake . -DTEST:STRING="defaults-enabled"
cmake --build .
preset-support-but-not-enough:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install/cmake
with:
version: "3.24.4"
url: "https://cmake.org/files/v3.24/cmake-3.24.4.tar.gz"
- uses: ./.github/actions/install/gtest

- name: setup
run: |
mkdir build
cd build
cmake .. -DJWT_BUILD_EXAMPLES=ON -DJWT_BUILD_TESTS=ON
sudo make install
- name: test
run: |
cd tests/cmake
cmake . -DTEST:STRING="defaults-enabled"
cmake --build .
custom-install-linux:
runs-on: ubuntu-latest
steps:
Expand All @@ -117,7 +138,7 @@ jobs:
root-hint-install-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest

- name: setup
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,17 @@ jobs:

steps:
- uses: actions/checkout@v4
- run: cmake -E make_directory ${{ github.workspace }}/build

- name: configure
shell: bash # access regardless of the host operating system
working-directory: ${{ github.workspace }}/build
run: cmake $GITHUB_WORKSPACE -DJWT_BUILD_EXAMPLES=ON
run: cmake --preset examples

- name: build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build .
run: cmake --build --preset examples

- name: test
run: |
cmake --build build/ --target rsa-create-run
cmake --build build/ --target rsa-verify-run
cmake --build --preset examples --target rsa-create-run
cmake --build --preset examples --target rsa-verify-run
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
Expand Down
71 changes: 26 additions & 45 deletions .github/workflows/jwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ jobs:
- uses: ./.github/actions/install/open-source-parsers-jsoncpp

- name: configure
run: |
mkdir build
cd build
cmake .. -DJWT_BUILD_EXAMPLES=OFF -DJWT_BUILD_TESTS=ON -DJWT_ENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug
run: cmake --preset coverage
- name: run
working-directory: build
run: make jwt-cpp-test coverage
run: cmake --build --preset coverage

- uses: coverallsapp/github-action@v2
with:
Expand All @@ -38,21 +33,19 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- uses: ./.github/actions/install/gtest

- name: configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DJWT_ENABLE_FUZZING=ON
run: cmake --preset ci-fuzzing
- name: build
run: cmake --build --preset ci-fuzzing

- name: run
run: |
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
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: # Based on https://gist.github.com/jlblancoc/44be9d4d466f0a973b1f3808a8e56782
asan:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -69,46 +62,34 @@ jobs:
version: ${{ matrix.openssl.tag }}

- name: configure
run: |
mkdir build
cd build
cmake .. -DJWT_BUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=leak -g" \
-DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak -g" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" \
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak"
run: cmake --preset ci-asan
- name: build
run: cmake --build --preset ci-asan

- name: run
working-directory: build
run: |
make
export ASAN_OPTIONS=check_initialization_order=true:detect_stack_use_after_return=true:fast_unwind_on_malloc=0
./example/rsa-create
./example/rsa-verify
./example/jwks-verify
./tests/jwt-cpp-test
cmake --build --preset ci-asan --target private-claims-run
cmake --build --preset ci-asan --target rsa-create-run
cmake --build --preset ci-asan --target rsa-verify-run
cmake --build --preset ci-asan --target jwks-verify-run
cmake --build --preset ci-asan --target jwt-cpp-test-run
ubsan:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- uses: ./.github/actions/install/gtest

- name: configure
run: |
mkdir build
cd build
cmake .. -DJWT_BUILD_TESTS=ON -DCMAKE_CXX_STANDARD=20 \
-DCMAKE_CXX_FLAGS="-fsanitize=undefined -fsanitize=return -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize-recover=all -g" \
-DCMAKE_C_FLAGS="-fsanitize=undefined -fsanitize=return -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize-recover=all -g" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=undefined -fsanitize=return -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize-recover=all" \
-DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=undefined -fsanitize=return -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize-recover=all"
run: cmake --preset ci-ubsan
- name: build
run: cmake --build --preset ci-ubsan -DCMAKE_CXX_STANDARD=20

- name: run
working-directory: build
run: |
make
export UBSAN_OPTIONS=print_stacktrace=1
./example/rsa-create
./example/rsa-verify
./tests/jwt-cpp-test
cmake --build --preset ci-ubsan --target private-claims-run
cmake --build --preset ci-ubsan --target rsa-create-run
cmake --build --preset ci-ubsan --target rsa-verify-run
cmake --build --preset ci-ubsan --target jwks-verify-run
cmake --build --preset ci-ubsan --target jwt-cpp-test-run
10 changes: 3 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
matrix:
files: ["**/CMakeLists.txt", "cmake/code-coverage.cmake"]
steps:
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- run: pip install cmakelang
Expand All @@ -54,13 +54,9 @@ jobs:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v4
- name: configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-fix"
run: cmake --preset examples -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-fix"
- name: run
working-directory: build
run: make
run: cmake --build --preset examples
- uses: ./.github/actions/process-linting-results
with:
linter_name: clang-tidy
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
version: ${{ matrix.openssl.tag }}

- name: configure
run: cmake . -DJWT_BUILD_TESTS=ON -DOPENSSL_ROOT_DIR=/tmp
- run: make
run: cmake --preset unit-tests -DOPENSSL_ROOT_DIR=/tmp
- run: cmake --build --preset unit-tests
- name: test
run: ./tests/jwt-cpp-test
run: ctest --preset unit-tests

- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
Expand All @@ -50,8 +50,10 @@ jobs:
version: "openssl-3.0.5"

- name: configure
run: cmake . -DJWT_BUILD_TESTS=ON -DOPENSSL_ROOT_DIR=/tmp -DCMAKE_CXX_FLAGS="-DOPENSSL_NO_DEPRECATED=1" -DCMAKE_C_FLAGS="-DOPENSSL_NO_DEPRECATED=1"
- run: make
run: cmake --preset unit-tests -DOPENSSL_ROOT_DIR=/tmp -DCMAKE_CXX_FLAGS="-DOPENSSL_NO_DEPRECATED=1" -DCMAKE_C_FLAGS="-DOPENSSL_NO_DEPRECATED=1"
- run: cmake --build --preset unit-tests
- name: test
run: ctest --preset unit-tests

libressl:
runs-on: ubuntu-latest
Expand All @@ -69,10 +71,10 @@ jobs:
version: ${{ matrix.libressl }}

- name: configure
run: cmake . -DJWT_BUILD_TESTS=ON -DJWT_SSL_LIBRARY:STRING=LibreSSL
- run: make
run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=LibreSSL
- run: cmake --build --preset unit-tests
- name: test
run: ./tests/jwt-cpp-test
run: ctest --preset unit-tests

- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
Expand Down Expand Up @@ -100,10 +102,10 @@ jobs:
version: ${{ matrix.wolfssl.ref }}

- name: configure
run: cmake . -DJWT_BUILD_TESTS=ON -DJWT_SSL_LIBRARY:STRING=wolfSSL
- run: make
run: cmake --preset unit-tests -DJWT_SSL_LIBRARY:STRING=wolfSSL
- run: cmake --build --preset unit-tests
- name: test
run: ./tests/jwt-cpp-test
run: ctest --preset unit-tests

- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,15 @@ $RECYCLE.BIN/
test
*.o
*.o.d
.vscode

# IDE-specific files
.vscode/
.vscode/!extensions.json # Allow to provide recommended extensions

# ClangD cache files
.cache

build/*
package-lock.json

CMakeUserPresets.json
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cmake-tools",
"twxs.cmake",
"matepek.vscode-catch2-test-adapter",
"GitHub.vscode-github-actions"
]
}
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ if(JWT_BUILD_EXAMPLES)
endif()

if(JWT_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

Expand Down
33 changes: 33 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"include": [
"example/CMakePresets.json",
"tests/CMakePresets.json"
],
"configurePresets": [
{
"name": "dev",
"displayName": "Development",
"inherits": "debug",
"environment": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"cacheVariables": {
"JWT_BUILD_EXAMPLES": "ON",
"JWT_BUILD_TESTS": "ON"
}
}
],
"buildPresets": [
{
"name": "dev",
"configurePreset": "dev",
"configuration": "Debug"
}
]
}
48 changes: 48 additions & 0 deletions cmake/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"hidden": true,
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"JWT_BUILD_EXAMPLES": "OFF",
"JWT_BUILD_TESTS": "OFF"
}
},
{
"name": "debug",
"displayName": "Debug",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"displayName": "Release",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug",
"configuration": "Debug"
},
{
"name": "release",
"configurePreset": "release",
"configuration": "Release"
}
]
}
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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_custom_target(private-claims-run COMMAND private-claims)

add_executable(rsa-create rsa-create.cpp)
target_link_libraries(rsa-create jwt-cpp::jwt-cpp)
Expand Down
Loading

0 comments on commit 871af79

Please sign in to comment.