Skip to content

Commit be53473

Browse files
blink1073Jibola
andauthored
INTPYTHON-611 Make it easier to run patch builds (#67)
Co-authored-by: Jib <[email protected]>
1 parent 11cd722 commit be53473

File tree

15 files changed

+68
-17
lines changed

15 files changed

+68
-17
lines changed

.evergreen/config.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ functions:
4444
- command: subprocess.exec
4545
type: test
4646
params:
47-
include_expansions_in_env: [DIR]
47+
include_expansions_in_env: [DIR, REPO_ORG, REPO_BRANCH]
4848
working_dir: "src"
4949
binary: bash
5050
args: [.evergreen/fetch-repo.sh]
@@ -96,6 +96,13 @@ post:
9696
working_dir: "src"
9797
binary: bash
9898
args: [drivers-evergreen-tools/.evergreen/teardown.sh]
99+
- command: subprocess.exec
100+
type: setup
101+
params:
102+
include_expansions_in_env: [DIR, REPO_ORG, REPO_BRANCH]
103+
working_dir: "src"
104+
binary: bash
105+
args: [.evergreen/teardown.sh]
99106

100107
tasks:
101108
- name: test-semantic-kernel-python-local

.evergreen/fetch-repo.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,32 @@ fi
99

1010
cd ${DIR}
1111

12+
# Allow overrides from the patch build.
13+
REPO_ORG_OVERRIDE=${REPO_ORG:-}
14+
REPO_BRANCH_OVERRIDE=${REPO_BRANCH:-}
15+
1216
# Source the configuration.
1317
set -a
1418
source config.env
1519
set +a
1620

21+
if [ -n "${REPO_ORG_OVERRIDE}" ]; then
22+
REPO_ORG="${REPO_ORG_OVERRIDE}"
23+
fi
24+
if [ -n "${REPO_BRANCH_OVERRIDE}" ]; then
25+
REPO_BRANCH="${REPO_BRANCH_OVERRIDE}"
26+
fi
27+
1728
rm -rf ${REPO_NAME}
18-
git clone ${CLONE_URL}
29+
30+
ARGS="https://github.com/${REPO_ORG}/${REPO_NAME}"
31+
if [ -n "${REPO_BRANCH:-}" ]; then
32+
ARGS="-b ${REPO_BRANCH} ${ARGS}"
33+
fi
34+
35+
echo "Cloning repo $ARGS..."
36+
git clone --depth=1 ${ARGS}
37+
echo "Cloning repo $ARGS... done."
1938

2039
# Apply patches to upstream repo if desired.
2140
if [ -d "patches" ]; then

.evergreen/teardown.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
OVERRIDES=
6+
if [ -n "${REPO_ORG:-}" ]; then
7+
echo "REPO_ORG=$REPO_ORG"
8+
OVERRIDES=1
9+
fi
10+
if [ -n "${REPO_BRANCH:-}" ]; then
11+
echo "REPO_BRANCH=$REPO_BRANCH"
12+
OVERRIDES=1
13+
fi
14+
15+
if [ -z "${OVERRIDES}" ]; then
16+
echo "No overrides"
17+
fi

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Within each subdirectory you should expect to have:
2424
- `run.sh` -- A script that should handle any additional library installations and steps for executing the test suite. This script should not populate the Atlas database with any required test data.
2525
- `config.env` - A file that defines the following environment variables:
2626
- `REPO_NAME` -- The name of the AI/ML framework repository that will get cloned
27-
- `CLONE_URL` -- The Github URL to clone into the specified `DIR`
27+
- `REPO_ORG` -- The Github org of the repository
28+
- `REPO_BRANCH` -- The optional branch to clone
2829
- `DATABASE` -- The optional database where the Atlas CLI will load your index configs
2930
- `database/` -- An optional directory used by `.evergreen/scaffold_atlas.py` to populate a MongoDB database with test data. Only provide this if your tests require pre-populated data.
3031
- `database/{collection}.json` -- An optional JSON file containing one or more MongoDB documents that will be uploaded to `$DATABASE.{collection}` in the local Atlas instance. Only provide this if your tests require pre-populated data.
@@ -117,7 +118,7 @@ Test execution flow is defined in `.evergreen/config.yml`. The test pipeline's c
117118

118119
**[Functions](https://docs.devprod.prod.corp.mongodb.com/evergreen/Project-Configuration/Project-Configuration-Files#functions)** -- We've defined some common functions that will be used. See the `.evergreen/config.yml` for example cases. The standard procedure is to fetch the repository, provision Atlas as needed, and then execute the tests specified in the `run.sh` script you create. Ensure that the expansions are provided for these functions, otherwise the tests will run improperly and most likely fail.
119120

120-
- [`fetch repo`](https://github.com/mongodb-labs/ai-ml-pipeline-testing/blob/main/.evergreen/config.yml#L30) -- Clones the library's git repository; make sure to provide the expansion CLONE_URL
121+
- [`fetch repo`](https://github.com/mongodb-labs/ai-ml-pipeline-testing/blob/main/.evergreen/config.yml#L30) -- Clones the library's git repository; make sure to provide the expansion REPO_ORG/REPO_NAME and REPO_BRANCH (optional)
121122
- [`execute tests`](https://github.com/mongodb-labs/ai-ml-pipeline-testing/blob/main/.evergreen/config.yml#L51) -- Uses [subprocess.exec](https://docs.devprod.prod.corp.mongodb.com/evergreen/Project-Configuration/Project-Commands#subprocessexec) to run the provided `run.sh` file. `run.sh` must be within the specified `DIR` path.
122123
- `fetch source` -- Retrieves the current (`ai-ml-pipeline-testing`) repo
123124
- `setup atlas cli` -- Sets up the local Atlas deployment
@@ -137,8 +138,7 @@ At the start, we will hopefully add the integration tests themselves.
137138
The bad news is that the maintainers of the AI/ML packages may take considerable
138139
time to review and merge our changes. The good news is that we can begin testing
139140
without pointing to the main branch of the upstream repo.
140-
The parameter value of the `CLONE_URL` is very flexible.
141-
We literally just call `git clone $CLONE_URL`.
141+
We can use `REPO_ORG`, `REPO_NAME`, and an optional `REPO_BRANCH` to define which repo to clone.
142142
As such, we can point to an arbitrary branch on an arbitrary repo.
143143
While developing, we encourage developers to point to a feature branch
144144
on their own fork, and add a TODO with the JIRA ticket to update the url
@@ -169,3 +169,11 @@ We realized that we could easily get this working without changing the upstream
169169
simply by applying a git patch file.
170170
This is a standard practice used by `conda package` maintainers,
171171
as they often have to build for a more broad set of scenarios than the original authors intended.
172+
173+
### Running a patch build of a given PR
174+
175+
Rather than making a new branch and modifying a `config.env` file, you can run a patch build as follows:
176+
177+
```bash
178+
evergreen patch -p ai-ml-pipelin-testing --param REPO_ORG="<my-org>" --param REPO_BRANCH="<my-branch>" -y "<my-message>"
179+
```

chatgpt-retrieval-plugin/config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
REPO_NAME=chatgpt-retrieval-plugin
2-
CLONE_URL="https://github.com/openai/chatgpt-retrieval-plugin.git"
2+
REPO_ORG=openai
33
DATABASE=chatgpt_retrieval_plugin_test_db

docarray/config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
REPO_NAME=docarray
2-
CLONE_URL="https://github.com/docarray/docarray.git"
2+
REPO_ORG=docarray
33
DATABASE=docarray_test_db

haystack-embeddings/config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
REPO_NAME=haystack-core-integrations
2-
CLONE_URL="https://github.com/deepset-ai/haystack-core-integrations.git"
2+
REPO_ORG=deepset-ai
33
DATABASE=haystack_integration_test

haystack-fulltext/config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
REPO_NAME=haystack-core-integrations
2-
CLONE_URL="https://github.com/deepset-ai/haystack-core-integrations.git"
2+
REPO_ORG=deepset-ai
33
DATABASE=haystack_test

langchain-python/config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
REPO_NAME=langchain-mongodb
2-
CLONE_URL="https://github.com/langchain-ai/langchain-mongodb.git"
2+
REPO_ORG=langchain-ai
33
DATABASE=langchain_test_db

langchaingo-golang/config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
REPO_NAME=langchaingo
2-
CLONE_URL="https://github.com/tmc/langchaingo.git"
2+
REPO_ORG=tmc

0 commit comments

Comments
 (0)