Skip to content

Commit af447ec

Browse files
authored
[CHORE] Fix JS CI (#5393)
## Description of changes Wire new JS clients to CI. The integration script takes advantage of the new API generator and testing suite that are able to start a server on their own from the Rust code. ## Test plan - [x] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust
1 parent 38cf472 commit af447ec

File tree

6 files changed

+41
-77
lines changed

6 files changed

+41
-77
lines changed

.github/workflows/_javascript-client-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
with:
1818
version: "9"
1919
- name: Install dependencies
20-
run: cd clients/js && pnpm install --no-frozen-lockfile
20+
run: cd clients/new-js && pnpm install --no-frozen-lockfile
2121
- name: Test
2222
run: bin/ts-integration-test.sh

bin/ts-integration-test.sh

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,24 @@
11
#!/usr/bin/env bash
22
set -e
3-
# Function to check if server is ready
4-
check_server() {
5-
curl -s http://localhost:8000/openapi.json > /dev/null
6-
return $?
7-
}
8-
# Function to wait for server with exponential backoff
9-
wait_for_server() {
10-
local max_attempts=10
11-
local attempt=1
12-
local base_delay=1
13-
local max_delay=32
14-
echo "Waiting for server to start..."
15-
while [ $attempt -le $max_attempts ]; do
16-
if check_server; then
17-
echo "Server is ready!"
18-
return 0
19-
fi
20-
delay=$((base_delay * (2 ** (attempt - 1)))) # Exponential backoff
21-
delay=$((delay < max_delay ? delay : max_delay)) # Cap at max_delay
22-
echo "Attempt $attempt/$max_attempts: Server not ready, waiting ${delay}s..."
23-
sleep $delay
24-
attempt=$((attempt + 1))
25-
done
26-
echo "Error: Server failed to start after $max_attempts attempts"
27-
return 1
28-
}
29-
# Start the Chroma server in the background
30-
echo "Building and starting Chroma server..."
31-
cargo build --bin chroma
32-
cargo run --bin chroma run &
33-
SERVER_PID=$!
34-
# Wait for the server to be ready
35-
wait_for_server
363

374
# Install dependencies
38-
cd clients/js
5+
cd clients/new-js
6+
pnpm build
397

408
# Generate the JS client
419
echo "Generating JS client..."
42-
pnpm genapi
10+
pnpm genapi:chromadb
4311

44-
# Cleanup: kill the server process
45-
kill $SERVER_PID
46-
47-
pnpm prettier
48-
49-
# run git diff and check if packages/chromadb-core/src/generated/ has changed
12+
# run git diff and check if packages/chromadb/src/api/ has changed
5013
echo "Checking for changes in generated client..."
51-
if ! git diff --quiet --exit-code packages/chromadb-core/src/generated/; then
14+
if ! git diff --quiet --exit-code packages/chromadb/src/api/; then
5215
echo "Error: Generated JS client has changed. Please commit the changes."
53-
git diff packages/chromadb-core/src/generated/ | cat
16+
git diff packages/chromadb/src/api/ | cat
5417
exit 1
5518
fi
5619
echo "No changes detected in generated client."
5720

5821
# Install dependencies and run tests
5922
echo "Running tests..."
60-
pnpm -r test --verbose
23+
cd packages/chromadb
24+
pnpm test --verbose

clients/new-js/packages/chromadb/src/api/client.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =
1616
export const client = createClient(createConfig<ClientOptions>({
1717
baseUrl: 'http://localhost:8000',
1818
throwOnError: true
19-
}));
19+
}));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22
export * from './types.gen';
3-
export * from './sdk.gen';
3+
export * from './sdk.gen';

