Skip to content

Commit

Permalink
DRIVERS-3032 Add Python CLI for drivers-evergreen-tools orchestration (
Browse files Browse the repository at this point in the history
…#578)

Co-authored-by: Jib <[email protected]>
  • Loading branch information
blink1073 and Jibola authored Jan 27, 2025
1 parent 6a0686e commit 50d13ab
Show file tree
Hide file tree
Showing 19 changed files with 564 additions and 356 deletions.
2 changes: 1 addition & 1 deletion .evergreen/auth_oidc/azure/remote-scripts/start-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export TOPOLOGY=server
export ORCHESTRATION_FILE=auth-oidc.json
export DRIVERS_TOOLS=$HOME/drivers-evergreen-tools
export PROJECT_ORCHESTRATION_HOME=$DRIVERS_TOOLS/.evergreen/orchestration
export MONGO_ORCHESTRATION_HOME=$HOME
export MONGO_ORCHESTRATION_HOME=$PROJECT_ORCHESTRATION_HOME
export SKIP_LEGACY_SHELL=true
export NO_IPV6=${NO_IPV6:-""}

Expand Down
1 change: 1 addition & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ functions:
MONGODB_VERSION: ${VERSION}
TOPOLOGY: ${TOPOLOGY}
SSL: ${SSL}
AUTH: ${AUTH}
STORAGE_ENGINE: ${STORAGE_ENGINE}
LOAD_BALANCER: ${LOAD_BALANCER}
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
Expand Down
46 changes: 0 additions & 46 deletions .evergreen/docker/overwrite_orchestration.py

This file was deleted.

3 changes: 3 additions & 0 deletions .evergreen/docker/rhel8/base-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -eu

# Remove the virtual env.
rm -rf $DRIVERS_TOOLS/.evergreen/venv || true

# Start the server.
cd $DRIVERS_TOOLS
make run-server
Expand Down
3 changes: 3 additions & 0 deletions .evergreen/docker/run-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ test -t 1 && ARGS+=" -t"

# Launch server container.
$DOCKER run $ARGS $NAME $ENTRYPOINT

# Restore the clis
bash $DRIVERS_TOOLS/.evergreen/orchestration/setup.sh
5 changes: 4 additions & 1 deletion .evergreen/docker/ubuntu20.04/base-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
set -eu
set -eux

# Remove the virtual env.
rm -rf $DRIVERS_TOOLS/.evergreen/venv || true

# Start the server.
cd $DRIVERS_TOOLS
Expand Down
45 changes: 6 additions & 39 deletions .evergreen/download-mongodb.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,16 @@
#!/usr/bin/env bash
# shellcheck shell=sh

# For future use the feed to get full list of distros : http://downloads.mongodb.org/full.json

# This file is no longer used directly by drivers-evergreen-tools.
# If using this file to download mongodb binaries, you should consider instead using `mongodl.py` and `mongosh-dl.py`.
# If using this file for get_distro, use `get-distro.sh`.
set -o errexit # Exit the script with error if any of the commands fail

get_distro ()
{
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO="${ID}-${VERSION_ID}"
elif [ -f /etc/centos-release ]; then
version=$(cat /etc/centos-release | tr -dc '0-9.' | cut -d '.' -f1)
DISTRO="centos-${version}"
elif command -v lsb_release >/dev/null 2>&1; then
name=$(lsb_release -s -i)
if [ "$name" = "RedHatEnterpriseServer" ]; then # RHEL 6.2 at least
name="rhel"
fi
version=$(lsb_release -s -r)
DISTRO="${name}-${version}"
elif [ -f /etc/redhat-release ]; then
release=$(cat /etc/redhat-release)
case $release in
*Red\ Hat*)
name="rhel"
;;
Fedora*)
name="fedora"
;;
esac
version=$(echo $release | sed 's/.*\([[:digit:]]\).*/\1/g')
DISTRO="${name}-${version}"
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO="${DISTRIB_ID}-${DISTRIB_RELEASE}"
elif grep -R "Amazon Linux" "/etc/system-release" >/dev/null 2>&1; then
DISTRO="amzn64"
fi

