Skip to content

Provide trait implementation for supported JSON libraries #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 160 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
083176b
quick poc for Thalhammer#174
prince-chrismc Sep 27, 2021
1d5c82a
Copy paste
prince-chrismc Sep 27, 2021
bdfea02
Rename include/jwt-cpp/traits/traits.h to include/jwt-cpp/traits/dani…
prince-chrismc Sep 27, 2021
4687641
Create traits.h
prince-chrismc Sep 27, 2021
35a58c1
adding a namespace
prince-chrismc Sep 28, 2021
7466ea1
mustache + action to automate defaults generation
prince-chrismc Sep 28, 2021
77c4875
fix order
prince-chrismc Sep 28, 2021
20f57fb
traits tests should use traits
prince-chrismc Sep 28, 2021
6fda30d
playing with header order
prince-chrismc Sep 28, 2021
1f2e504
install all possible traits
prince-chrismc Sep 28, 2021
60a9e9d
Update CMakeLists.txt
prince-chrismc Sep 28, 2021
89e8b07
Update traits.h
prince-chrismc Sep 28, 2021
a033ad9
try commenting corrected code
prince-chrismc Sep 29, 2021
403eaf9
rm typescript
prince-chrismc Sep 29, 2021
60f2507
make sure to implace edit
prince-chrismc Sep 29, 2021
7c0ee84
dont comment when no diff
prince-chrismc Sep 29, 2021
66fd868
apply linting
prince-chrismc Sep 29, 2021
6057233
fixup boost-json traits
prince-chrismc Sep 29, 2021
9f242a9
move comment and render to composite action
prince-chrismc Oct 1, 2021
2ba21ad
actions/github-script does not leave context in the usual spot
prince-chrismc Oct 1, 2021
7bd1c6d
enabled globstar
prince-chrismc Oct 1, 2021
a0f6312
make sure to forward inputs
prince-chrismc Oct 1, 2021
c033efb
try using env normally
prince-chrismc Oct 1, 2021
a0d0d75
fix typo
prince-chrismc Oct 1, 2021
8bb061f
pass in linter name correctly
prince-chrismc Oct 1, 2021
6d432e7
debug print
prince-chrismc Oct 1, 2021
a23b018
fix linting issues
prince-chrismc Oct 1, 2021
e5aff5d
more debug printing
prince-chrismc Oct 1, 2021
bb6c4da
fix linting issues
prince-chrismc Oct 1, 2021
45c46a3
fix typpo + more rebug print
prince-chrismc Oct 1, 2021
7260ac3
apply linting
prince-chrismc Oct 1, 2021
76c9f7d
more debug
prince-chrismc Oct 1, 2021
acf7b5f
try npm install global to be less intrusive
prince-chrismc Oct 1, 2021
5edc423
wip render traits tests
prince-chrismc Oct 1, 2021
cfa81d9
Update lint.yml
prince-chrismc Oct 2, 2021
9cd19df
global install does not work
prince-chrismc Oct 2, 2021
91e3f46
Update action.yml
prince-chrismc Oct 2, 2021
e789a63
Update defaults.h
prince-chrismc Oct 2, 2021
f6edd8b
remove nodejs action poc
prince-chrismc Oct 2, 2021
eeec089
include jsoncons in main test application (for coverage of new files)
prince-chrismc Oct 2, 2021
847dcfa
do not exclude json (since it's used by all the traits)
prince-chrismc Oct 2, 2021
fd5e77a
exclude bundled json libraries
prince-chrismc Oct 2, 2021
f0e86ce
apply linting
prince-chrismc Oct 2, 2021
54a25e8
add jsoncons for coverage testing
prince-chrismc Oct 2, 2021
39869fb
jsoncons set default to a viable version
prince-chrismc Oct 2, 2021
3d5b7f9
exploring ci failure
prince-chrismc Oct 4, 2021
f3cc614
Revert "exploring ci failure" it's overlapping symbols
prince-chrismc Oct 4, 2021
d51e614
add missing specialization
prince-chrismc Oct 4, 2021
9e464d3
be explicit with the tests
prince-chrismc Oct 4, 2021
6bff043
Create CMakeLists.txt
prince-chrismc Oct 4, 2021
b7e19ca
Create danielaparker-jsoncons.cpp
prince-chrismc Oct 4, 2021
f4180bb
Update lint.yml
prince-chrismc Oct 7, 2021
df7abe2
Update traits.yml
prince-chrismc Oct 7, 2021
b56ca7e
lint
prince-chrismc Oct 8, 2021
6fd88bb
better access too decoded claims
prince-chrismc Oct 8, 2021
e999b69
more tests on verify
prince-chrismc Oct 9, 2021
48fef83
tweak test
prince-chrismc Oct 9, 2021
a9a5e57
lets enable linting tests
prince-chrismc Oct 9, 2021
43d67d6
using env impl for github script
prince-chrismc Oct 9, 2021
edf7e30
fix typo
prince-chrismc Oct 9, 2021
28a2be2
apply linting
prince-chrismc Oct 9, 2021
818a6fc
add boost to the tests (very hacky)
prince-chrismc Oct 9, 2021
587170d
Update lint.yml
prince-chrismc Nov 12, 2021
bae365b
ceate light boost installer
prince-chrismc Nov 12, 2021
4be8e88
remove path requirement
prince-chrismc Nov 12, 2021
193ae20
outline for commit and push linting on comment
prince-chrismc Nov 16, 2021
7306249
try different webhook target
prince-chrismc Nov 16, 2021
700a8bb
more event types
Nov 16, 2021
823be6e
fix if for more event types
prince-chrismc Nov 16, 2021
3549d20
just a test commit
prince-chrismc Nov 16, 2021
e9c24f3
Update lint.yml
prince-chrismc Nov 16, 2021
0a36af2
Update lint.yml
prince-chrismc Nov 16, 2021
8cf925d
Update lint.yml
prince-chrismc Nov 16, 2021
efdd335
Apply automatic changes
prince-chrismc Nov 16, 2021
f60c7e4
add token
prince-chrismc Nov 16, 2021
09e032e
screw up formatting
prince-chrismc Nov 16, 2021
1fdac88
Update lint.yml
prince-chrismc Nov 16, 2021
26d5e9b
Update lint.yml
prince-chrismc Nov 16, 2021
6eef83e
Apply automatic changes
prince-chrismc Nov 16, 2021
34db044
Merge branch 'master' into provide-traits
prince-chrismc Nov 16, 2021
1755416
fix merge conflicts
prince-chrismc Nov 16, 2021
942f5d1
missing errors
prince-chrismc Nov 16, 2021
414bc2b
playing with globbing
prince-chrismc Nov 16, 2021
ef91d2d
lint issues
prince-chrismc Nov 16, 2021
62acd12
matrix on comment should give many pushes
prince-chrismc Nov 16, 2021
e9952bf
Apply automatic changes
prince-chrismc Nov 16, 2021
5483acb
Update lint.yml
prince-chrismc Nov 16, 2021
bfe5198
Apply automatic changes
prince-chrismc Nov 16, 2021
b9beb52
Apply automatic changes
prince-chrismc Nov 16, 2021
ab125fb
Merge branch 'master' into provide-traits
prince-chrismc Nov 16, 2021
d94b40d
fix rebase
prince-chrismc Nov 16, 2021
455a03d
apply render tests
prince-chrismc Nov 16, 2021
fadd3aa
Apply automatic changes
prince-chrismc Nov 16, 2021
13d5a03
Apply automatic changes
prince-chrismc Nov 16, 2021
63bbadf
Delete package-lock.json
prince-chrismc Nov 16, 2021
c214c2f
fail linting
prince-chrismc Nov 16, 2021
cf78038
Update .gitignore
prince-chrismc Nov 16, 2021
ead5842
Merge branch 'master' into provide-traits
prince-chrismc Nov 16, 2021
721cf52
Merge branch 'Thalhammer:master' into master
prince-chrismc Nov 19, 2021
a71f09c
Update lint.yml
prince-chrismc Nov 19, 2021
a87559c
Update lint.yml
prince-chrismc Nov 19, 2021
7d95de3
Update lint.yml
prince-chrismc Nov 19, 2021
6f80fb1
Apply automatic changes
prince-chrismc Nov 19, 2021
603ab1e
Update lint.yml
prince-chrismc Nov 19, 2021
5feedac
Merge branch 'master' into provide-traits
prince-chrismc Nov 19, 2021
4776bb0
Update CMakeLists.txt
prince-chrismc Nov 22, 2021
cd1c5c4
refactor boost.json inclusion
prince-chrismc Nov 22, 2021
8e2800c
Apply automatic changes
prince-chrismc Nov 22, 2021
cf241df
debug log
prince-chrismc Nov 22, 2021
a6defa5
Update action.yml
prince-chrismc Nov 22, 2021
a6a698a
debug output
prince-chrismc Nov 22, 2021
e358c26
Update action.yml
prince-chrismc Nov 22, 2021
fab1d4e
Delete private-boost-json.cpp.in
prince-chrismc Nov 22, 2021
3bcace6
Update private-find-boost-json.cmake
prince-chrismc Nov 22, 2021
f88fc2b
Update CMakeLists.txt
prince-chrismc Nov 22, 2021
c039588
Update CMakeLists.txt
prince-chrismc Nov 22, 2021
8da605a
Create CMakeLists.txt
prince-chrismc Nov 22, 2021
a1792cb
Update boost-json.cpp
prince-chrismc Nov 22, 2021
1c43a2c
Update boost-json.cpp
prince-chrismc Nov 22, 2021
1b646f6
Update boost-json.cpp
prince-chrismc Nov 22, 2021
73e088c
Update boost-json.cpp
prince-chrismc Nov 22, 2021
5534fee
remove old boost tests
prince-chrismc Nov 23, 2021
42c361b
examples to include traits
prince-chrismc Nov 23, 2021
8a9388c
fix compilation
prince-chrismc Nov 23, 2021
7349c59
test nlohmann json traits
prince-chrismc Nov 23, 2021
674d778
linting
prince-chrismc Nov 23, 2021
c509aba
Merge branch 'Thalhammer:master' into master
prince-chrismc Nov 23, 2021
8cac799
refactor traits to make badges
prince-chrismc Dec 2, 2021
850cd29
try with less expression syntax
prince-chrismc Dec 2, 2021
52b02a9
trying single quotes
prince-chrismc Dec 2, 2021
ff070d2
advertise traits support
prince-chrismc Dec 2, 2021
c7b0577
Update lint.yml
prince-chrismc Dec 2, 2021
6683a5d
Update lint.yml
prince-chrismc Dec 2, 2021
a6f9efc
Update lint.yml
prince-chrismc Dec 2, 2021
e00645f
sync (prince-chrismc/jwt-cpp#16)
prince-chrismc Dec 2, 2021
2447cbc
Update lint.yml
prince-chrismc Dec 2, 2021
2e0699f
Merge branch 'master' into provide-traits
prince-chrismc Dec 2, 2021
9807bb2
make sure to use install `nlohmann-json`
prince-chrismc Dec 12, 2021
0f80f6d
make action folder match trait names
prince-chrismc Dec 12, 2021
7e521e0
add example + badge for kazuho-picojson
prince-chrismc Dec 12, 2021
875866b
link to new examples
prince-chrismc Dec 12, 2021
3ae2a23
revert debug code
prince-chrismc Dec 12, 2021
7580b0c
Merge branch 'Thalhammer:master' into provide-traits
prince-chrismc Dec 12, 2021
ec6aaf4
dont mix matrix with uses
prince-chrismc Dec 12, 2021
ec88e81
fix bad copy paste
prince-chrismc Dec 12, 2021
5177d41
spec interface library so it's no compiled
prince-chrismc Dec 12, 2021
e804f2a
fix installer
prince-chrismc Dec 12, 2021
f226867
fix to interface
prince-chrismc Dec 12, 2021
df2849b
fix example
prince-chrismc Dec 12, 2021
5b94af3
attempt 2
prince-chrismc Dec 12, 2021
b8c2f85
make sure to avoid circular reference
prince-chrismc Dec 12, 2021
f7ce6ff
attempt 3
prince-chrismc Dec 12, 2021
a198367
Merge pull request #14 from prince-chrismc/provide-traits
prince-chrismc Dec 12, 2021
b4d8e00
white space
prince-chrismc Dec 12, 2021
bff185d
white space
prince-chrismc Dec 12, 2021
e1ae42c
Update and rename .github/actions/comment-linting/action.yml to .gith…
prince-chrismc Dec 23, 2021
bde2011
Update lint.yml
prince-chrismc Dec 23, 2021
d1eca2f
Update action.yml
prince-chrismc Dec 23, 2021
e748608
Update action.yml
prince-chrismc Dec 23, 2021
2adbbc3
Update README.md
prince-chrismc Dec 23, 2021
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
17 changes: 17 additions & 0 deletions .github/actions/install/boost-json/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Install Boost.JSON
description: Install Boost.JSON for building test application
inputs:
version:
description: The desired Boost.JSON version to install
required: false
default: "1.77.0"
runs:
using: composite
steps:
- run: |
cd /tmp
wget https://github.com/boostorg/json/archive/boost-${{ inputs.version }}.tar.gz
tar -zxf /tmp/boost-${{ inputs.version }}.tar.gz
cd json-boost-${{ inputs.version }}
sudo cp -vR include/boost /usr/local/include
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
version:
description: The desired jsoncons version to install
required: false
default: "0.159.0"
default: "0.167.1"
runs:
using: composite
steps:
Expand Down
17 changes: 17 additions & 0 deletions .github/actions/install/kazuho-picojson/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Install PicoJSON
description: Install PicoJSON for building test application
inputs:
version:
description: The desired PicoJSON version to install
required: false
default: "v1.3.0"
runs:
using: composite
steps:
- run: |
cd /tmp
wget https://github.com/kazuho/picojson/archive/${{ inputs.version }}.tar.gz
tar -zxf /tmp/${{ inputs.version }}.tar.gz
cd picojson-${{ inputs.version }}
sudo cp -v picojson.h /usr/local/include/picojson
shell: bash
18 changes: 18 additions & 0 deletions .github/actions/install/nlohmann-json/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Install nlohmann-json
description: Install nlohmann-json for building test application
inputs:
version:
description: The desired nlohmann-json version to install
required: false
default: "3.10.4"
runs:
using: composite
steps:
- run: |
cd /tmp
wget https://github.com/nlohmann/json/archive/v${{ inputs.version }}.tar.gz
tar -zxf /tmp/v${{ inputs.version }}.tar.gz
cd json-${{ inputs.version }}
cmake .
sudo cmake --install .
shell: bash
21 changes: 21 additions & 0 deletions .github/actions/process-linting-results/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Process Linting Results
description: Add a comment to a pull request with when `git diff` present and save the changes as an artifact so they can be applied manually
inputs:
linter_name:
description: The name of the tool to credit in the comment
required: true
runs:
using: "composite"
steps:
- run: git add --update
shell: bash
- id: stage
uses: dtinth/patch-generator-action@v1
- if: steps.stage.outputs.result == 'dirty'
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ github.token }}
body: |
Hello, @${{ github.actor }}! `${{ inputs.linter_name }}` had some concerns :scream:
- run: exit $(git status -uno -s | wc -l)
shell: bash
52 changes: 52 additions & 0 deletions .github/actions/render/defaults/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Render `defaults.h` Template"
description: "Generate the `defaults.h` header file for a JSON library"
inputs:
traits_name:
description: "Name of the traits structure to be used. Typically in the format `author_repository` or equivilant"
required: true
library_name:
description: "Name of the JSON library."
required: true
library_url:
description: "URL to the JSON library."
required: true
disable_default_traits:
description: "Set the macro to disable the default traits"
required: false
default: "true"
runs:
using: composite
steps:
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm install mustache
shell: bash
- uses: actions/github-script@v5
env:
TRAITS_NAME: ${{ inputs.traits_name }}
LIBRARY_NAME: ${{ inputs.library_name }}
LIBRARY_URL: ${{ inputs.library_url }}
DISABLE_DEFAULT_TRAITS: ${{ inputs.disable_default_traits }}
with:
script: |
const mustache = require('mustache')
const path = require('path')
const fs = require('fs')

