From 6df7c35f86180c95c220f124932d66350fdbdfdd Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Mon, 3 Jun 2024 17:13:13 -0700 Subject: [PATCH] CSHARP-5117: EG script to run tests from other repos --- evergreen/evergreen.yml | 53 ++++++++++++++++++++++++++++++-- evergreen/run-external-script.sh | 37 ++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 evergreen/run-external-script.sh diff --git a/evergreen/evergreen.yml b/evergreen/evergreen.yml index c376efef5a3..beb65dff60b 100644 --- a/evergreen/evergreen.yml +++ b/evergreen/evergreen.yml @@ -53,6 +53,7 @@ functions: if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) + export DOTNET_SDK_PATH=$(cygpath -m $DOTNET_SDK_PATH) else # non windows OSs don't have dotnet in the PATH export PATH=$PATH:/usr/share/dotnet @@ -146,6 +147,21 @@ functions: ${PREPARE_SHELL} ${PROJECT_DIRECTORY}/${file} + run-external-script: + - command: subprocess.exec + type: test + params: + working_dir: mongo-csharp-driver + binary: bash + include_expansions_in_env: + - "OS" + - "GIT_REPO" + - "GIT_BRANCH" + - "LOCAL_PATH" + - "SCRIPT" + args: + - evergreen/run-external-script.sh + upload-mo-artifacts: - command: shell.exec params: @@ -210,7 +226,7 @@ functions: upload-test-results: - command: attach.xunit_results params: - file: ./mongo-csharp-driver/build/test-results/TEST-*.xml + file: "${PROJECT_DIRECTORY}/build/test-results/TEST-*.xml" bootstrap-mongo-orchestration: - command: shell.exec @@ -1871,6 +1887,23 @@ tasks: - func: install-dotnet - func: build-apidocs + - name: test-odata + commands: + - func: bootstrap-mongo-orchestration + - command: expansions.update + params: + updates: + - key: PROJECT_DIRECTORY + value: ${workdir}/odata + - func: run-external-script + vars: + GIT_REPO: "https://github.com/mongodb/mongo-aspnetcore-odata.git" + LOCAL_PATH: ${PROJECT_DIRECTORY} + SCRIPT: | + ${PREPARE_SHELL} + DOTNET_SDK_PATH="${DOTNET_SDK_PATH}" bash ./evergreen/install-dependencies.sh + DRIVER_VERSION="${PACKAGE_VERSION}" bash ./evergreen/run-tests.sh + axes: - id: version display_name: MongoDB Version @@ -2731,4 +2764,20 @@ buildvariants: git_tag_only: true depends_on: - name: push-packages-nuget - variant: ".push-packages" \ No newline at end of file + variant: ".push-packages" + +- matrix_name: odata-tests + batchtime: 720 # 12 hours + matrix_spec: + os: ["ubuntu-2004", "windows-64"] + version: ["4.2", "latest", "rapid"] + exclude_spec: + # We do not have MongoDB 4.2 binaries for Ubuntu 2004 + - os: "ubuntu-2004" + version: "4.2" + display_name: "OData tests on ${os} with MongoDB ${version}" + tasks: + - name: test-odata + depends_on: + - name: push-packages-myget + variant: ".push-packages-myget" diff --git a/evergreen/run-external-script.sh b/evergreen/run-external-script.sh new file mode 100644 index 00000000000..c046e63bd27 --- /dev/null +++ b/evergreen/run-external-script.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -o xtrace # Write all commands first to stderr +set -o errexit # Exit the script with error if any of the commands fail + +# clone the repo +rm -rf "${LOCAL_PATH}" +mkdir "${LOCAL_PATH}" +cd "${LOCAL_PATH}" || exit + +git clone -b "${GIT_BRANCH:-main}" --single-branch "${GIT_REPO}" . + +# add/adjust nuget.config pointing to myget so intermediate versions could be restored +if [ -f "./nuget.config" ]; then + echo "Adding myget into nuget.config" + dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config +else + echo "Creating custom nuget.config" + cat > "nuget.config" << EOL + + + + + + + + +EOL +fi + +# make files executable +for i in $(find "." -name \*.sh); do + chmod +x $i +done + +# execute the provided script +eval "$SCRIPT"