Skip to content

Commit 8d8e599

Browse files
authored
Run integration tests with replicate/canary model (#283)
* Run integration tests with replicate/canary model * Update expected output * Add test matrix for Next.js * Reorder test matrix configurations * Add test matrix for build step
1 parent f70b3d9 commit 8d8e599

File tree

10 files changed

+39
-24
lines changed

10 files changed

+39
-24
lines changed

.github/workflows/ci.yml

+20-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15+
suite: [node]
1516
# See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases
1617
node-version: [18.x, 20.x, 22.x]
1718

@@ -32,15 +33,20 @@ jobs:
3233
build:
3334
runs-on: ubuntu-latest
3435

36+
strategy:
37+
matrix:
38+
# See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases
39+
node-version: [20.x]
40+
3541
outputs:
3642
tarball-name: ${{ steps.pack.outputs.tarball-name }}
3743

3844
steps:
3945
- uses: actions/checkout@v4
40-
- name: Use Node.js
46+
- name: Use Node.js ${{ matrix.node-version }}
4147
uses: actions/setup-node@v4
4248
with:
43-
node-version: 20.x
49+
node-version: ${{ matrix.node-version }}
4450
cache: "npm"
4551
- name: Build tarball
4652
id: pack
@@ -61,9 +67,9 @@ jobs:
6167

6268
strategy:
6369
matrix:
70+
suite: [commonjs, esm, typescript]
6471
# See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases
6572
node-version: [18.x, 20.x]
66-
suite: [commonjs, esm, typescript]
6773
fail-fast: false
6874

6975
steps:
@@ -90,9 +96,9 @@ jobs:
9096

9197
strategy:
9298
matrix:
93-
node-version: [20.x]
94-
browser: ["chromium", "firefox", "webkit"]
9599
suite: ["browser"]
100+
browser: ["chromium", "firefox", "webkit"]
101+
node-version: [20.x]
96102
fail-fast: false
97103

98104
steps:
@@ -122,8 +128,8 @@ jobs:
122128

123129
strategy:
124130
matrix:
125-
node-version: [20.x]
126131
suite: [cloudflare-worker]
132+
node-version: [20.x]
127133

128134
steps:
129135
- uses: actions/checkout@v4
@@ -150,8 +156,8 @@ jobs:
150156

151157
strategy:
152158
matrix:
153-
bun-version: [1.0.11]
154159
suite: [bun]
160+
bun-version: [1.0.11]
155161

156162
steps:
157163
- uses: actions/checkout@v4
@@ -180,8 +186,8 @@ jobs:
180186

181187
strategy:
182188
matrix:
183-
deno-version: [v1.x]
184189
suite: [deno]
190+
deno-version: [v1.x]
185191

186192
steps:
187193
- uses: actions/checkout@v4
@@ -202,6 +208,11 @@ jobs:
202208
needs: [test, build]
203209
runs-on: ubuntu-latest
204210

211+
strategy:
212+
matrix:
213+
suite: [nextjs]
214+
node-version: [20.x]
215+
205216
env:
206217
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
207218

@@ -213,7 +224,7 @@ jobs:
213224
- name: Use Node.js
214225
uses: actions/setup-node@v4
215226
with:
216-
node-version: 20.x
227+
node-version: ${{ matrix.node-version }}
217228
cache: "npm"
218229
- run: |
219230
npm --prefix integration/next install

integration/bun/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ import type {
1919

2020
test("main", async () => {
2121
const output = await main();
22-
expect(output).toContain("Brünnhilde Bun");
22+
expect(output).toEqual("hello there, Brünnhilde Bun");
2323
});

integration/commonjs/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ const replicate = new Replicate({
55
});
66

77
module.exports = async function main() {
8-
return await replicate.run(
9-
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
8+
const output = await replicate.run(
9+
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
1010
{
1111
input: {
1212
text: "Claire CommonJS",
1313
},
1414
}
1515
);
16+
return output.join("").trim();
1617
};

integration/commonjs/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ const main = require("./index");
44

55
test("main", async () => {
66
const output = await main();
7-
assert.equal(output, "hello Claire CommonJS");
7+
assert.equal(output, "hello there, Claire CommonJS");
88
});

integration/deno/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ Deno.test({
2121
name: "main",
2222
async fn() {
2323
const output = await main();
24-
assertEquals({ output }, { output: "hello Deno the dinosaur" });
24+
assertEquals({ output }, { output: "hello there, Deno the dinosaur" });
2525
},
2626
});

integration/deno/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ const replicate = new Replicate({
55
});
66

77
export default async function main() {
8-
return await replicate.run(
9-
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
8+
const output = (await replicate.run(
9+
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
1010
{
1111
input: {
1212
text: "Deno the dinosaur",
1313
},
1414
}
15-
);
15+
)) as string[];
16+
return output.join("").trim();
1617
}

integration/esm/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ const replicate = new Replicate({
55
});
66

77
export default async function main() {
8-
return await replicate.run(
9-
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
8+
const output = await replicate.run(
9+
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
1010
{
1111
input: {
1212
text: "Evelyn ESM",
1313
},
1414
}
1515
);
16+
return Array.isArray(output) ? output.join("").trim() : String(output).trim();
1617
}

integration/esm/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import main from "./index.js";
44

55
test("main", async () => {
66
const output = await main();
7-
assert.equal(output, "hello Evelyn ESM");
7+
assert.equal(output, "hello there, Evelyn ESM");
88
});

integration/typescript/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ import type {
2020

2121
test("main", async () => {
2222
const output = await main();
23-
assert.equal(output, "hello Tracy TypeScript");
23+
assert.equal(output, "hello there, Tracy TypeScript");
2424
});

integration/typescript/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ const replicate = new Replicate({
55
});
66

77
export default async function main() {
8-
return await replicate.run(
9-
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
8+
const output = (await replicate.run(
9+
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
1010
{
1111
input: {
1212
text: "Tracy TypeScript",
1313
},
1414
}
15-
);
15+
)) as string[];
16+
return output.join("").trim();
1617
}

0 commit comments

Comments
 (0)