Skip to content

Conversation

itaismith
Copy link
Contributor

Description of changes

Updating the CI for JS to test the new JS client on PRs. The integration script for JS (bin/ts-integration-test.sh) will now correctly generate types from the server on every PR, and will fail if changes were not committed. It will also use the updated tests and code from clients/new-js. The API generation script and tests now have the ability to skip spinning up the server if one is already available (set up by the integration test in this case).

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor

propel-code-bot bot commented Aug 27, 2025

JS Client CI & Integration Improvements and Migration to clients/new-js

This PR rewires the CI pipeline and development scripts for the Chroma JavaScript client, switching focus to the new JS implementation in clients/new-js. It updates the JavaScript integration test and API generation scripts to reliably spin up the server, generate TypeScript types, check for uncommitted generated changes, and run tests against the updated codebase. The PR also refreshes test setup logic, modifies workspace-wide configuration files, and ensures all new JS-related jobs, scripts, and documentation now reference the correct paths and npm workspace.

Key Changes

• Replaces JS client testing and generation flows from clients/js to clients/new-js in CI and development scripts.
• Updates bin/ts-integration-test.sh to reliably build, start, and cleanup the server, generate types, enforce up-to-date generation, and run tests.
• Adds flexibility to API/types generation (gen-api.ts) to use an existing server if available to avoid redundant server starts.
• Converts test suite bootstrap code to prefer using an externally started server (suitable for CI/integration-run environments).
• Ensures .github/workflows/pr.yml and reusable actions reference clients/new-js; fixes jobs, directory globs, and job dependencies accordingly.
• Bumps native optional dependency versions in pnpm-lock.yaml and package.json.
• Applies various test file updates to use new host/port environment variable idioms.
• Introduces a simple YAML config for integration server config (bin/ts-integration-test-fe-config.yml).

Affected Areas

CI workflows: PR workflows, reusable JS test workflow
• Integration test and API generation bash and Node scripts
JS client test wrappers, test setup, and all test files
JS package management (pnpm, package.json, lock files)
TypeScript auto-generated API/types files and codegen logic

This summary was automatically generated by @propel-code-bot

Copy link
Contributor

blacksmith-sh bot commented Aug 27, 2025

2 Jobs Failed:

PR checks / all-required-pr-checks-passed

Step "Decide whether the needed jobs succeeded or failed" from job "all-required-pr-checks-passed" is failing. The last 20 log lines are:

[...]
}
EOM
)"
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  GITHUB_REPO_NAME: chroma-core/chroma
  PYTHONPATH: /home/runner/_work/_actions/re-actors/alls-green/release/v1/src
# ❌ Some of the required to succeed jobs failed 😢😢😢

📝 Job statuses:
📝 python-tests → ✓ success [required to succeed or be skipped]
📝 python-vulnerability-scan → ✓ success [required to succeed or be skipped]
📝 javascript-client-tests → ❌ failure [required to succeed or be skipped]
📝 rust-tests → ✓ success [required to succeed or be skipped]
📝 go-tests → ✓ success [required to succeed or be skipped]
📝 lint → ✓ success [required to succeed]
📝 check-helm-version-bump → ⬜ skipped [required to succeed or be skipped]
📝 delete-helm-comment → ✓ success [required to succeed or be skipped]
Error: Process completed with exit code 1.
PR checks / JavaScript client tests / test

Step "Test" from job "JavaScript client tests / test" is failing. The last 20 log lines are:

[...]

> [email protected] genapi /home/runner/_work/chroma/chroma/clients/new-js/packages/chromadb
> node --loader ts-node/esm scripts/gen-api.ts -- --use-localhost

