Skip to content

CXX-2683 Replace codecov-bash with new Codecov uploader #958

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

Merged
merged 10 commits into from
Apr 24, 2023
Merged
18 changes: 15 additions & 3 deletions .evergreen/build_example_projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ cd examples/projects
for project in bsoncxx mongocxx; do
(
cd $project
( cd cmake/$DIR && ./build.sh )
( cd cmake-deprecated/$DIR && ./build.sh )

if ! ( cd cmake/$DIR && ./build.sh >|output.txt 2>&1); then
cat output.txt 1>&2
exit 1
fi

if ! ( cd cmake-deprecated/$DIR && ./build.sh >|output.txt 2>&1); then
cat output.txt 1>&2
exit 1
fi

if [ "Windows_NT" != "$OS" ]; then
( cd pkg-config/$DIR && ./build.sh )
if ! ( cd pkg-config/$DIR && ./build.sh >|output.txt 2>&1); then
cat output.txt 1>&2
exit 1
fi
fi
)
done
8 changes: 4 additions & 4 deletions .evergreen/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ case "$OS" in

cygwin*)
GENERATOR=${GENERATOR:-"Visual Studio 14 2015 Win64"}
CMAKE_BUILD_OPTS="/maxcpucount:$CONCURRENCY"
CMAKE_BUILD_OPTS="/verbosity:minimal /maxcpucount:$CONCURRENCY"
CMAKE_EXAMPLES_TARGET=examples/examples
;;

Expand All @@ -52,10 +52,10 @@ esac
. .evergreen/find_cmake.sh

cd build
"$CMAKE" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DCMAKE_VERBOSE_MAKEFILE=ON -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" ..
"$CMAKE" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" ..
"$CMAKE" --build . --config $BUILD_TYPE -- $CMAKE_BUILD_OPTS
"$CMAKE" --build . --config $BUILD_TYPE --target install
"$CMAKE" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET
"$CMAKE" --build . --config $BUILD_TYPE --target install -- $CMAKE_BUILD_OPTS
"$CMAKE" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET -- $CMAKE_BUILD_OPTS

if [ "$_RUN_DISTCHECK" ]; then
DISTCHECK_BUILD_OPTS="-j$CONCURRENCY" "$CMAKE" --build . --config $BUILD_TYPE --target distcheck
Expand Down
18 changes: 11 additions & 7 deletions .evergreen/install_c_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ fi

echo "libmongoc version: ${mongoc_version}"

echo "Installing C Driver into ${mongoc_dir}..."

# Download tarball from GitHub and extract into ${mongoc_dir}.
rm -rf "${mongoc_dir}"
mkdir "${mongoc_dir}"
Expand Down Expand Up @@ -72,7 +70,11 @@ cmake_binary="$(find_cmake_latest)"
command -v "${cmake_binary:?}"

# Install libmongocrypt.
"${mongoc_dir}/.evergreen/scripts/compile-libmongocrypt.sh" "${cmake_binary}" "${mongoc_idir}" "${mongoc_install_idir}"
{
echo "Installing libmongocrypt into ${mongoc_dir}..." 1>&2
"${mongoc_dir}/.evergreen/scripts/compile-libmongocrypt.sh" "${cmake_binary}" "${mongoc_idir}" "${mongoc_install_idir}"
echo "Installing libmongocrypt into ${mongoc_dir}... done." 1>&2
} >/dev/null

if [[ "${OSTYPE}" == darwin* ]]; then
# MacOS does not have nproc.
Expand Down Expand Up @@ -127,7 +129,9 @@ else
fi

# Install libmongoc.
"${cmake_binary}" -S "${mongoc_idir}" -B "${mongoc_idir}" -G "${cmake_generator}" "${configure_flags[@]}"
"${cmake_binary}" --build "${mongoc_idir}" --config Debug --target install -- "${compile_flags[@]}"