OS_NAME=$(uname -s)
MARCH=$(uname -m)
DISTRO=$(echo "$OS_NAME-$DISTRO-$MARCH" | tr '[:upper:]' '[:lower:]')

echo $DISTRO
# shellcheck disable=SC3028
_script_dir="$(dirname ${BASH_SOURCE:-$0})"
. ${_script_dir}/get-distro.sh
}

# get_mongodb_download_url_for "linux-distro-version-architecture" "latest|44|42|40|36|34|32|30|28|26|24" "true|false"
Expand Down
44 changes: 44 additions & 0 deletions .evergreen/get-distro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

get_distro ()
{
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO="${ID}-${VERSION_ID}"
elif [ -f /etc/centos-release ]; then
version=$(cat /etc/centos-release | tr -dc '0-9.' | cut -d '.' -f1)
DISTRO="centos-${version}"
elif command -v lsb_release >/dev/null 2>&1; then
name=$(lsb_release -s -i)
if [ "$name" = "RedHatEnterpriseServer" ]; then # RHEL 6.2 at least
name="rhel"
fi
version=$(lsb_release -s -r)
DISTRO="${name}-${version}"
elif [ -f /etc/redhat-release ]; then
release=$(cat /etc/redhat-release)
case $release in
*Red\ Hat*)
name="rhel"
;;
Fedora*)
name="fedora"
;;
esac
version=$(echo $release | sed 's/.*\([[:digit:]]\).*/\1/g')
DISTRO="${name}-${version}"
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO="${DISTRIB_ID}-${DISTRIB_RELEASE}"
elif grep -R "Amazon Linux" "/etc/system-release" >/dev/null 2>&1; then
DISTRO="amzn64"
fi

OS_NAME=$(uname -s)
MARCH=$(uname -m)
DISTRO=$(echo "$OS_NAME-$DISTRO-$MARCH" | tr '[:upper:]' '[:lower:]')

echo $DISTRO
}

get_distro
19 changes: 12 additions & 7 deletions .evergreen/install-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ fi
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/handle-paths.sh

pushd $SCRIPT_DIR
pushd $SCRIPT_DIR > /dev/null

# Ensure pipx is writing assets to a contained location.
export UV_CACHE_DIR=${DRIVERS_TOOLS}/.local/uv-cache
export UV_TOOL_DIR=${DRIVERS_TOOLS}/.local/uv-tool

if [ "${DOCKER_RUNNING:-}" == "true" ]; then
_root_dir=$(mktemp -d)
UV_CACHE_DIR=$_root_dir/uv-cache
UV_TOOL_DIR=$_root_dir/uv-tool
fi

. ./venv-utils.sh

if [ ! -d $SCRIPT_DIR/venv ]; then
Expand All @@ -34,13 +40,12 @@ if [ ! -d $SCRIPT_DIR/venv ]; then
echo "Creating virtual environment 'venv'..."
venvcreate "${PYTHON:?}" venv
echo "Creating virtual environment 'venv'... done."

python -m pip install uv
python -m pip install -q uv
else
venvactivate venv
fi

pushd $1
pushd $1 > /dev/null

# On Windows, we have to do a bit of path manipulation.
if [ "Windows_NT" == "${OS:-}" ]; then
Expand All @@ -53,8 +58,8 @@ if [ "Windows_NT" == "${OS:-}" ]; then
done
rm -rf $TMP_DIR
else
UV_TOOL_BIN_DIR=$(pwd) uv tool install --python "$(which python)" --force --editable .
UV_TOOL_BIN_DIR=$(pwd) uv tool install -q --python "$(which python)" --force --editable .
fi

popd
popd
popd > /dev/null
popd > /dev/null
2 changes: 1 addition & 1 deletion .evergreen/mongosh_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _get_latest_version_git():
shlex.split(cmd), cwd=path, stderr=subprocess.PIPE
)
for line in reversed(output.decode("utf-8").splitlines()):
if re.match("^v\d+\.\d+\.\d+$", line):
if re.match(r"^v\d+\.\d+\.\d+$", line):
LOGGER.debug("Found version %s", line)
return line.replace("v", "").strip()

Expand Down
Loading

0 comments on commit 50d13ab

Please sign in to comment.