Skip to content

Commit 2b03289

Browse files
authored
CSHARP-5117: EG script to run tests from other repos (#1338)
1 parent 2f5beb8 commit 2b03289

File tree

2 files changed

+89
-2
lines changed

2 files changed

+89
-2
lines changed

evergreen/evergreen.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ functions:
5353
if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
5454
# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
5555
export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
56+
export DOTNET_SDK_PATH=$(cygpath -m $DOTNET_SDK_PATH)
5657
else
5758
# non windows OSs don't have dotnet in the PATH
5859
export PATH=$PATH:/usr/share/dotnet
@@ -72,6 +73,7 @@ functions:
7273
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
7374
PACKAGE_VERSION: "$PACKAGE_VERSION"
7475
DOTNET_SDK_PATH: "$DOTNET_SDK_PATH"
76+
TEST_RESULTS_PATH: "./mongo-csharp-driver/build/test-results/TEST-*.xml"
7577
PREPARE_SHELL: |
7678
set -o errexit
7779
set -o xtrace
@@ -146,6 +148,21 @@ functions:
146148
${PREPARE_SHELL}
147149
${PROJECT_DIRECTORY}/${file}
148150
151+
run-external-script:
152+
- command: subprocess.exec
153+
type: test
154+
params:
155+
working_dir: mongo-csharp-driver
156+
binary: bash
157+
include_expansions_in_env:
158+
- "OS"
159+
- "GIT_REPO"
160+
- "GIT_BRANCH"
161+
- "LOCAL_PATH"
162+
- "SCRIPT"
163+
args:
164+
- evergreen/run-external-script.sh
165+
149166
upload-mo-artifacts:
150167
- command: shell.exec
151168
params:
@@ -210,7 +227,7 @@ functions:
210227
upload-test-results:
211228
- command: attach.xunit_results
212229
params:
213-
file: ./mongo-csharp-driver/build/test-results/TEST-*.xml
230+
file: ${TEST_RESULTS_PATH}
214231

215232
bootstrap-mongo-orchestration:
216233
- command: shell.exec
@@ -1871,6 +1888,23 @@ tasks:
18711888
- func: install-dotnet
18721889
- func: build-apidocs
18731890

1891+
- name: test-odata
1892+
commands:
1893+
- func: bootstrap-mongo-orchestration
1894+
- command: expansions.update
1895+
params:
1896+
updates:
1897+
- key: TEST_RESULTS_PATH
1898+
value: "./odata/build/test-results/TEST-*.xml"
1899+
- func: run-external-script
1900+
vars:
1901+
GIT_REPO: "https://github.com/mongodb/mongo-aspnetcore-odata.git"
1902+
LOCAL_PATH: ${workdir}/odata
1903+
SCRIPT: |
1904+
${PREPARE_SHELL}
1905+
DOTNET_SDK_PATH="${DOTNET_SDK_PATH}" bash ./evergreen/install-dependencies.sh
1906+
DRIVER_VERSION="${PACKAGE_VERSION}" bash ./evergreen/run-tests.sh
1907+
18741908
axes:
18751909
- id: version
18761910
display_name: MongoDB Version
@@ -2731,4 +2765,20 @@ buildvariants:
27312765
git_tag_only: true
27322766
depends_on:
27332767
- name: push-packages-nuget
2734-
variant: ".push-packages"
2768+
variant: ".push-packages"
2769+
2770+
- matrix_name: odata-tests
2771+
batchtime: 720 # 12 hours
2772+
matrix_spec:
2773+
os: ["ubuntu-2004", "windows-64"]
2774+
version: ["4.2", "7.0", "latest"]
2775+
exclude_spec:
2776+
# We do not have MongoDB 4.2 binaries for Ubuntu 2004
2777+
- os: "ubuntu-2004"
2778+
version: "4.2"
2779+
display_name: "OData tests on ${os} with MongoDB ${version}"
2780+
tasks:
2781+
- name: test-odata
2782+
depends_on:
2783+
- name: push-packages-myget
2784+
variant: ".push-packages-myget"

evergreen/run-external-script.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -o xtrace # Write all commands first to stderr
4+
set -o errexit # Exit the script with error if any of the commands fail
5+
6+
# clone the repo
7+
rm -rf "${LOCAL_PATH}"
8+
mkdir "${LOCAL_PATH}"
9+
cd "${LOCAL_PATH}" || exit
10+
11+
git clone -b "${GIT_BRANCH:-main}" --single-branch "${GIT_REPO}" .
12+
13+
# add/adjust nuget.config pointing to myget so intermediate versions could be restored
14+
if [ -f "./nuget.config" ]; then
15+
echo "Adding myget into nuget.config"
16+
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
17+
else
18+
echo "Creating custom nuget.config"
19+
cat > "nuget.config" << EOL
20+
<?xml version="1.0" encoding="utf-8"?>
21+
<configuration>
22+
<packageSources>
23+
<clear />
24+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
25+
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
26+
</packageSources>
27+
</configuration>
28+
EOL
29+
fi
30+
31+
# make files executable
32+
for i in $(find "." -name \*.sh); do
33+
chmod +x $i
34+
done
35+
36+
# execute the provided script
37+
eval "$SCRIPT"

0 commit comments

Comments
 (0)