Skip to content

Commit

Permalink
Merge branch 'master' into bump-ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-chrismc authored Jun 19, 2024
2 parents e8d257d + a6927cb commit 9a51feb
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 84 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,21 +14,16 @@ 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: MSBUILD_VERBOSITY=Diagnostic cmake --build .
run: MSBUILD_VERBOSITY=Diagnostic 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
30 changes: 15 additions & 15 deletions .github/workflows/ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
- "1.0.2u"
- "1.0.1u"
exclude:
# The older version of OpenSSL were less cross-platform friendly, the Windows builds had a seperate set of builds
# script to build them but it's just a pain to support them, see the failed attempt:
# The older version of OpenSSL were less cross-platform friendly, the Windows build had a seperate set of build
# scripts but it's just a pain to support them, see the failed attempt:
# https://github.com/prince-chrismc/jwt-cpp/pull/35/commits/e4948d2e1b7ec03896f80669fab6f9a2edf7ea63
- os: windows-latest
openssl: "1.1.0i"
Expand All @@ -40,11 +40,10 @@ jobs:
with:
version: ${{ fromJson('{"3.3.0":"openssl-3.3.0","3.2.1":"openssl-3.2.1","3.1.5":"openssl-3.1.5","3.0.13":"openssl-3.0.13","1.1.1w":"OpenSSL_1_1_1w","1.1.0i":"OpenSSL_1_1_0i","1.0.2u":"OpenSSL_1_0_2u","1.0.1u":"OpenSSL_1_0_1u"}')[matrix.openssl] }}
- name: configure
run: cmake . -DJWT_BUILD_TESTS=ON
- name: build
run: cmake --build . --target jwt-cpp-test
run: cmake --preset unit-tests -DOPENSSL_ROOT_DIR=/tmp
- run: cmake --build --preset unit-tests
- name: test
run: cmake --build . --target jwt-cpp-test-run
run: ctest --preset unit-tests

- if: github.event_name == 'push' && matrix.os == 'ubuntu-latest' && always()
uses: ./.github/actions/badge
Expand All @@ -64,9 +63,10 @@ jobs:
version: "openssl-3.3.0"

- 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"
- name: build
run: cmake --build . --target jwt-cpp-test
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 @@ -84,10 +84,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 All @@ -113,10 +113,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 @@ -158,6 +158,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"
}
]
}
Loading

0 comments on commit 9a51feb

Please sign in to comment.