mirror of
https://github.com/nlohmann/json.git
synced 2026-02-17 09:03:58 +00:00
Fix CI (#4871)
* 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 👷 fix CI Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2
.github/workflows/ubuntu.yml
vendored
2
.github/workflows/ubuntu.yml
vendored
@@ -161,8 +161,6 @@ jobs:
|
||||
compiler: ['3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15-bullseye', '16', '17', '18', '19', '20', 'latest']
|
||||
container: silkeh/clang:${{ matrix.compiler }}
|
||||
steps:
|
||||
- name: Install unzip and git
|
||||
run: apt-get update ; apt-get install -y unzip git
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Get latest CMake and ninja
|
||||
uses: lukka/get-cmake@6b3e96a9bc9976b8b546346fdd102effedae0ca8 # v4.02
|
||||
|
||||
80
.github/workflows/windows.yml
vendored
80
.github/workflows/windows.yml
vendored
@@ -18,7 +18,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
mingw:
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
matrix:
|
||||
architecture: [x64, x86]
|
||||
@@ -40,24 +40,14 @@ jobs:
|
||||
msvc:
|
||||
strategy:
|
||||
matrix:
|
||||
runs_on: [windows-2019, windows-2022]
|
||||
build_type: [Debug, Release]
|
||||
architecture: [Win32, x64]
|
||||
std_version: [default, latest]
|
||||
|
||||
runs-on: ${{ matrix.runs_on }}
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Set generator
|
||||
id: generator
|
||||
run: |
|
||||
if [ "${{ matrix.runs_on }}" = "windows-2019" ]; then
|
||||
echo "generator=Visual Studio 16 2019" >> $GITHUB_ENV
|
||||
else
|
||||
echo "generator=Visual Studio 17 2022" >> $GITHUB_ENV
|
||||
fi
|
||||
shell: bash
|
||||
- name: Set extra CXX_FLAGS for latest std_version
|
||||
id: cxxflags
|
||||
run: |
|
||||
@@ -68,11 +58,11 @@ jobs:
|
||||
fi
|
||||
shell: bash
|
||||
- name: Run CMake (Release)
|
||||
run: cmake -S . -B build -G "$env:generator" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="$env:flags"
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DCMAKE_CXX_FLAGS="$env:flags"
|
||||
if: matrix.build_type == 'Release'
|
||||
shell: pwsh
|
||||
- name: Run CMake (Debug)
|
||||
run: cmake -S . -B build -G "$env:generator" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="$env:flags"
|
||||
run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -DJSON_BuildTests=On -DJSON_FastTests=ON -DCMAKE_CXX_FLAGS="$env:flags"
|
||||
if: matrix.build_type == 'Debug'
|
||||
shell: pwsh
|
||||
- name: Build
|
||||
@@ -80,34 +70,34 @@ jobs:
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
clang:
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
version: [11, 12, 13, 14, 15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Install Clang
|
||||
run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
||||
- name: Build
|
||||
run: cmake --build build --parallel 10
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
clang-cl-12:
|
||||
runs-on: windows-2019
|
||||
strategy:
|
||||
matrix:
|
||||
architecture: [Win32, x64]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Run CMake
|
||||
run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||
- name: Build
|
||||
run: cmake --build build --config Debug --parallel 10
|
||||
- name: Test
|
||||
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
# clang:
|
||||
# runs-on: windows-2025
|
||||
# strategy:
|
||||
# matrix:
|
||||
# version: [11, 12, 13, 14, 15]
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
# - name: Install Clang
|
||||
# run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM"
|
||||
# - name: Run CMake
|
||||
# run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
||||
# - name: Build
|
||||
# run: cmake --build build --parallel 10
|
||||
# - name: Test
|
||||
# run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
#
|
||||
# clang-cl-12:
|
||||
# runs-on: windows-2025
|
||||
# strategy:
|
||||
# matrix:
|
||||
# architecture: [Win32, x64]
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
# - name: Run CMake
|
||||
# run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On
|
||||
# - name: Build
|
||||
# run: cmake --build build --config Debug --parallel 10
|
||||
# - name: Test
|
||||
# run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
# -Wno-padded We do not care about padding warnings.
|
||||
# -Wno-covered-switch-default All switches list all cases and a default case.
|
||||
# -Wno-unsafe-buffer-usage Otherwise Doctest would not compile.
|
||||
# -Wno-missing-noreturn We found no way to silence this warning otherwise, see PR #4871
|
||||
|
||||
set(CLANG_CXXFLAGS
|
||||
-Werror
|
||||
@@ -17,4 +18,5 @@ set(CLANG_CXXFLAGS
|
||||
-Wno-padded
|
||||
-Wno-covered-switch-default
|
||||
-Wno-unsafe-buffer-usage
|
||||
-Wno-missing-noreturn
|
||||
)
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
|
||||
set(JSON_TEST_DATA_VERSION 3.1.0)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
# if variable is set, use test data from given directory rather than downloading them
|
||||
if(JSON_TestDataDirectory)
|
||||
message(STATUS "Using test data in ${JSON_TestDataDirectory}.")
|
||||
add_custom_target(download_test_data)
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${JSON_TestDataDirectory}\"\n")
|
||||
else()
|
||||
find_package(Git)
|
||||
# create a header with the path to the downloaded test data
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/test_files\"\n")
|
||||
|
||||
# download test data from GitHub release
|
||||
ExternalProject_Add(download_test_data_project
|
||||
URL "${JSON_TEST_DATA_URL}/archive/refs/tags/v${JSON_TEST_DATA_VERSION}.zip"
|
||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/test_files"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD TRUE
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
)
|
||||
|
||||
# target to download test data
|
||||
add_custom_target(download_test_data
|
||||
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
|
||||
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
DEPENDS download_test_data_project
|
||||
)
|
||||
# create a header with the path to the downloaded test data
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"\n")
|
||||
endif()
|
||||
|
||||
# determine the operating system (for debug and support purposes)
|
||||
|
||||
@@ -402,7 +402,7 @@ template<typename T>
|
||||
struct is_iterator_of_multibyte
|
||||
{
|
||||
using value_type = typename std::iterator_traits<T>::value_type;
|
||||
enum
|
||||
enum // NOLINT(cppcoreguidelines-use-enum-class)
|
||||
{
|
||||
value = sizeof(value_type) > 1
|
||||
};
|
||||
|
||||
@@ -655,7 +655,7 @@ struct is_ordered_map
|
||||
template <typename C> static one test( decltype(&C::capacity) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg,cppcoreguidelines-use-enum-class)
|
||||
};
|
||||
|
||||
// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
|
||||
|
||||
@@ -4198,7 +4198,7 @@ struct is_ordered_map
|
||||
template <typename C> static one test( decltype(&C::capacity) ) ;
|
||||
template <typename C> static two test(...);
|
||||
|
||||
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg,cppcoreguidelines-use-enum-class)
|
||||
};
|
||||
|
||||
// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
|
||||
@@ -6895,7 +6895,7 @@ template<typename T>
|
||||
struct is_iterator_of_multibyte
|
||||
{
|
||||
using value_type = typename std::iterator_traits<T>::value_type;
|
||||
enum
|
||||
enum // NOLINT(cppcoreguidelines-use-enum-class)
|
||||
{
|
||||
value = sizeof(value_type) > 1
|
||||
};
|
||||
|
||||
@@ -1352,7 +1352,7 @@ TEST_CASE("value conversion")
|
||||
#ifndef SKIP_TESTS_FOR_ENUM_SERIALIZATION
|
||||
SECTION("get an enum")
|
||||
{
|
||||
enum c_enum { value_1, value_2 };
|
||||
enum c_enum { value_1, value_2 }; // NOLINT(cppcoreguidelines-use-enum-class)
|
||||
enum class cpp_enum { value_1, value_2 };
|
||||
|
||||
CHECK(json(value_1).get<c_enum>() == value_1);
|
||||
@@ -1601,7 +1601,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(cards,
|
||||
{cards::karo, "karo"}
|
||||
})
|
||||
|
||||
enum TaskState // NOLINT(cert-int09-c,readability-enum-initial-value)
|
||||
enum TaskState // NOLINT(cert-int09-c,readability-enum-initial-value,cppcoreguidelines-use-enum-class)
|
||||
{
|
||||
TS_STOPPED,
|
||||
TS_RUNNING,
|
||||
|
||||
@@ -23,7 +23,7 @@ using nlohmann::json;
|
||||
|
||||
namespace
|
||||
{
|
||||
enum test {};
|
||||
enum test {}; // NOLINT(cppcoreguidelines-use-enum-class)
|
||||
|
||||
struct pod {};
|
||||
struct pod_bis {};
|
||||
|
||||
@@ -177,7 +177,7 @@ TEST_CASE("regression tests 1")
|
||||
#ifndef SKIP_TESTS_FOR_ENUM_SERIALIZATION
|
||||
SECTION("pull request #71 - handle enum type")
|
||||
{
|
||||
enum { t = 0, u = 102};
|
||||
enum { t = 0, u = 102}; // NOLINT(cppcoreguidelines-use-enum-class)
|
||||
json j = json::array();
|
||||
j.push_back(t);
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ struct for_3204_foo
|
||||
|
||||
struct for_3204_bar
|
||||
{
|
||||
enum constructed_from_t
|
||||
enum constructed_from_t // NOLINT(cppcoreguidelines-use-enum-class)
|
||||
{
|
||||
constructed_from_none = 0,
|
||||
constructed_from_foo = 1,
|
||||
|
||||
Reference in New Issue
Block a user