const { TRAITS_NAME, LIBRARY_NAME, LIBRARY_URL, DISABLE_DEFAULT_TRAITS } = process.env
console.log(`Rendering ${TRAITS_NAME}!`)

const disableDefault = DISABLE_DEFAULT_TRAITS === 'true'

const template = fs.readFileSync(path.join('include', 'jwt-cpp', 'traits', 'defaults.h.mustache'), 'utf8')
const content = mustache.render(template, {
traits_name: TRAITS_NAME,
traits_name_upper: TRAITS_NAME.toUpperCase(),
library_name: LIBRARY_NAME,
library_url: LIBRARY_URL,
disable_default_traits: disableDefault,
})
const outputDir = path.join('include', 'jwt-cpp', 'traits', TRAITS_NAME.replace('_', '-'))
fs.mkdirSync(outputDir, { recursive: true })
fs.writeFileSync(path.join(outputDir, 'defaults.h'), content)
39 changes: 39 additions & 0 deletions .github/actions/render/tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Render `TraitsTests.cpp` Template"
description: "Generate the `TraitsTests.cpp` header file for a JSON library"
inputs:
traits_name:
description: "Name of the traits structure to be used. Typically in the format `author_repository` or equivilant"
required: true
test_suite_name:
description: "Name of the JSON library."
required: true
runs:
using: composite
steps:
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm install mustache
shell: bash
- uses: actions/github-script@v5
env:
TRAITS_NAME: ${{ inputs.traits_name }}
SUITE_NAME: ${{ inputs.test_suite_name }}
with:
script: |
const mustache = require('mustache')
const path = require('path')
const fs = require('fs')

