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

Combine fetch source and prepare resources in EVG config.yml #500

Merged
merged 10 commits into from
Oct 2, 2024
91 changes: 14 additions & 77 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ timeout:
ls -la

functions:
"fetch source":
"fetch and prepare resources":
# Executes git clone and applies the submitted patch, if any
- command: git.get_project
params:
Expand All @@ -40,74 +40,19 @@ functions:
# Deprecated. Should be removed. But still needed for certain agents (ZAP)
- command: git.apply_patch
# Make an evergreen exapanstion file with dynamic values
- command: shell.exec
- command: subprocess.exec
params:
include_expansions_in_env: ["is_patch", "version_id", "project"]
working_dir: "src"
shell: bash
script: |
# Get the current unique version of this checkout
if [ "${is_patch}" = "true" ]; then
CURRENT_VERSION=$(git describe)-patch-${version_id}
else
CURRENT_VERSION=latest
fi

export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
export PROJECT_DIRECTORY="$(pwd)"

# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
if [[ "$(uname -s)" == CYGWIN* ]]; then
export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
fi

export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
export PROJECT_ORCHESTRATION_HOME="$PROJECT_DIRECTORY/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"

cat <<EOT > expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
PROJECT_ORCHESTRATION_HOME: "$PROJECT_ORCHESTRATION_HOME"
MONGODB_BINARIES: "$MONGODB_BINARIES"
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
EOT

cat <<EOT > .env
CURRENT_VERSION="$CURRENT_VERSION"
DRIVERS_TOOLS="$DRIVERS_TOOLS"
MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
PROJECT_ORCHESTRATION_HOME="$PROJECT_ORCHESTRATION_HOME"
MONGODB_BINARIES="$MONGODB_BINARIES"
UPLOAD_BUCKET="$UPLOAD_BUCKET"
PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
EOT

# See what we've done
cat expansion.yml
binary: bash
args:
- .evergreen/prepare-env-and-resources.sh

# Load the expansion file to make an evergreen variable with the current unique version
- command: expansions.update
params:
file: src/expansion.yml

"prepare resources":
- command: shell.exec
params:
script: |
rm -rf ${DRIVERS_TOOLS}
if [ "${project}" = "drivers-tools" ]; then
# If this was a patch build, doing a fresh clone would not actually test the patch
cp -R ${PROJECT_DIRECTORY}/ ${DRIVERS_TOOLS}
else
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git ${DRIVERS_TOOLS}
fi
${DRIVERS_TOOLS}/.evergreen/setup.sh
"${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"

"upload release":
- command: s3.put
params:
Expand Down Expand Up @@ -546,8 +491,7 @@ functions:
rm -rf ${DRIVERS_TOOLS} || true

pre:
- func: "fetch source"
- func: "prepare resources"
- func: "fetch and prepare resources"

post:
# Skip: uploading the full working directory is not needed by drivers-evergreen-tools.
Expand Down Expand Up @@ -992,8 +936,7 @@ task_groups:
teardown_task_can_fail_task: true
teardown_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: "fetch source"
- func: "prepare resources"
- func: "fetch and prepare resources"
- command: subprocess.exec
params:
binary: "bash"
Expand All @@ -1019,8 +962,7 @@ task_groups:
teardown_task_can_fail_task: true
teardown_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch source
- func: prepare resources
- func: "fetch and prepare resources"
- command: subprocess.exec
params:
binary: bash
Expand Down Expand Up @@ -1052,8 +994,7 @@ task_groups:
teardown_task_can_fail_task: true
teardown_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch source
- func: prepare resources
- func: "fetch and prepare resources"
- command: shell.exec
params:
shell: bash
Expand Down Expand Up @@ -1084,8 +1025,7 @@ task_groups:
teardown_task_can_fail_task: true
teardown_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch source
- func: prepare resources
- func: "fetch and prepare resources"
- command: shell.exec
params:
shell: bash
Expand Down Expand Up @@ -1116,8 +1056,7 @@ task_groups:
teardown_group_can_fail_task: true
teardown_group_timeout_secs: 1800
setup_group:
- func: fetch source
- func: prepare resources
- func: "fetch and prepare resources"
- command: subprocess.exec
params:
binary: bash
Expand All @@ -1142,8 +1081,7 @@ task_groups:
teardown_task_can_fail_task: true
teardown_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch source
- func: prepare resources
- func: "fetch and prepare resources"
- command: subprocess.exec
params:
binary: bash
Expand All @@ -1168,8 +1106,7 @@ task_groups:
teardown_task_can_fail_task: true
teardown_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: fetch source
- func: prepare resources
- func: "fetch and prepare resources"
- command: subprocess.exec
params:
binary: bash
Expand Down
69 changes: 69 additions & 0 deletions .evergreen/prepare-env-and-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# PREPARE EVERGREEN ENVINROMENT
# Get the current unique version of this checkout
# shellcheck disable=SC2154
if [ "$is_patch" = "true" ]; then
# shellcheck disable=SC2154
CURRENT_VERSION=$(git describe)-patch-$version_id
else
CURRENT_VERSION=latest
fi

DRIVERS_TOOLS="$(pwd)/../drivers-tools"
PROJECT_DIRECTORY="$(pwd)"

# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
if [[ "$(uname -s)" == CYGWIN* ]]; then
DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
fi

MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
PROJECT_ORCHESTRATION_HOME="$PROJECT_DIRECTORY/.evergreen/orchestration"
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
# shellcheck disable=SC2154
UPLOAD_BUCKET="$project"

export CURRENT_VERSION
export DRIVERS_TOOLS
export PROJECT_DIRECTORY
export MONGO_ORCHESTRATION_HOME
export PROJECT_ORCHESTRATION_HOME
export MONGODB_BINARIES
export UPLOAD_BUCKET

cat <<EOT >expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
PROJECT_ORCHESTRATION_HOME: "$PROJECT_ORCHESTRATION_HOME"
MONGODB_BINARIES: "$MONGODB_BINARIES"
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
EOT

cat <<EOT >.env
CURRENT_VERSION="$CURRENT_VERSION"
DRIVERS_TOOLS="$DRIVERS_TOOLS"
MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
PROJECT_ORCHESTRATION_HOME="$PROJECT_ORCHESTRATION_HOME"
MONGODB_BINARIES="$MONGODB_BINARIES"
UPLOAD_BUCKET="$UPLOAD_BUCKET"
PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
EOT

# See what we've done
cat expansion.yml

# PREPARE RESOURCES
rm -rf $DRIVERS_TOOLS
if [ "$project" = "drivers-tools" ]; then
# If this was a patch build, doing a fresh clone would not actually test the patch
cp -R $PROJECT_DIRECTORY/ $DRIVERS_TOOLS
else
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
fi

$DRIVERS_TOOLS/.evergreen/setup.sh
$PROJECT_DIRECTORY/.evergreen/install-dependencies.sh
Loading