echo "Installing C Driver into ${mongoc_dir}... done."
{
echo "Installing C Driver into ${mongoc_dir}..." 1>&2
"${cmake_binary}" -S "${mongoc_idir}" -B "${mongoc_idir}" -G "${cmake_generator}" "${configure_flags[@]}"
"${cmake_binary}" --build "${mongoc_idir}" --config Debug --target install -- "${compile_flags[@]}"
echo "Installing C Driver into ${mongoc_dir}... done." 1>&2
} >/dev/null
98 changes: 83 additions & 15 deletions .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,48 @@ functions:
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
./.evergreen/run-orchestration.sh

# Ensure server on port 27017 is the primary server.
Copy link
Collaborator

Choose a reason for hiding this comment

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

by directly connecting to it via the default URI (which does not list the other replset members)

Another alternative to consider: the C driver's test_framework_get_uri_str_no_auth constructs a URI with multiple hosts after checking the hello response. Using multiple hosts in the URI may be more robust if tests are expected to step down the primary. AFAICT the C++ driver has no such tests, but there are specification tests that use replSetStepDown.

Though setting the priority still seems like an improvement, and I expect should resolve the "not primary" errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered adding the replset hosts to the URIs used by the test framework, but decided against it as many tests use the default-constructed mongocxx::uri object to obtain the URI, and updating the test suite to use a test-framework URI constructor like the C Driver seemed too extensive a change for this PR.

if [[ "$TOPOLOGY" == replica_set ]]; then
# Replset members should be on the following ports.
declare hosts="localhost:27017,localhost:27018,localhost:27019"

# Authentication may be required.
declare creds
if [[ -n "$AUTH" ]]; then
creds="bob:pwd123@"
else
creds=""
fi

declare uri
printf -v uri "mongodb://%s%s" "$creds" "$hosts"

# Raise the priority of the member on port 27017. Others should have priority 1.
declare script
printf -v script "%s\n%s\n%s\n" \
"let c = rs.conf()" \
"c.members.find((m) => m.host.includes('27017')).priority = 10" \
"rs.reconfig(c)"

mongosh --quiet "$uri" --eval "$script"

# Wait up to a minute for member on port 27017 to become primary.
wait_for_primary() {
for _ in $(seq 60); do
if mongosh --quiet "$uri" --eval "quit(rs.hello().primary.includes('27017') ? 0 : 1)"; then
return 0
else
sleep 1
fi
done
echo "Could not set replset member on port 27017 as primary"
return 1
}
echo "Waiting for replset member 27017 to become primary..."
wait_for_primary
echo "Waiting for replset member 27017 to become primary... done."
fi

# Copy mongocryptd up so other functions can find it later, since we can't share PATHs
if [ -f $MONGODB_BINARIES/mongocryptd ]; then
cp $MONGODB_BINARIES/mongocryptd ../mongocryptd
Expand Down Expand Up @@ -221,11 +263,13 @@ functions:

"install_c_driver":
- command: expansions.update
type: setup
params:
updates:
- key: mongoc_version_default
value: *mongoc_version_default
- command: shell.exec
type: setup
params:
shell: bash
add_expansions_to_env: true
Expand Down Expand Up @@ -325,7 +369,6 @@ functions:

MONGOC_PREFIX="$(pwd)/../mongoc"
echo "MONGOC_PREFIX=$MONGOC_PREFIX"
ls -l $MONGOC_PREFIX

if [ "Windows_NT" == "$OS" ]; then
MONGOC_PREFIX=$(cygpath -m "$MONGOC_PREFIX")
Expand Down Expand Up @@ -490,7 +533,7 @@ functions:
fi
;;
esac
}
} >/dev/null
register_ca_cert
echo "Registering CA certificate for KMS TLS tests... done."

Expand All @@ -517,12 +560,18 @@ functions:
fi

