Skip to content

Commit 5d1930f

Browse files
authored
Attempt to address miscellaneous integration task errors on macos-14-arm64 (#1327)
* Remove old SKIP_LEGACY_SHELL workaround for run-orchestration scripts * Attempt to fix install-c-driver errors on macos distros * Attempt to fix mongo shell executable permissions on macos distros * Address -Wsign-conversion warnings on macos-14-arm64
1 parent 1ef252a commit 5d1930f

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

.evergreen/scripts/install-c-driver.sh

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,36 @@ curl -sS -o mongo-c-driver.tar.gz -L "https://api.github.com/repos/mongodb/mongo
3838
tar xzf mongo-c-driver.tar.gz --directory "${mongoc_dir}" --strip-components=1
3939

4040
# C Driver needs VERSION_CURRENT to compute BUILD_VERSION.
41-
# RegEx pattern to match SemVer strings. See https://semver.org/.
42-
declare -r semver_regex="^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
43-
if echo "${mongoc_version}" | perl -ne "$(printf 'exit 1 unless /%s/' "${semver_regex}")"; then
44-
# If $VERSION is already SemVer compliant, use as-is.
45-
echo "${mongoc_version}" >|"${mongoc_dir}/VERSION_CURRENT"
41+
if [[ -f "${mongoc_dir}/VERSION_CURRENT" ]]; then
42+
: # Use the existing VERSION_CURRENT bundled with the release tarball.
4643
else
47-
# Otherwise, use the tag name of the latest release to construct a prerelease version string.
48-
49-
# Extract "tag_name" from latest Github release.
50-
declare build_version
51-
build_version=$(curl -sS -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/mongodb/mongo-c-driver/releases/latest | perl -ne 'print for /"tag_name": "(.+)"/')
52-
53-
# Assert the tag name is a SemVer string via errexit.
54-
echo "${build_version}" | perl -ne "$(printf 'exit 1 unless /%s/' "${semver_regex}")"
55-
56-
# Bump to the next minor version, e.g. 1.0.1 -> 1.1.0.
57-
build_version="$(echo "${build_version}" | perl -ne "$(printf '/%s/; print $+{major} . "." . ($+{minor}+1) . ".0"' "${semver_regex}")")"
58-
59-
# Append a prerelease tag, e.g. 1.1.0-pre+<version>.
60-
build_version="$(printf "%s-pre+%s" "${build_version}" "${mongoc_version}")"
61-
62-
# Use the constructed prerelease build version when building the C driver.
63-
echo "${build_version}" >|"${mongoc_dir}/VERSION_CURRENT"
44+
# RegEx pattern to match SemVer strings. See https://semver.org/.
45+
declare -r semver_regex="^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
46+
if echo "${mongoc_version}" | perl -ne "$(printf 'exit 1 unless /%s/' "${semver_regex}")"; then
47+
# If $mongoc_version is already SemVer compliant, use as-is.
48+
echo "${mongoc_version}" >|"${mongoc_dir}/VERSION_CURRENT"
49+
else
50+
# Otherwise, use the tag name of the latest release to construct a prerelease version string.
51+
52+
# Extract "tag_name" from latest Github release.
53+
declare build_version
54+
build_version="$(curl -sS -H "Accept: application/vnd.github+json" https://api.github.com/repos/mongodb/mongo-c-driver/releases/latest | perl -ne 'print for /"tag_name": "(.+)"/')"
55+
56+
# Assert the tag name is a SemVer string via errexit.
57+
echo "${build_version}" | perl -ne "exit 1 unless /${semver_regex}/" || {
58+
echo "could not obtain a build version from the tag name of the latest release" 1>&2
59+
exit 1
60+
}
61+
62+
# Bump to the next minor version, e.g. 1.0.1 -> 1.1.0.
63+
build_version="$(echo "${build_version}" | perl -ne "$(printf '/%s/; print $+{major} . "." . ($+{minor}+1) . ".0"' "${semver_regex}")")"
64+
65+
# Append a prerelease tag, e.g. 1.1.0-pre+<version>.
66+
build_version="$(printf "%s-pre+%s" "${build_version}" "${mongoc_version}")"
67+
68+
# Use the constructed prerelease build version when building the C driver.
69+
echo "${build_version}" >|"${mongoc_dir}/VERSION_CURRENT"
70+
fi
6471
fi
6572

6673
# shellcheck source=/dev/null

.evergreen/scripts/start-mongod.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ if [ ! -d "drivers-evergreen-tools" ]; then
1616
fi
1717
cd drivers-evergreen-tools
1818

19-
# The legacy shell is only present in server 5.0 builds and earlier,
20-
# but there is no 5.0 build for RHEL9, so we have to avoid it
21-
if [[ "${build_variant}" =~ "rhel9" ]]; then
22-
export SKIP_LEGACY_SHELL=1
23-
fi
24-
2519
DRIVERS_TOOLS="$(pwd)"
2620
if [ "Windows_NT" == "$OS" ]; then
2721
DRIVERS_TOOLS="$(cygpath -m "${DRIVERS_TOOLS:?}")"
@@ -41,6 +35,21 @@ export PATH="${MONGODB_BINARIES:?}:${PATH:-}"
4135
echo "{ \"releases\": { \"default\": \"${MONGODB_BINARIES:?}\" }}" >"${MONGO_ORCHESTRATION_HOME:?}/orchestration.config"
4236
./.evergreen/run-orchestration.sh
4337

38+
# MacOS needs some assistance to ensure executable permissions(?).
39+
chmod +x ${MONGODB_BINARIES:?}/*
40+
41+
declare mongosh_binary
42+
if command -v mongosh >/dev/null; then
43+
mongosh_binary="mongosh"
44+
elif command -v mongo >/dev/null; then
45+
mongosh_binary="mongo"
46+
else
47+
echo "could not find a MongoDB Shell binary to use" 1>&2
48+
exit 1
49+
fi
50+
: "${mongosh_binary:?}"
51+
"${mongosh_binary:?}" --version
52+
4453
# Ensure server on port 27017 is the primary server.
4554
if [[ "${TOPOLOGY:-}" == replica_set ]]; then
4655
# Replset members should be on the following ports.
@@ -63,13 +72,12 @@ if [[ "${TOPOLOGY:-}" == replica_set ]]; then
6372
"let c = rs.conf()" \
6473
"c.members.find((m) => m.host.includes('27017')).priority = 10" \
6574
"rs.reconfig(c)"
66-
67-
mongosh --quiet "${uri:?}" --eval "${script:?}"
75+
"${mongosh_binary:?}" --quiet "${uri:?}" --eval "${script:?}"
6876

6977
# Wait up to a minute for member on port 27017 to become primary.
7078
wait_for_primary() {
7179
for _ in $(seq 60); do
72-
if mongosh --quiet "${uri:?}" --eval "quit(rs.hello().primary.includes('27017') ? 0 : 1)"; then
80+
if "${mongosh_binary:?}" --quiet "${uri:?}" --eval "quit(rs.hello().primary.includes('27017') ? 0 : 1)"; then
7381
return 0
7482
else
7583
sleep 1

examples/mongocxx/gridfs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int EXAMPLES_CDECL main() {
6363
auto buffer_size = std::min(file_length, static_cast<std::int64_t>(downloader.chunk_size()));
6464

6565
// Use `std::make_unique` with C++14 and newer.
66-
auto buffer = std::unique_ptr<std::uint8_t[]>(new std::uint8_t[buffer_size]);
66+
auto buffer = std::unique_ptr<std::uint8_t[]>(new std::uint8_t[static_cast<std::size_t>(buffer_size)]);
6767

6868
while (auto length_read = downloader.read(buffer.get(), static_cast<std::size_t>(buffer_size))) {
6969
bytes_counter += static_cast<std::int32_t>(length_read);

0 commit comments

Comments
 (0)