clients/new-js/packages/chromadb/src/api/sdk.gen.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class DefaultService {
2828
...options
2929
});
3030
}
31-
31+
3232
/**
3333
* Retrieves a collection by Chroma Resource Name.
3434
*/
@@ -38,7 +38,7 @@ export class DefaultService {
3838
...options
3939
});
4040
}
41-
41+
4242
/**
4343
* Health check endpoint that returns 200 if the server and executor are ready
4444
*/
@@ -48,7 +48,7 @@ export class DefaultService {
4848
...options
4949
});
5050
}
51-
51+
5252
/**
5353
* Heartbeat endpoint that returns a nanosecond timestamp of the current time.
5454
*/
@@ -58,7 +58,7 @@ export class DefaultService {
5858
...options
5959
});
6060
}
61-
61+
6262
/**
6363
* Pre-flight checks endpoint reporting basic readiness info.
6464
*/
@@ -68,7 +68,7 @@ export class DefaultService {
6868
...options
6969
});
7070
}
71-
71+
7272
/**
7373
* Reset endpoint allowing authorized users to reset the database.
7474
*/
@@ -78,7 +78,7 @@ export class DefaultService {
7878
...options
7979
});
8080
}
81-
81+
8282
/**
8383
* Creates a new tenant.
8484
*/
@@ -92,7 +92,7 @@ export class DefaultService {
9292
}
9393
});
9494
}
95-
95+
9696
/**
9797
* Returns an existing tenant by name.
9898
*/
@@ -102,7 +102,7 @@ export class DefaultService {
102102
...options
103103
});
104104
}
105-
105+
106106
/**
107107
* Updates an existing tenant by name.
108108
*/
@@ -116,7 +116,7 @@ export class DefaultService {
116116
}
117117
});
118118
}
119-
119+
120120
/**
121121
* Lists all databases for a given tenant.
122122
*/
@@ -126,7 +126,7 @@ export class DefaultService {
126126
...options
127127
});
128128
}
129-
129+
130130
/**
131131
* Creates a new database for a given tenant.
132132
*/
@@ -140,7 +140,7 @@ export class DefaultService {
140140
}
141141
});
142142
}
143-
143+
144144
/**
145145
* Deletes a specific database.
146146
*/
@@ -150,7 +150,7 @@ export class DefaultService {
150150
...options
151151
});
152152
}
153-
153+
154154
/**
155155
* Retrieves a specific database by name.
156156
*/
@@ -160,7 +160,7 @@ export class DefaultService {
160160
...options
161161
});
162162
}
163-
163+
164164
/**
165165
* Lists all collections in the specified database.
166166
*/
@@ -170,7 +170,7 @@ export class DefaultService {
170170
...options
171171
});
172172
}
173-
173+
174174
/**
175175
* Creates a new collection under the specified database.
176176
*/
@@ -184,7 +184,7 @@ export class DefaultService {
184184
}
185185
});
186186
}
187-
187+
188188
/**
189189
* Deletes a collection in a given database.
190190
*/
@@ -194,7 +194,7 @@ export class DefaultService {
194194
...options
195195
});
196196
}
197-
197+
198198
/**
199199
* Retrieves a collection by ID or name.
200200
*/
@@ -204,7 +204,7 @@ export class DefaultService {
204204
...options
205205
});
206206
}
207-
207+
208208
/**
209209
* Updates an existing collection's name or metadata.
210210
*/
@@ -218,7 +218,7 @@ export class DefaultService {
218218
}
219219
});
220220
}
221-
221+
222222
/**
223223
* Adds records to a collection.
224224
*/
@@ -232,7 +232,7 @@ export class DefaultService {
232232
}
233233
});
234234
}
235-
235+
236236
/**
237237
* Retrieves the number of records in a collection.
238238
*/
@@ -242,7 +242,7 @@ export class DefaultService {
242242
...options
243243
});
244244
}
245-
245+
246246
/**
247247
* Deletes records in a collection. Can filter by IDs or metadata.
248248
*/
@@ -256,7 +256,7 @@ export class DefaultService {
256256
}
257257
});
258258
}
259-
259+
260260
/**
261261
* Forks an existing collection.
262262
*/
@@ -270,7 +270,7 @@ export class DefaultService {
270270
}
271271
});
272272
}
273-
273+
274274
/**
275275
* Retrieves records from a collection by ID or metadata filter.
276276
*/
@@ -284,7 +284,7 @@ export class DefaultService {
284284
}
285285
});
286286
}
287-
287+
288288
/**
289289
* Query a collection in a variety of ways, including vector search, metadata filtering, and full-text search
290290
*/
@@ -298,7 +298,7 @@ export class DefaultService {
298298
}
299299
});
300300
}
301-
301+
302302
/**
303303
* Updates records in a collection by ID.
304304
*/
@@ -312,7 +312,7 @@ export class DefaultService {
312312
}
313313
});
314314
}
315-
315+
316316
/**
317317
* Upserts records in a collection (create if not exists, otherwise update).
318318
*/
@@ -326,7 +326,7 @@ export class DefaultService {
326326
}
327327
});
328328
}
329-
329+
330330
/**
331331
* Retrieves the total number of collections in a given database.
332332
*/
@@ -336,7 +336,7 @@ export class DefaultService {
336336
...options
337337
});
338338
}
339-
339+
340340
/**
341341
* Returns the version of the server.
342342
*/
@@ -346,5 +346,5 @@ export class DefaultService {
346346
...options
347347
});
348348
}
349-
350-
}
349+
350+
}

clients/new-js/packages/chromadb/src/api/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,4 +1320,4 @@ export type VersionResponse = VersionResponses[keyof VersionResponses];
13201320

13211321
export type ClientOptions = {
13221322
baseUrl: 'http://127.0.0.1:8000' | (string & {});
1323-
};
1323+
};

0 commit comments

Comments
 (0)