const { TRAITS_NAME, SUITE_NAME } = process.env
console.log(`Rendering ${TRAITS_NAME}!`)

const template = fs.readFileSync(path.join('tests', 'traits', 'TraitsTest.cpp.mustache'), 'utf8')
const content = mustache.render(template, {
traits_name: TRAITS_NAME,
traits_dir: TRAITS_NAME.replace('_', '-'),
test_suite_name: SUITE_NAME,
})
const outputDir = path.join('tests', 'traits')
fs.mkdirSync(outputDir, { recursive: true })
fs.writeFileSync(path.join(outputDir, `${SUITE_NAME}.cpp`), content)
2 changes: 2 additions & 0 deletions .github/workflows/jwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
- uses: actions/checkout@v2
- uses: lukka/get-cmake@latest
- uses: ./.github/actions/install/gtest
- uses: ./.github/actions/install/danielaparker-jsoncons
- uses: ./.github/actions/install/boost-json

- name: configure
run: |
Expand Down
91 changes: 76 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,105 @@ jobs:
clang-format:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
files: ["include/jwt-cpp/*.h", "tests/**.cpp"]
files:
- "include/jwt-cpp/*.h"
- "include/jwt-cpp/traits/**/*.h"
- "tests/*.cpp"
- "tests/**/*.cpp"
- "example/*.cpp"
- "example/**/*.cpp"
steps:
- run: sudo apt-get install clang-format
- run: |
sudo apt-get install clang-format
shopt -s globstar
- uses: actions/checkout@v2
- run: clang-format -i ${{ matrix.files }}
- run: exit $(git status -s | wc -l)
- uses: ./.github/actions/process-linting-results
with:
linter_name: clang-format

