🧰 Adding clang-tidy, cmake-format, and ASAN tests (#168)

* adding clang-tidy and asan tests

Playing with clang-tidy, we already had the rule removed in #166... running the static analyzer from CMake reproduced the report in many places... I suspect the macro and `new`/`delete` separation clang-tidy is just unable to understand.

Running the problematic examples + tests with the ASAN enabled reported no problems

* Apply suggestions from code review

* Update lint.yml

* applying linting rules

* fix bad rename

* formating

* clang-tidy on jsoncons tests

* and cmake-format to lint

* cmake format improve change detection

* Update lint.yml

* apply linting
This commit is contained in:
Chris Mc
2021-09-17 19:42:21 -04:00
committed by GitHub
parent b47d095741
commit 3d501217a3
14 changed files with 142 additions and 85 deletions

View File

@@ -2,22 +2,81 @@ name: Lint CI
on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
paths:
- 'include/jwt-cpp/**.h'
- 'tests/**.cpp'
- '.github/workflows/lint.yml'
branches: [master]
jobs:
cpp:
clang-format:
runs-on: ubuntu-20.04
strategy:
matrix:
files: ["include/jwt-cpp/*.h", "tests/**.cpp"]
steps:
- run: sudo apt-get install clang-format-10
- run: sudo apt-get install clang-format
- uses: actions/checkout@v2
- run: clang-format-10 -i ${{ matrix.files }}
- run: clang-format -i ${{ matrix.files }}
- run: exit $(git status -s | wc -l)
cmake-format:
runs-on: ubuntu-20.04
strategy:
matrix:
files: ["CMakeLists.txt", "**/CMakeLists.txt", "cmake/code-coverage.cmake"]
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: pip install cmakelang
- uses: actions/checkout@v2
- run: ls ${{ matrix.files }}
- run: cmake-format --check $(ls ${{ matrix.files }})
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
- 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)
asan: ## Based on https://gist.github.com/jlblancoc/44be9d4d466f0a973b1f3808a8e56782
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: lukka/get-cmake@latest
- uses: ./.github/actions/install/gtest
- 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"
- name: build
run: |
cd build
make
- name: run
run: |
export ASAN_OPTIONS=fast_unwind_on_malloc=0
cd build
./example/rsa-create
./example/rsa-verify
./tests/jwt-cpp-test