From 5c0f09a8921e8978ff7e5dfaeb7db4dfebee4544 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 5 Jul 2024 05:40:12 -0700 Subject: [PATCH 1/5] Run integration tests with replicate/canary model --- integration/bun/index.test.ts | 2 +- integration/commonjs/index.js | 2 +- integration/commonjs/index.test.js | 2 +- integration/deno/index.test.ts | 2 +- integration/deno/index.ts | 2 +- integration/esm/index.js | 2 +- integration/esm/index.test.js | 2 +- integration/typescript/index.test.ts | 2 +- integration/typescript/index.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/integration/bun/index.test.ts b/integration/bun/index.test.ts index 1357e5ba..f0665a6d 100644 --- a/integration/bun/index.test.ts +++ b/integration/bun/index.test.ts @@ -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"); }); diff --git a/integration/commonjs/index.js b/integration/commonjs/index.js index 40f00cd0..d063d21f 100644 --- a/integration/commonjs/index.js +++ b/integration/commonjs/index.js @@ -6,7 +6,7 @@ const replicate = new Replicate({ module.exports = async function main() { return await replicate.run( - "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", + "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { text: "Claire CommonJS", diff --git a/integration/commonjs/index.test.js b/integration/commonjs/index.test.js index 6e0f8b2a..afc3c014 100644 --- a/integration/commonjs/index.test.js +++ b/integration/commonjs/index.test.js @@ -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"); }); diff --git a/integration/deno/index.test.ts b/integration/deno/index.test.ts index 28965d57..e944d770 100644 --- a/integration/deno/index.test.ts +++ b/integration/deno/index.test.ts @@ -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" }); }, }); diff --git a/integration/deno/index.ts b/integration/deno/index.ts index 069e28a0..8c19ffbb 100644 --- a/integration/deno/index.ts +++ b/integration/deno/index.ts @@ -6,7 +6,7 @@ const replicate = new Replicate({ export default async function main() { return await replicate.run( - "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", + "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { text: "Deno the dinosaur", diff --git a/integration/esm/index.js b/integration/esm/index.js index 9264f3c0..67604dae 100644 --- a/integration/esm/index.js +++ b/integration/esm/index.js @@ -6,7 +6,7 @@ const replicate = new Replicate({ export default async function main() { return await replicate.run( - "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", + "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { text: "Evelyn ESM", diff --git a/integration/esm/index.test.js b/integration/esm/index.test.js index 7549e909..c95ab8b0 100644 --- a/integration/esm/index.test.js +++ b/integration/esm/index.test.js @@ -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"); }); diff --git a/integration/typescript/index.test.ts b/integration/typescript/index.test.ts index b7928c5d..0f0f356b 100644 --- a/integration/typescript/index.test.ts +++ b/integration/typescript/index.test.ts @@ -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"); }); diff --git a/integration/typescript/index.ts b/integration/typescript/index.ts index e49f75c2..f801ae99 100644 --- a/integration/typescript/index.ts +++ b/integration/typescript/index.ts @@ -6,7 +6,7 @@ const replicate = new Replicate({ export default async function main() { return await replicate.run( - "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", + "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { text: "Tracy TypeScript", From ca4a707922045573b3c20a90a6cd3087231b7281 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 5 Jul 2024 05:46:46 -0700 Subject: [PATCH 2/5] Update expected output --- integration/commonjs/index.js | 3 ++- integration/deno/index.ts | 5 +++-- integration/esm/index.js | 3 ++- integration/typescript/index.ts | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/integration/commonjs/index.js b/integration/commonjs/index.js index d063d21f..6d8c436b 100644 --- a/integration/commonjs/index.js +++ b/integration/commonjs/index.js @@ -5,7 +5,7 @@ const replicate = new Replicate({ }); module.exports = async function main() { - return await replicate.run( + const output = await replicate.run( "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { @@ -13,4 +13,5 @@ module.exports = async function main() { }, } ); + return output.join("").trim(); }; diff --git a/integration/deno/index.ts b/integration/deno/index.ts index 8c19ffbb..a235699b 100644 --- a/integration/deno/index.ts +++ b/integration/deno/index.ts @@ -5,12 +5,13 @@ const replicate = new Replicate({ }); export default async function main() { - return await replicate.run( + const output = (await replicate.run( "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { text: "Deno the dinosaur", }, } - ); + )) as string[]; + return output.join("").trim(); } diff --git a/integration/esm/index.js b/integration/esm/index.js index 67604dae..48feccb7 100644 --- a/integration/esm/index.js +++ b/integration/esm/index.js @@ -5,7 +5,7 @@ const replicate = new Replicate({ }); export default async function main() { - return await replicate.run( + const output = await replicate.run( "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { @@ -13,4 +13,5 @@ export default async function main() { }, } ); + return Array.isArray(output) ? output.join("").trim() : String(output).trim(); } diff --git a/integration/typescript/index.ts b/integration/typescript/index.ts index f801ae99..1b276bc9 100644 --- a/integration/typescript/index.ts +++ b/integration/typescript/index.ts @@ -5,12 +5,13 @@ const replicate = new Replicate({ }); export default async function main() { - return await replicate.run( + const output = (await replicate.run( "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272", { input: { text: "Tracy TypeScript", }, } - ); + )) as string[]; + return output.join("").trim(); } From 9dc602f3cf01b4070315c0ea3f07388efd9db211 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 5 Jul 2024 05:48:48 -0700 Subject: [PATCH 3/5] Add test matrix for Next.js --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87b1f75e..d441eb39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,6 +202,11 @@ jobs: needs: [test, build] runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + suite: [nextjs] + env: REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }} @@ -213,7 +218,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 From fad4b7f98333051474357d4bb56d5dfc3b14907f Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 5 Jul 2024 05:50:44 -0700 Subject: [PATCH 4/5] Reorder test matrix configurations --- .github/workflows/ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d441eb39..b46bb10a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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] @@ -61,9 +62,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: @@ -90,9 +91,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: @@ -122,8 +123,8 @@ jobs: strategy: matrix: - node-version: [20.x] suite: [cloudflare-worker] + node-version: [20.x] steps: - uses: actions/checkout@v4 @@ -150,8 +151,8 @@ jobs: strategy: matrix: - bun-version: [1.0.11] suite: [bun] + bun-version: [1.0.11] steps: - uses: actions/checkout@v4 @@ -180,8 +181,8 @@ jobs: strategy: matrix: - deno-version: [v1.x] suite: [deno] + deno-version: [v1.x] steps: - uses: actions/checkout@v4 @@ -204,8 +205,8 @@ jobs: strategy: matrix: - node-version: [20.x] suite: [nextjs] + node-version: [20.x] env: REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }} From 90d6d1544b22dd88d90ceb145a17aea99004f517 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 5 Jul 2024 05:56:00 -0700 Subject: [PATCH 5/5] Add test matrix for build step --- .github/workflows/ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b46bb10a..27a982cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,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