Skip to content

Commit

Permalink
refactor a lot of code into a shared script
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 10, 2024
1 parent dcc0432 commit 1ec69cf
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,22 @@ export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_anthropic_dir="$monorepo_libs_dir/langchain-anthropic"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"
monorepo_anthropic_dir="/app/monorepo/libs/langchain-anthropic"

# Updater script will not live inside the monorepo
updater_script_dir="/app/updater_script"
standard_tests_updater_script_dir="/app/with_standard_script"

# Original directory paths
original_anthropic_dir="/libs/langchain-anthropic"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_updater_script_dir="/scripts/with_standard_tests/anthropic/node"
original_standard_tests_updater_script_dir="/scripts/with_standard_tests/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

# Copy `@langchain/anthropic` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_anthropic_dir/"
cp -r "$original_anthropic_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_anthropic_dir/"

# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$standard_tests_updater_script_dir"
cp "$original_standard_tests_updater_script_dir"/* "$standard_tests_updater_script_dir/"
cd "$standard_tests_updater_script_dir"
# Run the updater script
node "update_workspace_dependencies.js"

# Navigate back to root
cd "/app"
# Run the shared script to copy all necessary folders/files
bash /scripts/with_standard_tests/shared.sh anthropic

mkdir -p "$updater_script_dir"
cp "$original_updater_script_dir"/* "$updater_script_dir/"
cd "$updater_script_dir"
# Update any workspace dep to the latest version since not all workspaces are
# available in the test enviroment.
# available in the test enviroment.
node "update_workspace_deps.js"

# Navigate back to monorepo root and install dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,30 @@ set -euxo pipefail

export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_anthropic_dir="$monorepo_libs_dir/langchain-anthropic"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"

# Updater script will not live inside the monorepo
monorepo_openai_dir="/app/monorepo/libs/langchain-anthropic"
updater_script_dir="/app/updater_script"
standard_tests_updater_script_dir="/app/with_standard_script"

# Original directory paths
original_anthropic_dir="/libs/langchain-anthropic"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_updater_script_dir="/scripts/with_standard_tests/anthropic/node"
original_standard_tests_updater_script_dir="/scripts/with_standard_tests/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

# Copy `@langchain/anthropic` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_anthropic_dir/"
cp -r "$original_anthropic_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_anthropic_dir/"

# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$standard_tests_updater_script_dir"
cp "$original_standard_tests_updater_script_dir"/* "$standard_tests_updater_script_dir/"
cd "$standard_tests_updater_script_dir"
# Run the updater script
node "update_workspace_dependencies.js"

# Navigate back to root
cd "/app"
# Run the shared script to copy all necessary folders/files
bash /scripts/with_standard_tests/shared.sh anthropic

# Copy the updater script to the monorepo
mkdir -p "$updater_script_dir"
cp "$original_updater_script_dir"/* "$updater_script_dir/"

# Install deps (e.g semver) for the updater script
cd "$updater_script_dir"
yarn
# Run the updater script
node "update_resolutions_lowest.js"
node "update_workspace_deps.js"

# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
yarn

# Navigate into `@langchain/anthropic` to build and run tests
# We need to run inside the anthropic directory so turbo repo does
# We need to run inside the package directory so turbo repo does
# not try to build the package/it's workspace dependencies.
cd "$monorepo_anthropic_dir"
cd "$monorepo_openai_dir"
yarn test
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,10 @@ export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_community_dir="$monorepo_libs_dir/langchain-community"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"
monorepo_community_dir="/app/monorepo/libs/langchain-community"

# Updater script will not live inside the monorepo
standard_tests_updater_script_dir="/app/with_standard_script"

# Original directory paths
original_community_dir="/libs/langchain-community"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_standard_tests_updater_script_dir="/scripts/with_standard_tests/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

# Copy `@langchain/community` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_community_dir/"
cp -r "$original_community_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_community_dir/"

# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$standard_tests_updater_script_dir"
cp "$original_standard_tests_updater_script_dir"/* "$standard_tests_updater_script_dir/"
cd "$standard_tests_updater_script_dir"
# Run the updater script
node "update_workspace_dependencies.js"
# Run the shared script to copy all necessary folders/files
bash /scripts/with_standard_tests/shared.sh community

# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,32 @@ set -euxo pipefail

export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_community_dir="$monorepo_libs_dir/langchain-community"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"

# Updater script will not live inside the monorepo
monorepo_community_dir="/app/monorepo/libs/langchain-community"
updater_script_dir="/app/updater_script"
updater_script_dir="/app/updater_script"
standard_tests_updater_script_dir="/app/with_standard_script"

# Original directory paths
original_community_dir="/libs/langchain-community"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_updater_script_dir="/scripts/with_standard_tests/community/node"
original_standard_tests_updater_script_dir="/scripts/with_standard_tests/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

# Copy `@langchain/community` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_community_dir/"
cp -r "$original_community_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_community_dir/"

# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$standard_tests_updater_script_dir"
cp "$original_standard_tests_updater_script_dir"/* "$standard_tests_updater_script_dir/"
cd "$standard_tests_updater_script_dir"
# Run the updater script
node "update_workspace_dependencies.js"

# Navigate back to root
cd "/app"
# Run the shared script to copy all necessary folders/files
bash /scripts/with_standard_tests/shared.sh community

# Copy the updater script to the monorepo
mkdir -p "$updater_script_dir"
cp "$original_updater_script_dir"/* "$updater_script_dir/"

# Install deps (e.g semver) for the updater script
cd "$updater_script_dir"
yarn
# Run the updater script
node "update_resolutions_lowest.js"


# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
yarn

# Navigate into `@langchain/community` to build and run tests
# We need to run inside the community directory so turbo repo does
# Navigate into `@langchain/package` to build and run tests
# We need to run inside the package directory so turbo repo does
# not try to build the package/it's workspace dependencies.
cd "$monorepo_community_dir"
yarn test
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,10 @@ export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_openai_dir="$monorepo_libs_dir/langchain-openai"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"
monorepo_openai_dir="/app/monorepo/libs/langchain-openai"

# Updater script will not live inside the monorepo
standard_tests_updater_script_dir="/app/with_standard_script"

# Original directory paths
original_openai_dir="/libs/langchain-openai"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_standard_tests_updater_script_dir="/scripts/with_standard_tests/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

# Copy `@langchain/openai` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_openai_dir/"
cp -r "$original_openai_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_openai_dir/"

# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$standard_tests_updater_script_dir"
cp "$original_standard_tests_updater_script_dir"/* "$standard_tests_updater_script_dir/"
cd "$standard_tests_updater_script_dir"
# Run the updater script
node "update_workspace_dependencies.js"
# Run the shared script to copy all necessary folders/files
bash /scripts/with_standard_tests/shared.sh openai

# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,32 @@ set -euxo pipefail

export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_openai_dir="$monorepo_libs_dir/langchain-openai"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"

# Updater script will not live inside the monorepo
monorepo_openai_dir="/app/monorepo/libs/langchain-openai"
updater_script_dir="/app/updater_script"
updater_script_dir="/app/updater_script"
standard_tests_updater_script_dir="/app/with_standard_script"

# Original directory paths
original_openai_dir="/libs/langchain-openai"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_updater_script_dir="/scripts/with_standard_tests/openai/node"
original_standard_tests_updater_script_dir="/scripts/with_standard_tests/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

# Copy `@langchain/openai` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_openai_dir/"
cp -r "$original_openai_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_openai_dir/"

# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$standard_tests_updater_script_dir"
cp "$original_standard_tests_updater_script_dir"/* "$standard_tests_updater_script_dir/"
cd "$standard_tests_updater_script_dir"
# Run the updater script
node "update_workspace_dependencies.js"

# Navigate back to root
cd "/app"
# Run the shared script to copy all necessary folders/files
bash /scripts/with_standard_tests/shared.sh openai

# Copy the updater script to the monorepo
mkdir -p "$updater_script_dir"
cp "$original_updater_script_dir"/* "$updater_script_dir/"

# Install deps (e.g semver) for the updater script
cd "$updater_script_dir"
yarn
# Run the updater script
node "update_resolutions_lowest.js"


# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
yarn

# Navigate into `@langchain/openai` to build and run tests
# We need to run inside the openai directory so turbo repo does
# Navigate into `@langchain/package` to build and run tests
# We need to run inside the package directory so turbo repo does
# not try to build the package/it's workspace dependencies.
cd "$monorepo_openai_dir"
yarn test
Loading

0 comments on commit 1ec69cf

Please sign in to comment.