if [ "Windows_NT" == "$OS" ]; then
CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration=${build_type} RUN_TESTS.vcxproj
CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration=${build_type} /verbosity:minimal RUN_TESTS.vcxproj
# Only run examples if MONGODB_API_VERSION is unset. We do not append
# API version to example clients, so examples will fail when requireApiVersion
# is true.
if [[ -z "$MONGODB_API_VERSION" ]]; then
CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration=${build_type} examples/run-examples.vcxproj
echo "Running examples..."
if ! CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration=${build_type} /verbosity:minimal examples/run-examples.vcxproj >|output.txt 2>&1; then
# Only emit output on failure.
cat output.txt 1>&2
exit 1
fi
echo "Running examples... done."
fi
else
# ENABLE_SLOW_TESTS is required to run the slow tests that are disabled by default. The slow tests should not be run if explicitly disabled.
Expand Down Expand Up @@ -566,24 +615,29 @@ functions:
# is true.
if [[ -z "$MONGODB_API_VERSION" ]]; then
for test in $EXAMPLES; do
echo "Running $test"
case "$test" in
*encryption*)
echo "Skipping client side encryption example"
echo " - Skipping client side encryption example"
;;
*change_stream*)
echo "TODO CXX-1201, enable for servers that support change streams"
echo " - TODO CXX-1201, enable for servers that support change streams"
;;
*client_session*)
echo "TODO CXX-1201, enable for servers that support change streams"
echo " - TODO CXX-1201, enable for servers that support change streams"
;;
*with_transaction*)
echo "TODO CXX-1201, enable for servers that support transactions"
echo " - TODO CXX-1201, enable for servers that support transactions"
;;
*causal_consistency*)
echo "TODO CXX-1201, enable for servers that support transactions"
echo " - TODO CXX-1201, enable for servers that support transactions"
;;
*)
${test_params} $test
if ! ${test_params} $test >|output.txt 2>&1; then
# Only emit output on failure.
cat output.txt 1>&2
exit 1
fi
;;
esac
done
Expand Down Expand Up @@ -625,7 +679,9 @@ functions:
# API version to example clients, so example projects will fail when requireApiVersion
# is true.
if [[ -z "$MONGODB_API_VERSION" ]]; then
echo "Building example projects..."
.evergreen/build_example_projects.sh
echo "Building example projects... done."
fi
unset MONGODB_API_VERSION

Expand Down Expand Up @@ -710,13 +766,25 @@ functions:
shell: bash
working_dir: "mongo-cxx-driver"
script: |
# redacted code coverage token
export CODECOV_TOKEN="${codecov_token}"

set -o errexit
set -o pipefail

bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
# Nothing to do if code coverage was not enabled.
if [[ -z "${code_coverage_cmake_flags}" ]]; then
exit 0
fi

# Note: coverage is currently only enabled on the ubuntu-1804 distro.
# This script does not support MacOS, Windows, or non-x86_64 distros.
# Update accordingly if code coverage is expanded to other distros.
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov

# -Z: Exit with a non-zero value if error.
# -g: Run with gcov support.
# -t: Codecov upload token.
# perl: filter verbose "Found" list and "Processing" messages.
./codecov -Zgt "${codecov_token}" | perl -lne 'print if not m|(^.*\.gcov(\.\.\.)?$)|'

#######################################
# Post Task #
Expand Down Expand Up @@ -899,7 +967,7 @@ tasks:
rsync -aq --exclude='examples/add_subdirectory' $(readlink -f ../..) .
[ -d build ] || mkdir build
cd build
$CMAKE -DCMAKE_VERBOSE_MAKEFILE=ON ..
$CMAKE ..
$CMAKE --build . -- -j 8
./hello_mongocxx

Expand Down
4 changes: 2 additions & 2 deletions examples/projects/bsoncxx/cmake-deprecated/shared/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace with make run to run example. Same comment applies to other files under examples/projects.

"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/bsoncxx/cmake-deprecated/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/bsoncxx/cmake/shared/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/bsoncxx/cmake/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/mongocxx/cmake-deprecated/shared/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/mongocxx/cmake-deprecated/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/mongocxx/cmake/shared/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi
4 changes: 2 additions & 2 deletions examples/projects/mongocxx/cmake/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ rm -rf build/*
cd build
if [ -z "$MSVC" ]; then
"$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
make run VERBOSE=1
"$CMAKE" --build . --target run
else
if [ "$CXX_STANDARD" = "17" ]; then
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
else
# Boost is needed for pre-17 Windows polyfill.
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
fi
"$CMAKE" --build . --target run --config "${BUILD_TYPE}"
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
fi