Skip to content

Commit

Permalink
Fix CI issues (#3906)
Browse files Browse the repository at this point in the history
Co-authored-by: barcode <[email protected]>
  • Loading branch information
barcode and barcode committed Jan 31, 2023
1 parent da6b908 commit 233d233
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
13 changes: 4 additions & 9 deletions .github/external_ci/.drone.yml → .cirrus.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|--------------------------------------------------------------------------------------------------------|--------------------|----------------|
Expand Down Expand Up @@ -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 |
Expand Down
7 changes: 1 addition & 6 deletions cmake/ci.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
9 changes: 9 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

#############################################################################
Expand Down
6 changes: 5 additions & 1 deletion tests/src/unit-regression2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ using ordered_json = nlohmann::ordered_json;
#endif

#ifdef JSON_HAS_CPP_20
#include <span>
#if __has_include(<span>)
#include <span>
#endif
#endif

// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
Expand Down Expand Up @@ -664,13 +666,15 @@ TEST_CASE("regression tests 2")
}

#ifdef JSON_HAS_CPP_20
#if __has_include(<span>)
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)
const auto s = std::as_bytes(std::span(DATA));
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")
Expand Down

0 comments on commit 233d233

Please sign in to comment.