From 03f2a6916d7565d11a7cd0ba5c230996279f5956 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Thu, 14 Dec 2023 12:02:12 -0800 Subject: [PATCH] [BUILD] Introduce CXX 20 CI pipeline for MSVC/Windows (#2450) --- .github/workflows/ci.yml | 16 ++++++++++++++++ CHANGELOG.md | 2 ++ api/test/nostd/string_view_test.cc | 4 ++-- api/test/nostd/variant_test.cc | 2 +- ci/do_ci.ps1 | 24 ++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30b3b3fbde..cc3a4532b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,6 +202,22 @@ jobs: - name: run tests run: ./ci/do_ci.ps1 cmake.maintainer.test + cmake_msvc_maintainer_test_stl_cxx20: + name: CMake msvc (maintainer mode) with C++20 + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: setup + run: | + ./ci/setup_windows_cmake.ps1 + ./ci/setup_windows_ci_environment.ps1 + - name: run tests + env: + CXX_STANDARD: '20' + run: ./ci/do_ci.ps1 cmake.maintainer.cxx20.stl.test + cmake_with_async_export_test: name: CMake test (without otlp-exporter and with async export) runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index b55c3fa223..11ba426024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ Increment the: [#2435](https://github.com/open-telemetry/opentelemetry-cpp/pull/2435) * [BUILD] Fix removing of NOMINMAX on Windows [#2449](https://github.com/open-telemetry/opentelemetry-cpp/pull/2449) +* [BUILD] Introduce CXX 20 CI pipeline for MSVC/Windows + [#2450](https://github.com/open-telemetry/opentelemetry-cpp/pull/2450) Important changes: diff --git a/api/test/nostd/string_view_test.cc b/api/test/nostd/string_view_test.cc index 52c72ea4d8..bbd5cb0648 100644 --- a/api/test/nostd/string_view_test.cc +++ b/api/test/nostd/string_view_test.cc @@ -71,8 +71,8 @@ TEST(StringViewTest, SubstrPortion) TEST(StringViewTest, SubstrOutOfRange) { string_view s = "abc123"; -#if __EXCEPTIONS || ((defined(OPENTELEMETRY_STL_VERSION) && (OPENTELEMETRY_STL_VERSION >= 2020))) - EXPECT_THROW(s.substr(10), std::out_of_range); +#if __EXCEPTIONS || (defined(OPENTELEMETRY_STL_VERSION) && (OPENTELEMETRY_STL_VERSION >= 2017)) + EXPECT_THROW((void)s.substr(10), std::out_of_range); #else EXPECT_DEATH({ s.substr(10); }, ""); #endif diff --git a/api/test/nostd/variant_test.cc b/api/test/nostd/variant_test.cc index cea5c4ee7b..a910106390 100644 --- a/api/test/nostd/variant_test.cc +++ b/api/test/nostd/variant_test.cc @@ -48,7 +48,7 @@ TEST(VariantTest, Get) EXPECT_EQ(nostd::get(w), 12); EXPECT_EQ(*nostd::get_if(&v), 12); EXPECT_EQ(nostd::get_if(&v), nullptr); -#if __EXCEPTIONS +#if __EXCEPTIONS || (defined(OPENTELEMETRY_STL_VERSION) && (OPENTELEMETRY_STL_VERSION >= 2017)) EXPECT_THROW(nostd::get(w), nostd::bad_variant_access); #else EXPECT_DEATH({ nostd::get(w); }, ""); diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 0b6cd9513e..a1e8c10014 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -112,6 +112,30 @@ switch ($action) { exit $exit } } + "cmake.maintainer.cxx20.stl.test" { + cd "$BUILD_DIR" + cmake $SRC_DIR ` + -DWITH_STL=CXX20 ` + -DCMAKE_CXX_STANDARD=20 ` + -DOTELCPP_MAINTAINER_MODE=ON ` + -DWITH_NO_DEPRECATED_CODE=ON ` + -DVCPKG_TARGET_TRIPLET=x64-windows ` + "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + cmake --build . -j $nproc + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + ctest -C Debug + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + } "cmake.with_async_export.test" { cd "$BUILD_DIR" cmake $SRC_DIR `