Skip to content

NODE-6950: add langchainjs to testing pipeline #66

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

Merged
merged 4 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@ tasks:
- func: "fetch repo"
- func: "execute tests"

- name: test-langchain-js-local
tags: [local]
commands:
- func: "fetch repo"
- func: "execute tests"
- command: attach.xunit_results
params:
file: src/langchain-js/langchainjs/libs/langchain-mongodb/results.xml

- name: test-langchain-js-remote
tags: [remote]
commands:
- func: "fetch repo"
- func: "setup remote atlas"
- func: "execute tests"
- command: attach.xunit_results
params:
file: src/langchain-js/langchainjs/libs/langchain-mongodb/results.xml

buildvariants:
- name: test-semantic-kernel-python-rhel
display_name: Semantic-Kernel RHEL Python
Expand Down Expand Up @@ -369,3 +388,13 @@ buildvariants:
- ubuntu2204-small
tasks:
- name: test-langchaingo-local

- name: test-langchain-js-ubuntu
display_name: LangchainJS Ubuntu2204
expansions:
DIR: langchain-js
run_on:
- ubuntu2204-small
tasks:
- name: test-langchain-js-local
- name: test-langchain-js-remote
3 changes: 3 additions & 0 deletions .evergreen/setup-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ case $DIR in
pymongo-voyageai)
MONGODB_URI=$VOYAGEAI_MONGODB_URI
;;
langchain-js)
MONGODB_URI=$LANGCHAIN_MONGODB_URI
;;
*)
echo "Missing config in setup-remote.sh for DIR: $DIR"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Test execution flow is defined in `.evergreen/config.yml`. The test pipeline's c

- `DIR` -- The subdirectory where the tasks will run

- `run_on` -- Specified platform to run on. `rhel87-small` should be used by default. Any other distro may fail Atlas CLI setup.
- `run_on` -- Specified platform to run on. `rhel87-small` or `ubuntu2204-small` should be used by default. Any other distro may fail Atlas CLI setup.
- `tasks` -- Tasks to run. See below for more details
- `cron` -- The tests are run via a cron job on a nightly cadence. This can be modified by setting a different cadence. Cron jobs can be scheduled using [cron syntax](https://crontab.guru/#0_0_*_*_*)

Expand Down
3 changes: 3 additions & 0 deletions langchain-js/config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REPO_NAME=langchainjs
REPO_ORG=langchain-ai
DATABASE=langchain_test_db
18 changes: 18 additions & 0 deletions langchain-js/indexes/langchain_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "default",
"type": "search",
"mappings": {
"fields": {
"e": {
"type": "number"
},
"embedding": {
"dimensions": 1536,
"similarity": "euclidean",
"type": "knnVector"
}
}
},
"database": "langchain",
"collectionName": "test"
}
49 changes: 49 additions & 0 deletions langchain-js/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
set -o errexit

setup_remote_atlas() {
# Get the MONGODB_URI and OPENAI_API_KEY.
SCRIPT_DIR=$(realpath "$(dirname ${BASH_SOURCE[0]})")
ROOT_DIR=$(dirname $SCRIPT_DIR)

if [[ -f "$ROOT_DIR/env.sh" ]]; then
echo "Sourcing $ROOT_DIR/env.sh"
source $ROOT_DIR/env.sh
fi

bash "$ROOT_DIR/.evergreen/fetch-secrets.sh"
source secrets-export.sh

if [[ -n "$MONGODB_URI" ]]; then
export MONGODB_ATLAS_URI=$MONGODB_URI
fi
}

setup_node_and_yarn() {
# setup node, npm and yarn
PATH=/opt/devtools/node22/bin:$(pwd)/bin:$PATH
npm_config_prefix=$(pwd)
export PATH
export npm_config_prefix

npm install --global yarn
}

setup_langchain_integration() {
cd libs/langchain-mongodb

yarn install
yarn build

yarn add --dev jest-junit
export JEST_JUNIT_OUTPUT_NAME=results.xml

# optionally enable to debug local atlas in CI.
# export DEBUG=testcontainers*
}

setup_remote_atlas
setup_node_and_yarn
setup_langchain_integration

yarn test:int --reporters=default --reporters=jest-junit