cmake-format:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
files: ["CMakeLists.txt", "**/CMakeLists.txt", "cmake/code-coverage.cmake"]
files: ["**/CMakeLists.txt", "cmake/code-coverage.cmake"]
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: "3.x"
- run: pip install cmakelang
- run: shopt -s globstar
- uses: actions/checkout@v2
- run: ls ${{ matrix.files }}
- run: cmake-format --check $(ls ${{ matrix.files }})
- run: cmake-format -i ${{ matrix.files }}
- uses: ./.github/actions/process-linting-results
with:
linter_name: cmake-format

clang-tidy:
runs-on: ubuntu-20.04
steps:
- run: sudo apt-get install clang-tidy
- uses: actions/checkout@v2
- uses: lukka/get-cmake@latest
- uses: ./.github/actions/install/gtest

- uses: actions/checkout@v2
- name: configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-fix"

- name: run
run: |
cd build
make
- run: exit $(git status -s | wc -l)
working-directory: build
run: make
- uses: ./.github/actions/process-linting-results
with:
linter_name: clang-tidy

render-defaults:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
traits:
- { name: "boost_json", library: "Boost.JSON", url: "https://github.com/boostorg/json", disable_pico: true }
- { name: "danielaparker_jsoncons", library: "jsoncons", url: "https://github.com/danielaparker/jsoncons", disable_pico: true }
- { name: "kazuho_picojson", library: "picojson", url: "https://github.com/kazuho/picojson", disable_pico: false }
- { name: "nlohmann_json", library: "JSON for Modern C++", url: "https://github.com/nlohmann/json", disable_pico: true }
name: render-defaults (${{ matrix.traits.name }})
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/render/defaults
with:
traits_name: ${{ matrix.traits.name }}
library_name: ${{ matrix.traits.library }}
library_url: ${{ matrix.traits.url }}
disable_default_traits: ${{ matrix.traits.disable_pico }}
- run: git add include/jwt-cpp/traits/*
- uses: ./.github/actions/process-linting-results
with:
linter_name: render-defaults

render-tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
traits:
# - { name: "boost_json", suite: "BoostJsonTest" } # Currently needs work arounds for API limitations
- { name: "danielaparker_jsoncons", suite: "JsonconsTest" }
# - { name: "kazuho_picojson", suite: "PicoJsonTest" } # Currently the default everything tests against this!
- { name: "nlohmann_json", suite: "NlohmannTest" }
name: render-tests (${{ matrix.traits.name }})
steps:
- uses: actions/checkout@v2
- run: shopt -s globstar
- uses: ./.github/actions/render/tests
with:
traits_name: ${{ matrix.traits.name }}
test_suite_name: ${{ matrix.traits.suite }}
- run: clang-format -i tests/**/*.cpp
- run: git add tests/traits/*
- uses: ./.github/actions/process-linting-results
with:
linter_name: render-tests
Loading