(node:5566) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
⏳ Generating from http://localhost:8000/openapi.json
🔥 Unexpected error occurred. Log saved to /home/runner/_work/chroma/chroma/clients/new-js/packages/chromadb/openapi-ts-error-1756509561054.log
🔥 Unexpected error occurred. Request failed with status 200: 
Server stopped
✅ Cleaned up ./chroma directory
Error: Request failed with status 200: 
    at re (file:///home/runner/_work/chroma/chroma/clients/new-js/node_modules/.pnpm/@[email protected][email protected]/node_modules/@hey-api/openapi-ts/dist/index.js:8:3788)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async oi (file:///home/runner/_work/chroma/chroma/clients/new-js/node_modules/.pnpm/@[email protected][email protected]/node_modules/@hey-api/openapi-ts/dist/index.js:1304:3066)
    at async main (file:///home/runner/_work/chroma/chroma/clients/new-js/packages/chromadb/scripts/gen-api.ts:26:9)
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

Summary: 1 successful workflow, 1 failed workflow

Last updated: 2025-08-29 23:38:00 UTC

Comment on lines +24 to +25
export const client = createClient(
createConfig<ClientOptions>({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CriticalError]

Consider validating the default port configuration. The client defaults to 'http://localhost:8000' but the server starts on '127.0.0.1:8000'. This inconsistency could cause connection failures.

export const client = createClient(
  createConfig<ClientOptions>({
    baseUrl: "http://127.0.0.1:8000", // Match server host
    throwOnError: true,
  }),
);

Alternatively, ensure both use the same host consistently throughout the codebase.

Comment on lines 33 to 64
# Start the Chroma server in the background
echo "Building and starting Chroma server..."
cargo build --bin chroma
cargo run --bin chroma run &
SERVER_PID=$!

# Wait for the server to be ready
wait_for_server

# Install dependencies
cd clients/js

# Generate the JS client
# Generate API
echo "Generating JS client..."
pnpm genapi
cd clients/new-js/packages/chromadb
pnpm genapi -- --use-localhost

# Cleanup: kill the server process
kill $SERVER_PID

pnpm prettier

# run git diff and check if packages/chromadb-core/src/generated/ has changed
# run git diff and check if packages/chromadb/src/api/ has changed
echo "Checking for changes in generated client..."
if ! git diff --quiet --exit-code packages/chromadb-core/src/generated/; then
if ! git diff --quiet --exit-code src/api/; then
echo "Error: Generated JS client has changed. Please commit the changes."
git diff packages/chromadb-core/src/generated/ | cat
git diff src/api/ | cat
exit 1
fi
echo "No changes detected in generated client."

# Install dependencies and run tests
# Run tests
export DEFAULT_CHROMA_INSTANCE_URL="http://localhost:8000"
export DEFAULT_CHROMA_INSTANCE_HOST="127.0.0.1"

echo "Running tests..."
pnpm -r test --verbose
pnpm -r test

# Cleanup: kill the server process
kill $SERVER_PID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

The server process is started in the background, but the kill $SERVER_PID command is at the very end of the script. Since set -e is active, if any command fails before the end of the script (e.g., pnpm genapi, git diff, or pnpm test), the script will exit immediately, leaving the server process running. This could cause issues in CI environments by consuming resources.

Using a trap will ensure the server process is cleaned up regardless of how the script exits.

pnpm -r test

# Cleanup: kill the server process
kill $SERVER_PID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

For a more robust cleanup, consider killing the entire process group instead of just the single process. The cargo run command can spawn child processes that might be orphaned if only the parent process is killed, which could lead to resource leaks on the CI runner.

Using kill -- -$SERVER_PID sends the signal to all processes in the process group, ensuring a cleaner shutdown.

Suggested change
kill $SERVER_PID
kill -- -$SERVER_PID

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Comment on lines 5 to 9
# Function to check if server is ready
check_server() {
curl -s http://localhost:8000/openapi.json > /dev/null
return $?
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

To improve consistency and avoid potential issues with localhost resolving to IPv6 addresses in some environments, it would be better to use variables for the host and port and use 127.0.0.1 consistently. This also makes the script easier to configure if the port needs to be changed in the future.

Comment on lines 62 to 63
export DEFAULT_CHROMA_INSTANCE_URL="http://localhost:8000"
export DEFAULT_CHROMA_INSTANCE_HOST="127.0.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

Using the variables defined at the top of the script will ensure consistency.

Comment on lines +64 to +67
await rm("../../../../chroma_integration_test_tmp_dir/", {
recursive: true,
force: true,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BestPractice]

Using a relative path with ../../../../ to locate a directory from the project root can be brittle. If this script's location changes in the future, this path will break. A more robust approach is to construct the path programmatically using path.join and __dirname.

@itaismith itaismith closed this Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant