Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Upgrade GoogleTest version from 1.12.1 to 1.13.0 #2114

Merged

Conversation

cngzhnp
Copy link
Contributor

@cngzhnp cngzhnp commented Apr 21, 2023

Upgraded GoogleTest to 1.13.0 + C++14

Changes

Revised the versions used for GoogleTest:

  • By default, upgraded to 1.13.0, which requires C++14
  • Still using 1.12.1 (unchanged) for CI builds that requires C++11
  • Still using 1.10.0 (unchanged) for CI builds using GCC 4.8

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch from 6bfa052 to e61cde0 Compare April 23, 2023 09:45
@codecov
Copy link

codecov bot commented Apr 23, 2023

Codecov Report

Merging #2114 (e0ed1eb) into main (d99cbab) will decrease coverage by 0.02%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2114      +/-   ##
==========================================
- Coverage   87.31%   87.29%   -0.02%     
==========================================
  Files         169      169              
  Lines        4901     4900       -1     
==========================================
- Hits         4279     4277       -2     
- Misses        622      623       +1     

see 2 files with indirect coverage changes

@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch 14 times, most recently from ea8ec98 to 4d0420e Compare April 23, 2023 14:12
@cngzhnp cngzhnp marked this pull request as ready for review April 23, 2023 14:53
@cngzhnp cngzhnp requested a review from a team April 23, 2023 14:53
@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch 2 times, most recently from c2a1ebf to 4e17174 Compare April 23, 2023 15:09
if [ "x$GOOGLETEST_VERSION" = "x" ]; then
export GOOGLETEST_VERSION=1.12.1
export GOOGLETEST_VERSION=1.10.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is default version changed to 1.10.0, can it remain as 1.12.1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If GoogleTest version is not set on CI Pipeline, it was set as 1.10.0 by default. It could not be 1.12.1 version because GCC 4.8 oldish environment to support C++14.

@lalitb
Copy link
Member

lalitb commented Apr 24, 2023

Can you update the description for the changes. As the latest version doesn't support C++11, how are we handling now CI tests for C++11 ?

@cngzhnp
Copy link
Contributor Author

cngzhnp commented Apr 24, 2023

Can you update the description for the changes. As the latest version doesn't support C++11, how are we handling now CI tests for C++11 ?

Could you please check the description and verify that?

CMakeLists.txt Outdated
@@ -535,6 +535,7 @@ list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")

include(CTest)
if(BUILD_TESTING)
set(CMAKE_CXX_STANDARD 20)
Copy link
Member

@lalitb lalitb May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cngzhnp - I think this will break the builds for users who are building library (along with tests) using gcc4.8 (or any C++11 only compiler) ? Do you think we should revisit upgrade to googletest once we drop C++11 only compiler support in #1830.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. However, it is like CI/CD pipeline design problem for opentelemetry-cpp. There are a lot of scripts which setup different versions of third party libraries or submodules etc. All of them are not in one page.

From my perspective, if we still want to support GCC 4.8 version with C++11 standard, we need a better CMake/CI-CD/Script design for this. Otherwise, like me people might only focus on passing the CI tests but not the real usecases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets C++20 for all builds using tests, which breaks gcc4.8.

See related comment, to set C++14 is relevant ci/do_ci.sh targets instead.

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cngzhnp

Thanks for the PR, looking into this.

In the mean time, please merge the main branch into this PR, to resolve the conflicts.

@marcalff marcalff added this to the Migrate to C++14 milestone May 23, 2023
@marcalff marcalff changed the title Upgrade GoogleTest version from 1.12.1 to 1.13.0 [CI] Upgrade GoogleTest version from 1.12.1 to 1.13.0 May 26, 2023
@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch from 4e17174 to ec849a1 Compare May 26, 2023 12:20
CHANGELOG.md Outdated Show resolved Hide resolved
cngzhnp added a commit to cngzhnp/opentelemetry-cpp that referenced this pull request Jul 4, 2023
@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch from 17f4fd6 to 262aacf Compare July 4, 2023 09:53
cngzhnp added a commit to cngzhnp/opentelemetry-cpp that referenced this pull request Jul 4, 2023
@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch from 262aacf to fcecc4c Compare July 4, 2023 14:05
cngzhnp added a commit to cngzhnp/opentelemetry-cpp that referenced this pull request Jul 4, 2023
@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch from fcecc4c to 8900a2f Compare July 4, 2023 14:34
@cngzhnp
Copy link
Contributor Author

cngzhnp commented Jul 4, 2023

@marcalff Could you please verify the changes after your comments? Also, could you please take a look that why CodeQL build is failed, I am not sure that fail is directly related to my changes?

@cngzhnp cngzhnp force-pushed the feature/update_googletest_version branch from 8900a2f to cc68517 Compare July 10, 2023 09:27
@marcalff
Copy link
Member

@cngzhnp Thanks for the cleanup.

Remaining points below.

CodeQL

The CodeQL / CodeQL-Build build fails on:

  [  0%] Building CXX object api/test/core/CMakeFiles/version_test.dir/version_test.cc.o
  cd /home/runner/work/opentelemetry-cpp/opentelemetry-cpp/_lgtm_build_dir/api/test/core && /usr/bin/c++  -DENABLE_TEST -I/home/runner/work/opentelemetry-cpp/opentelemetry-cpp/api/include  -fpermissive -O3 -DNDEBUG   -Wno-error=deprecated-declarations -std=gnu++11 -o CMakeFiles/version_test.dir/version_test.cc.o -c /home/runner/work/opentelemetry-cpp/opentelemetry-cpp/api/test/core/version_test.cc
  In file included from /usr/include/gtest/gtest-message.h:57,
                   from /usr/include/gtest/gtest-assertion-result.h:46,
                   from /usr/include/gtest/gtest.h:64,
                   from /home/runner/work/opentelemetry-cpp/opentelemetry-cpp/api/test/core/version_test.cc:6:
  /usr/include/gtest/internal/gtest-port.h:270:2: error: #error C++ versions less than C++14 are not supported.
    270 | #error C++ versions less than C++14 are not supported.
        |  ^~~~~

To fix this and keep the build in C++11, add:

GOOGLETEST_VERSION: 1.12.1

in file codeql-analysis.yml

setup-cmake.sh

Per previous comments, this code:

# This variable not set on CI pipeline for only legacy environment(GCC 4.8).
# With 1.13.0 version, C++14 must be set which does not supported by legacy environment anymore.
# Also with this version, release version path needs to be adapted.
if [ -z "${GOOGLETEST_VERSION}" ]; then
  # By default, GoogleTest version set the following version.
  export GOOGLETEST_VERSION=1.13.0
  GOOGLETEST_VERSION_PATH="v${GOOGLETEST_VERSION}"
  GOOGLETEST_FOLDER_PATH="googletest-${GOOGLETEST_VERSION}"
else
  GOOGLETEST_VERSION_PATH="release-${GOOGLETEST_VERSION}"
  GOOGLETEST_FOLDER_PATH="googletest-release-${GOOGLETEST_VERSION}"

fi

should decouple setting the default release with the release format.

Something like:

if [ -z "${GOOGLETEST_VERSION}" ]; then
  # Version by default. Requires C++14
  export GOOGLETEST_VERSION=1.13.0
fi

followed by something like:

if [  << GOOGLETEST_VERSION greater or equal to 1.13.0 >> ]; then
  GOOGLETEST_VERSION_PATH="v${GOOGLETEST_VERSION}"
  GOOGLETEST_FOLDER_PATH="googletest-${GOOGLETEST_VERSION}"
else
  GOOGLETEST_VERSION_PATH="release-${GOOGLETEST_VERSION}"
  GOOGLETEST_FOLDER_PATH="googletest-release-${GOOGLETEST_VERSION}"
fi

Expectation is that all the following use case works

unset GOOGLETEST_VERSION
setup_cmake

installs 1.13.0

GOOGLETEST_VERSION=1.13.0
setup_cmake

installs 1.13.0

GOOGLETEST_VERSION=1.12.1
setup_cmake

installs 1.12.1

GOOGLETEST_VERSION=1.10.0
setup_cmake

installs 1.10.0

@cngzhnp
Copy link
Contributor Author

cngzhnp commented Jul 10, 2023

@marcalff Could you please check & verify what I changed so for? Now, I fixed the CodeQL and split up GoogleTest version and its path.

@marcalff
Copy link
Member

marcalff commented Jul 10, 2023

@marcalff Could you please check & verify what I changed so for? Now, I fixed the CodeQL and split up GoogleTest version and its path.

Thanks.

How about this instead:

OLD_VERSION_REGEXP="^1\.([0-9]|10|11|12)(\..*)?$"

if [[ ${GOOGLETEST_VERSION} =~ ${OLD_VERSION_REGEXP} ]]; then
  # Old package name
else
  # New (starting with 1.13.0) package name
fi

@marcalff
Copy link
Member

marcalff commented Jul 10, 2023

Somehow, adding quotes broke the regexp test.

Tested locally, this works:

if [[ ${GOOGLETEST_VERSION} =~ ${OLD_VERSION_REGEXP} ]]; then

Tested locally, this fails:

if [[ "${GOOGLETEST_VERSION}" =~ "${OLD_VERSION_REGEXP}" ]]; then

breaking the build for 1.10.0 (Gcc 4.8) and 1.12.1 (C++11 builds)

Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM.

Please revise:

  • the PR description
  • code comments

for cleanup.

@owent

This change may cause merge collisions with your work, when setting CMAKE_CXX_STANDARD. I assume these will be trivial to fix, so not an issue.

@lalitb @esigo @owent

Please take a second look.

Copy link
Member

@owent owent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks.

@owent
Copy link
Member

owent commented Jul 11, 2023

The code LGTM.

Please revise:

  • the PR description
  • code comments

for cleanup.

@owent

This change may cause merge collisions with your work, when setting CMAKE_CXX_STANDARD. I assume these will be trivial to fix, so not an issue.

@lalitb @esigo @owent

Please take a second look.

It's fine by me , we also use gtest 13 and a high CMAKE_CXX_STANDARD in some of our products.While for the users still use gcc 4.8 and C++11, them can still use gtest 1.10.0 and it works well now.

@marcalff
Copy link
Member

marcalff commented Jul 11, 2023

Set merge temporarily on hold, to avoid conflicts with the release of opentelemetry-cpp 1.10.0.

@marcalff marcalff added the pr:do-not-merge This PR is not ready to be merged. label Jul 11, 2023
@marcalff marcalff removed the pr:do-not-merge This PR is not ready to be merged. label Jul 11, 2023
ci/do_ci.sh Show resolved Hide resolved
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the upgrade.

@ThomsonTan ThomsonTan added the ok-to-merge The PR is ok to merge (has two approves or raised by a maintainer/approver and has one approve) label Jul 12, 2023
@marcalff marcalff merged commit b3d547c into open-telemetry:main Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-merge The PR is ok to merge (has two approves or raised by a maintainer/approver and has one approve)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants