Skip to content

Commit

Permalink
Add integration test for Deno (#281)
Browse files Browse the repository at this point in the history
* Add integration test for Deno

* Test local build of replicate
  • Loading branch information
mattt authored Jul 5, 2024
1 parent 9121805 commit 7fec3af
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ jobs:
npm --prefix integration/${{ matrix.suite }} install "./${{ needs.build.outputs.tarball-name }}"
npm --prefix integration/${{ matrix.suite }} test
integration-bun:
needs: [test, build]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -172,6 +171,33 @@ jobs:
bun test && break || echo "Test failed, retrying..."
done
integration-deno:
needs: [test, build]
runs-on: ubuntu-latest

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

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

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: package-tarball
- name: Use Deno ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- run: |
cd integration/deno
deno cache --node-modules-dir index.ts
tar -xzf ../../${{ needs.build.outputs.tarball-name }} --strip-components=1 -C node_modules/replicate
deno test --allow-env --allow-net --node-modules-dir index.test.ts
integration-nextjs:
needs: [test, build]
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions integration/deno/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"replicate": "npm:replicate"
}
}
88 changes: 88 additions & 0 deletions integration/deno/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions integration/deno/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { assertEquals } from "jsr:@std/assert";
import main from "./index.ts";

// Verify exported types.
import type {
Status,
Visibility,
WebhookEventType,
ApiError,
Collection,
Hardware,
Model,
ModelVersion,
Prediction,
Training,
Page,
ServerSentEvent,
} from "replicate";

Deno.test({
name: "main",
async fn() {
const output = await main();
assertEquals({ output }, { output: "hello Deno the dinosaur" });
},
});
16 changes: 16 additions & 0 deletions integration/deno/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Replicate from "replicate";

const replicate = new Replicate({
auth: Deno.env.get("REPLICATE_API_TOKEN"),
});

export default async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Deno the dinosaur",
},
}
);
}

0 comments on commit 7fec3af

Please sign in to comment.