diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 6aacdab1f1b0..d8ab26254f31 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -29,7 +29,7 @@ env: # so that they run in parallel instead of overwhelming the default 2 CPU runner. jobs: # LangChain - test-langchain-with-latest-deps: + langchain-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -38,14 +38,10 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} cache: "yarn" - - name: Install dependencies - run: yarn install --immutable - - name: Build `@langchain/standard-tests` - run: yarn build --filter=@langchain/standard-tests - name: Test LangChain with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-langchain-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run langchain-latest-deps - test-langchain-with-lowest-deps: + langchain-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -54,15 +50,11 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} cache: "yarn" - - name: Install dependencies - run: yarn install --immutable - - name: Build `@langchain/standard-tests` - run: yarn build --filter=@langchain/standard-tests - name: Test LangChain with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-langchain-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run langchain-lowest-deps # Community - test-community-with-latest-deps: + community-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -76,9 +68,9 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/community` with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-community-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run community-latest-deps - test-community-with-lowest-deps: + community-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -92,10 +84,10 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/community` with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-community-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run community-lowest-deps # OpenAI - test-openai-with-latest-deps: + openai-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -109,9 +101,9 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/openai` with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-openai-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run openai-latest-deps - test-openai-with-lowest-deps: + openai-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -125,10 +117,10 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/openai` with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-openai-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run openai-lowest-deps # Anthropic - test-anthropic-with-latest-deps: + anthropic-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -142,9 +134,9 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/anthropic` with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-anthropic-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run anthropic-latest-deps - test-anthropic-with-lowest-deps: + anthropic-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -158,4 +150,29 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/anthropic` with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-anthropic-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run anthropic-lowest-deps + + # VertexAI + vertexai-latest-deps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "yarn" + - name: Test `@langchain/google-vertexai` with latest deps + run: docker compose -f dependency_range_tests/docker-compose.yml run vertexai-latest-deps + + vertexai-lowest-deps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "yarn" + - name: Test `@langchain/google-vertexai` with lowest deps + run: docker compose -f dependency_range_tests/docker-compose.yml run vertexai-lowest-deps diff --git a/dependency_range_tests/docker-compose.yml b/dependency_range_tests/docker-compose.yml index b5729ae14e74..9c2f4ebdbc28 100644 --- a/dependency_range_tests/docker-compose.yml +++ b/dependency_range_tests/docker-compose.yml @@ -1,7 +1,7 @@ version: "3" services: # LangChain - test-langchain-with-latest-deps: + langchain-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -12,7 +12,7 @@ services: - ../langchain:/langchain - ./scripts:/scripts command: bash /scripts/langchain/test-with-latest-deps.sh - test-langchain-with-lowest-deps: + langchain-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -20,15 +20,12 @@ services: COHERE_API_KEY: ${COHERE_API_KEY} working_dir: /app volumes: - - ../turbo.json:/turbo.json - - ../package.json:/package.json - - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../langchain:/langchain - ./scripts:/scripts command: bash /scripts/langchain/test-with-lowest-deps.sh # Community - test-community-with-latest-deps: + community-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -42,7 +39,7 @@ services: - ../libs/langchain-community:/libs/langchain-community - ./scripts:/scripts command: bash /scripts/with_standard_tests/community/test-with-latest-deps.sh - test-community-with-lowest-deps: + community-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -58,7 +55,7 @@ services: command: bash /scripts/with_standard_tests/community/test-with-lowest-deps.sh # OpenAI - test-openai-with-latest-deps: + openai-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -72,7 +69,7 @@ services: - ../libs/langchain-openai:/libs/langchain-openai - ./scripts:/scripts command: bash /scripts/with_standard_tests/openai/test-with-latest-deps.sh - test-openai-with-lowest-deps: + openai-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -88,7 +85,7 @@ services: command: bash /scripts/with_standard_tests/openai/test-with-lowest-deps.sh # Anthropic - test-anthropic-with-latest-deps: + anthropic-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -102,7 +99,7 @@ services: - ../libs/langchain-anthropic:/libs/langchain-anthropic - ./scripts:/scripts command: bash /scripts/with_standard_tests/anthropic/test-with-latest-deps.sh - test-anthropic-with-lowest-deps: + anthropic-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -116,3 +113,26 @@ services: - ../libs/langchain-anthropic:/libs/langchain-anthropic - ./scripts:/scripts command: bash /scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh + + # VertexAI + vertexai-latest-deps: + image: node:18 + environment: + PUPPETEER_SKIP_DOWNLOAD: "true" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" + working_dir: /app + volumes: + - ../libs/langchain-google-vertexai:/libs/langchain-google-vertexai + - ./scripts:/scripts + command: bash /scripts/vertexai/test-with-latest-deps.sh + vertexai-lowest-deps: + image: node:18 + environment: + PUPPETEER_SKIP_DOWNLOAD: "true" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" + working_dir: /app + volumes: + - ../libs/langchain-google-vertexai:/libs/langchain-google-vertexai + - ./scripts:/scripts + command: bash /scripts/vertexai/test-with-lowest-deps.sh + \ No newline at end of file diff --git a/dependency_range_tests/scripts/vertexai/node/package.json b/dependency_range_tests/scripts/vertexai/node/package.json new file mode 100644 index 000000000000..a4622fc74597 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/node/package.json @@ -0,0 +1,9 @@ +{ + "name": "dependency-range-tests", + "version": "0.0.0", + "private": true, + "description": "Tests dependency ranges for LangChain.", + "dependencies": { + "semver": "^7.5.4" + } +} \ No newline at end of file diff --git a/dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js new file mode 100644 index 000000000000..b8768d8a7156 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js @@ -0,0 +1,36 @@ +const fs = require("fs"); +const semver = require("semver"); + +const communityPackageJsonPath = "package.json"; + +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { + const minVersion = semver.minVersion( + currentPackageJson.dependencies["@langchain/core"] + ).version; + currentPackageJson.overrides = { + ...currentPackageJson.overrides, + "@langchain/core": minVersion, + }; + currentPackageJson.dependencies = { + ...currentPackageJson.dependencies, + "@langchain/core": minVersion, + }; +} + +if (currentPackageJson.dependencies["@langchain/google-gauth"] && !currentPackageJson.dependencies["@langchain/google-gauth"].includes("rc")) { + const minVersion = semver.minVersion( + currentPackageJson.dependencies["@langchain/google-gauth"] + ).version; + currentPackageJson.overrides = { + ...currentPackageJson.overrides, + "@langchain/google-gauth": minVersion, + }; + currentPackageJson.dependencies = { + ...currentPackageJson.dependencies, + "@langchain/google-gauth": minVersion, + }; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/vertexai/node/yarn.lock b/dependency_range_tests/scripts/vertexai/node/yarn.lock new file mode 100644 index 000000000000..50ac73caa812 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/node/yarn.lock @@ -0,0 +1,22 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +semver@^7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== diff --git a/dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh b/dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh new file mode 100644 index 000000000000..e5eb224b71e1 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +export CI=true + +# enable extended globbing for omitting build artifacts +shopt -s extglob + +# avoid copying build artifacts from the host +cp -r ../libs/langchain-google-vertexai/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./ + +yarn + +# Check the test command completes successfully +NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50% diff --git a/dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh b/dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh new file mode 100644 index 000000000000..9a95587c845c --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +export CI=true + +# enable extended globbing for omitting build artifacts +shopt -s extglob + +# avoid copying build artifacts from the host +cp -r ../libs/langchain-google-vertexai/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./ + +mkdir -p /updater_script +cp -r /scripts/vertexai/node/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) /updater_script/ + +cd /updater_script + +yarn + +cd /app + +node /updater_script/update_resolutions_lowest.js + +yarn + +# Check the test command completes successfully +NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%