diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d09b640fe..a61f0dd75 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -17,27 +17,6 @@ jobs: - name: build run: cmake --build build --target ci_test_clang_cxx20 - ci_clang_analyze: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: install_ninja - run: | - sudo apt update - sudo apt install ninja-build - shell: bash - - name: install_clang - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 11 - sudo apt-get install clang-tools-11 - shell: bash - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_clang_analyze - ci_test_clang: runs-on: ubuntu-latest steps: @@ -69,94 +48,31 @@ jobs: - name: build run: cmake --build build --target ci_test_gcc - ci_test_valgrind: + ci_static_analysis: runs-on: ubuntu-latest container: nlohmann/json-ci:latest + strategy: + matrix: + target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint] steps: - uses: actions/checkout@v2 - name: cmake run: cmake -S . -B build -DJSON_CI=On - name: build - run: cmake --build build --target ci_test_valgrind + run: cmake --build build --target ${{ matrix.target }} - ci_cppcheck: + ci_cmake_options: runs-on: ubuntu-latest container: nlohmann/json-ci:latest + strategy: + matrix: + target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions] steps: - uses: actions/checkout@v2 - name: cmake run: cmake -S . -B build -DJSON_CI=On - name: build - run: cmake --build build --target ci_cppcheck - - ci_cpplint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_cpplint - - ci_clang_tidy: - runs-on: ubuntu-latest - container: nlohmann/json-ci:latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_clang_tidy - - ci_test_amalgamation: - runs-on: ubuntu-latest - container: nlohmann/json-ci:latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_test_amalgamation - - ci_test_diagnostics: - runs-on: ubuntu-latest - container: nlohmann/json-ci:latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_test_diagnostics - - ci_test_noexceptions: - runs-on: ubuntu-latest - container: nlohmann/json-ci:latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_test_noexceptions - - ci_test_noimplicitconversions: - runs-on: ubuntu-latest - container: nlohmann/json-ci:latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_test_noimplicitconversions - - ci_test_clang_sanitizer: - runs-on: ubuntu-latest - container: nlohmann/json-ci:latest - steps: - - uses: actions/checkout@v2 - - name: cmake - run: cmake -S . -B build -DJSON_CI=On - - name: build - run: cmake --build build --target ci_test_clang_sanitizer + run: cmake --build build --target ${{ matrix.target }} ci_test_coverage: runs-on: ubuntu-latest @@ -177,3 +93,16 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: /__w/json/json/build/json.info.filtered.noexcept + + ci_test_compilers: + runs-on: ubuntu-latest + container: nlohmann/json-ci:latest + strategy: + matrix: + compiler: [g++-4.8, g++-4.9, g++-5, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11] + steps: + - uses: actions/checkout@v2 + - name: cmake + run: cmake -S . -B build -DJSON_CI=On + - name: build + run: cmake --build build --target ci_test_compiler_${{ matrix.compiler }} diff --git a/.travis.yml b/.travis.yml index c5208b31f..bdfbe722b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,30 +54,6 @@ matrix: # Linux / GCC - - os: linux - compiler: gcc - env: COMPILER=g++-4.8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.8', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-4.9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-5 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5', 'ninja-build'] - - os: linux compiler: gcc env: COMPILER=g++-6 @@ -86,124 +62,6 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['g++-6', 'ninja-build'] - - os: linux - compiler: gcc - env: COMPILER=g++-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-8', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - - os: linux - compiler: gcc - env: - - COMPILER=g++-9 - - CXX_STANDARD=17 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - # Linux / Clang - - - os: linux - compiler: clang - env: COMPILER=clang++-3.5 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5'] - packages: ['g++-6', 'clang-3.5', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.6 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] - packages: ['g++-6', 'clang-3.6', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] - packages: ['g++-6', 'clang-3.7', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'clang-3.8', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'clang-3.9', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-4.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] - packages: ['g++-6', 'clang-4.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-5.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0'] - packages: ['g++-6', 'clang-5.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-6.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['g++-6', 'clang-6.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-6', 'clang-7', 'ninja-build'] - - - os: linux - compiler: clang - env: - - COMPILER=clang++-7 - - CXX_STANDARD=17 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-7', 'clang-7', 'ninja-build'] - ################ # build script # ################ diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 4e0d74b12..b167cc93b 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -30,7 +30,7 @@ execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}") message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})") -find_program(GCC_TOOL NAMES g++-HEAD g++-11 g++-10 g++) +find_program(GCC_TOOL NAMES g++-HEAD g++-11 g++-latest) execute_process(COMMAND ${GCC_TOOL} --version OUTPUT_VARIABLE GCC_TOOL_VERSION ERROR_VARIABLE GCC_TOOL_VERSION) string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" GCC_TOOL_VERSION "${GCC_TOOL_VERSION}") message(STATUS "🔖 GCC ${GCC_TOOL_VERSION} (${GCC_TOOL})") @@ -85,7 +85,7 @@ find_program(SCAN_BUILD_TOOL NAMES scan-build-11 scan-build) file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp) ############################################################################### -# Different C++ Standards. +# Thorough check with recent compilers ############################################################################### set(CLANG_CXXFLAGS "-std=c++11 \ @@ -784,6 +784,26 @@ add_custom_target(ci_cmake_flags COMMENT "Check CMake flags" ) +############################################################################### +# Use more installed compilers. +############################################################################### + +foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11) + find_program(COMPILER_TOOL NAMES ${COMPILER}) + if (COMPILER_TOOL) + add_custom_target(ci_test_compiler_${COMPILER} + COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure + COMMENT "Compile and test with ${COMPILER}" + ) + endif() + unset(COMPILER_TOOL CACHE) +endforeach() + ############################################################################### # Clean up all generated files. ############################################################################### diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 15f55dfa5..d8c586425 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,6 +2,7 @@ option(JSON_Sanitizer "Build test suite with Clang sanitizer" OFF) option(JSON_Valgrind "Execute test suite with Valgrind" OFF) option(JSON_NoExceptions "Build test suite without exceptions" OFF) option(JSON_Coverage "Build test suite with coverage information" OFF) +option(JSON_FastTests "Whether to skip expensive tests" OFF) # download test data include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/download_test_data.cmake) @@ -112,10 +113,17 @@ foreach(file ${files}) target_link_libraries(${testcase} PRIVATE --coverage) endif() - add_test(NAME "${testcase}" - COMMAND ${testcase} ${DOCTEST_TEST_FILTER} --no-skip - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) + if (JSON_FastTests) + add_test(NAME "${testcase}" + COMMAND ${testcase} ${DOCTEST_TEST_FILTER} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + add_test(NAME "${testcase}" + COMMAND ${testcase} ${DOCTEST_TEST_FILTER} --no-skip + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + endif() set_tests_properties("${testcase}" PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA) if(JSON_Valgrind)