From 233d23343957e53f40aa5918b9bc668c7bf1c8d7 Mon Sep 17 00:00:00 2001 From: Raphael Grimm Date: Tue, 31 Jan 2023 19:23:37 +0100 Subject: [PATCH] Fix CI issues (#3906) Co-authored-by: barcode --- .github/external_ci/.drone.yml => .cirrus.yml | 13 ++++--------- .github/workflows/ubuntu.yml | 3 +++ README.md | 4 ++-- cmake/ci.cmake | 7 +------ tests/CMakeLists.txt | 9 +++++++++ tests/src/unit-regression2.cpp | 6 +++++- 6 files changed, 24 insertions(+), 18 deletions(-) rename .github/external_ci/.drone.yml => .cirrus.yml (76%) diff --git a/.github/external_ci/.drone.yml b/.cirrus.yml similarity index 76% rename from .github/external_ci/.drone.yml rename to .cirrus.yml index 0d9e3d0be..3a8c3871c 100644 --- a/.github/external_ci/.drone.yml +++ b/.cirrus.yml @@ -1,13 +1,8 @@ -kind: pipeline -name: test-on-arm64 +arm_container: + image: gcc:latest -platform: - arch: arm64 - -steps: -- name: build - image: gcc - commands: +check_task: + check_script: - wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz - tar xfz cmake-3.20.2.tar.gz - cd cmake-3.20.2 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 14b54348a..52e753436 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -146,6 +146,9 @@ jobs: - uses: actions/checkout@v3 - name: Get latest CMake and ninja uses: lukka/get-cmake@latest + - name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10 + run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV" + if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }} - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build diff --git a/README.md b/README.md index 0e360ef54..38fd58f4f 100644 --- a/README.md +++ b/README.md @@ -1140,7 +1140,7 @@ Please note: - Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case. -The following compilers are currently used in continuous integration at [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [Drone CI](https://cloud.drone.io/nlohmann/json), and [GitHub Actions](https://github.com/nlohmann/json/actions): +The following compilers are currently used in continuous integration at [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), [Cirrus CI](https://cirrus-ci.com/github/nlohmann/json), and [GitHub Actions](https://github.com/nlohmann/json/actions): | Compiler | Operating System | CI Provider | |--------------------------------------------------------------------------------------------------------|--------------------|----------------| @@ -1190,7 +1190,7 @@ The following compilers are currently used in continuous integration at [AppVeyo | GCC 8.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | | GCC 9.5.0 | Ubuntu 20.04.3 LTS | GitHub Actions | | GCC 10.4.0 | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 11.1.0 | Ubuntu (aarch64) | Drone CI | +| GCC 11.1.0 | Ubuntu (aarch64) | Cirrus CI | | GCC 11.3.0 | Ubuntu 20.04.3 LTS | GitHub Actions | | GCC 12.2.0 | Ubuntu 20.04.3 LTS | GitHub Actions | | GCC 13.0.0 20220605 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions | diff --git a/cmake/ci.cmake b/cmake/ci.cmake index f0b09f6d3..d07ab920c 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -901,12 +901,7 @@ add_custom_target(ci_cmake_flags foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 g++-11 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 clang++-12 clang++-13 clang++-14) find_program(COMPILER_TOOL NAMES ${COMPILER}) if (COMPILER_TOOL) - if ("${COMPILER}" STREQUAL "clang++-9") - # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 - set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") - else() - unset(ADDITIONAL_FLAGS) - endif() + unset(ADDITIONAL_FLAGS) add_custom_target(ci_test_compiler_${COMPILER} COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1afb000ae..3b9ae4d91 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,6 +6,15 @@ option(JSON_FastTests "Skip expensive/slow tests." OFF) set(JSON_32bitTest AUTO CACHE STRING "Enable the 32bit unit test (ON/OFF/AUTO/ONLY).") set(JSON_TestStandards "" CACHE STRING "The list of standards to test explicitly.") +# using an env var, since this will also affect targets executing cmake (such as "ci_test_compiler_default") +set(JSON_FORCED_GLOBAL_COMPILE_OPTIONS $ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}) +if (NOT "" STREQUAL "$ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}") + add_compile_options($ENV{JSON_FORCED_GLOBAL_COMPILE_OPTIONS}) +endif() +if (NOT "" STREQUAL "$ENV{JSON_FORCED_GLOBAL_LINK_OPTIONS}") + add_link_options($ENV{JSON_FORCED_GLOBAL_LINK_OPTIONS}) +endif() + include(test) ############################################################################# diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index 308ceeef9..2bb9b32e5 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -37,7 +37,9 @@ using ordered_json = nlohmann::ordered_json; #endif #ifdef JSON_HAS_CPP_20 - #include + #if __has_include() + #include + #endif #endif // NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair @@ -664,6 +666,7 @@ TEST_CASE("regression tests 2") } #ifdef JSON_HAS_CPP_20 +#if __has_include() SECTION("issue #2546 - parsing containers of std::byte") { const char DATA[] = R"("Hello, world!")"; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) @@ -671,6 +674,7 @@ TEST_CASE("regression tests 2") const json j = json::parse(s); CHECK(j.dump() == "\"Hello, world!\""); } +#endif #endif SECTION("issue #2574 - Deserialization to std::array, std::pair, and std::tuple with non-default constructable types fails")