Skip to content

Commit 07ee5eb

Browse files
CI: run ecosystem tests (openai#77)
1 parent 07b334b commit 07ee5eb

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,32 @@ jobs:
4545

4646
- name: Run tests
4747
run: ./scripts/test
48+
49+
ecosystem_tests:
50+
name: ecosystem tests
51+
runs-on: ubuntu-latest
52+
if: github.repository == 'stainless-sdks/openai-typescript'
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Set up Node
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: '18'
61+
62+
- uses: denoland/setup-deno@v1
63+
with:
64+
deno-version: v1.39.0
65+
66+
- uses: oven-sh/setup-bun@v2
67+
68+
- name: Bootstrap
69+
run: ./scripts/bootstrap
70+
71+
- name: Run ecosystem tests
72+
run: |
73+
echo 'OPENAI_API_KEY = "'"${OPENAI_API_KEY}"'"' >> ecosystem-tests/cloudflare-worker/wrangler.toml
74+
yarn tsn ecosystem-tests/cli.ts --live --verbose --parallel --jobs=4 --retry=3
75+
env:
76+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as shims from 'openai/_shims/index';
2-
import * as fd from 'formdata-node';
32

43
test('openai/shims/node', () => {
54
expect(shims.kind).toEqual('node');
6-
expect(shims.File).toBe(fd.File);
5+
expect(shims.File).toBe(File);
76
});

ecosystem-tests/node-ts-esm/tests/test-esnext.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ it(`raw response`, async function () {
5454

5555
// test that we can use node-fetch Response API
5656
const chunks: string[] = [];
57-
const { body } = response;
58-
if (!body) throw new Error(`expected response.body to be defined`);
59-
body.on('data', (chunk) => chunks.push(chunk));
60-
await new Promise<void>((resolve, reject) => {
61-
body.once('end', resolve);
62-
body.once('error', reject);
63-
});
57+
if (!response.body) throw new Error(`expected response.body to be defined`);
58+
59+
const decoder = new TextDecoder();
60+
61+
for await (const chunk of response.body) {
62+
chunks.push(decoder.decode(chunk));
63+
}
64+
6465
const json: ChatCompletion = JSON.parse(chunks.join(''));
6566
expect(json.choices[0]?.message.content || '').toBeSimilarTo('This is a test', 10);
6667
});

0 commit comments

Comments
 (0)