Skip to content

Commit

Permalink
CSHARP-5117: EG script to run tests from other repos (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanych-sun authored Jun 7, 2024
1 parent 2f5beb8 commit 2b03289
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 2 deletions.
54 changes: 52 additions & 2 deletions evergreen/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -72,6 +73,7 @@ functions:
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
PACKAGE_VERSION: "$PACKAGE_VERSION"
DOTNET_SDK_PATH: "$DOTNET_SDK_PATH"
TEST_RESULTS_PATH: "./mongo-csharp-driver/build/test-results/TEST-*.xml"
PREPARE_SHELL: |
set -o errexit
set -o xtrace
Expand Down Expand Up @@ -146,6 +148,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:
Expand Down Expand Up @@ -210,7 +227,7 @@ functions:
upload-test-results:
- command: attach.xunit_results
params:
file: ./mongo-csharp-driver/build/test-results/TEST-*.xml
file: ${TEST_RESULTS_PATH}

bootstrap-mongo-orchestration:
- command: shell.exec
Expand Down Expand Up @@ -1871,6 +1888,23 @@ tasks:
- func: install-dotnet
- func: build-apidocs

- name: test-odata
commands:
- func: bootstrap-mongo-orchestration
- command: expansions.update
params:
updates:
- key: TEST_RESULTS_PATH
value: "./odata/build/test-results/TEST-*.xml"
- func: run-external-script
vars:
GIT_REPO: "https://github.com/mongodb/mongo-aspnetcore-odata.git"
LOCAL_PATH: ${workdir}/odata
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
Expand Down Expand Up @@ -2731,4 +2765,20 @@ buildvariants:
git_tag_only: true
depends_on:
- name: push-packages-nuget
variant: ".push-packages"
variant: ".push-packages"

- matrix_name: odata-tests
batchtime: 720 # 12 hours
matrix_spec:
os: ["ubuntu-2004", "windows-64"]
version: ["4.2", "7.0", "latest"]
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"
37 changes: 37 additions & 0 deletions evergreen/run-external-script.sh
Original file line number Diff line number Diff line change
@@ -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
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
</packageSources>
</configuration>
EOL
fi

# make files executable
for i in $(find "." -name \*.sh); do
chmod +x $i
done

# execute the provided script
eval "$SCRIPT"

0 comments on commit 2b03289

Please sign in to comment.