-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚢 Provide trait implementation for supported JSON libraries (#193)
* quick poc for #174 * Copy paste * Rename include/jwt-cpp/traits/traits.h to include/jwt-cpp/traits/danielaparker-jsoncons/traits.h * Create traits.h * adding a namespace * mustache + action to automate defaults generation since they should always be the same * fix order * traits tests should use traits * playing with header order to make clang happy * install all possible traits switch badge name to sha * Update CMakeLists.txt * Update traits.h * try commenting corrected code * rm typescript * make sure to implace edit * dont comment when no diff * apply linting * fixup boost-json traits * move comment and render to composite action * actions/github-script does not leave context in the usual spot * enabled globstar * make sure to forward inputs * try using env normally * fix typo * pass in linter name correctly * debug print * fix linting issues * more debug printing * fix linting issues * fix typpo + more rebug print * apply linting * more debug * try npm install global to be less intrusive * wip render traits tests * Update lint.yml * global install does not work * Update action.yml * Update defaults.h * remove nodejs action poc * include jsoncons in main test application (for coverage of new files) * do not exclude json (since it's used by all the traits) * exclude bundled json libraries * apply linting * add jsoncons for coverage testing * jsoncons set default to a viable version * exploring ci failure * Revert "exploring ci failure" it's overlapping symbols This reverts commit 3d5b7f9. * add missing specialization * be explicit with the tests * Create CMakeLists.txt * Create danielaparker-jsoncons.cpp * Update lint.yml * Update traits.yml * lint * better access too decoded claims * more tests on verify * tweak test trying to find minimum * lets enable linting tests * using env impl for github script * fix typo * apply linting * add boost to the tests (very hacky) * Update lint.yml * ceate light boost installer there is no cmake install anymore so just a blanket copy should do * remove path requirement * outline for commit and push linting on comment * try different webhook target * more event types * fix if for more event types * just a test commit * Update lint.yml * Update lint.yml * Update lint.yml * Apply automatic changes * add token * screw up formatting * Update lint.yml * Update lint.yml * Apply automatic changes * fix merge conflicts * missing errors * playing with globbing * lint issues * matrix on comment should give many pushes * Apply automatic changes * Update lint.yml * Apply automatic changes * Apply automatic changes * fix rebase * apply render tests * Apply automatic changes * Apply automatic changes * Delete package-lock.json * fail linting * Update .gitignore * Update lint.yml * Update lint.yml * Update lint.yml * Apply automatic changes * Update lint.yml * Update CMakeLists.txt * refactor boost.json inclusion - find paths - compile library - code coverage - traits example * Apply automatic changes * debug log * Update action.yml * debug output * Update action.yml * Delete private-boost-json.cpp.in * Update private-find-boost-json.cmake * Update CMakeLists.txt * Update CMakeLists.txt * Create CMakeLists.txt * Update boost-json.cpp * Update boost-json.cpp * Update boost-json.cpp * Update boost-json.cpp * remove old boost tests * examples to include traits * fix compilation * test nlohmann json traits * linting * refactor traits to make badges * try with less expression syntax * trying single quotes * advertise traits support * Update lint.yml * Update lint.yml * Update lint.yml * sync (prince-chrismc#16) * 🔧 Replace RSA related deprecated functions (#189) * RSA_size() --> EVP_PKEY_size() * getting rid of deprecated functions in rsa-pss signature creation * getting rid of deprecated functions in rsa-pss signature verification * generate_hash not used in pss * Update lint.yml * Update lint.yml * Update lint.yml Co-authored-by: Marek Klein <[email protected]> * Update lint.yml * make sure to use install `nlohmann-json` * make action folder match trait names * add example + badge for kazuho-picojson * link to new examples * revert debug code * dont mix matrix with uses * fix bad copy paste * spec interface library so it's no compiled * fix installer * fix to interface * fix example * attempt 2 * make sure to avoid circular reference * attempt 3 * white space * white space * Update and rename .github/actions/comment-linting/action.yml to .github/actions/process-linting-results/action.yml * Update lint.yml * Update action.yml * Update action.yml * Update README.md Co-authored-by: prince-chrismc <[email protected]> Co-authored-by: Marek Klein <[email protected]>
- Loading branch information
1 parent
275c750
commit 5c9787e
Showing
52 changed files
with
1,998 additions
and
954 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.