Skip to content

Run integration tests with replicate/canary model #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:

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

Expand All @@ -32,15 +33,20 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases
node-version: [20.x]

outputs:
tarball-name: ${{ steps.pack.outputs.tarball-name }}

steps:
- uses: actions/checkout@v4
- name: Use Node.js
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Build tarball
id: pack
Expand All @@ -61,9 +67,9 @@ jobs:

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

steps:
Expand All @@ -90,9 +96,9 @@ jobs:

strategy:
matrix:
node-version: [20.x]
browser: ["chromium", "firefox", "webkit"]
suite: ["browser"]
browser: ["chromium", "firefox", "webkit"]
node-version: [20.x]
fail-fast: false

steps:
Expand Down Expand Up @@ -122,8 +128,8 @@ jobs:

strategy:
matrix:
node-version: [20.x]
suite: [cloudflare-worker]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
Expand All @@ -150,8 +156,8 @@ jobs:

strategy:
matrix:
bun-version: [1.0.11]
suite: [bun]
bun-version: [1.0.11]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -180,8 +186,8 @@ jobs:

strategy:
matrix:
deno-version: [v1.x]
suite: [deno]
deno-version: [v1.x]

steps:
- uses: actions/checkout@v4
Expand All @@ -202,6 +208,11 @@ jobs:
needs: [test, build]
runs-on: ubuntu-latest

strategy:
matrix:
suite: [nextjs]
node-version: [20.x]

env:
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}

Expand All @@ -213,7 +224,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: |
npm --prefix integration/next install
Expand Down
2 changes: 1 addition & 1 deletion integration/bun/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import type {

test("main", async () => {
const output = await main();
expect(output).toContain("Brünnhilde Bun");
expect(output).toEqual("hello there, Brünnhilde Bun");
});
5 changes: 3 additions & 2 deletions integration/commonjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const replicate = new Replicate({
});

module.exports = async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
const output = await replicate.run(
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
{
input: {
text: "Claire CommonJS",
},
}
);
return output.join("").trim();
};
2 changes: 1 addition & 1 deletion integration/commonjs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const main = require("./index");

test("main", async () => {
const output = await main();
assert.equal(output, "hello Claire CommonJS");
assert.equal(output, "hello there, Claire CommonJS");
});
2 changes: 1 addition & 1 deletion integration/deno/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Deno.test({
name: "main",
async fn() {
const output = await main();
assertEquals({ output }, { output: "hello Deno the dinosaur" });
assertEquals({ output }, { output: "hello there, Deno the dinosaur" });
},
});
7 changes: 4 additions & 3 deletions integration/deno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const replicate = new Replicate({
});

export default async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
const output = (await replicate.run(
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
{
input: {
text: "Deno the dinosaur",
},
}
);
)) as string[];
return output.join("").trim();
}
5 changes: 3 additions & 2 deletions integration/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const replicate = new Replicate({
});

export default async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
const output = await replicate.run(
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
{
input: {
text: "Evelyn ESM",
},
}
);
return Array.isArray(output) ? output.join("").trim() : String(output).trim();
}
2 changes: 1 addition & 1 deletion integration/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import main from "./index.js";

test("main", async () => {
const output = await main();
assert.equal(output, "hello Evelyn ESM");
assert.equal(output, "hello there, Evelyn ESM");
});
2 changes: 1 addition & 1 deletion integration/typescript/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ import type {

test("main", async () => {
const output = await main();
assert.equal(output, "hello Tracy TypeScript");
assert.equal(output, "hello there, Tracy TypeScript");
});
7 changes: 4 additions & 3 deletions integration/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const replicate = new Replicate({
});

export default async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
const output = (await replicate.run(
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272",
{
input: {
text: "Tracy TypeScript",
},
}
);
)) as string[];
return output.join("").trim();
}
Loading