Skip to content

Commit 7fec3af

Browse files
authored
Add integration test for Deno (#281)
* Add integration test for Deno * Test local build of replicate
1 parent 9121805 commit 7fec3af

File tree

5 files changed

+162
-1
lines changed

5 files changed

+162
-1
lines changed

.github/workflows/ci.yml

+27-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ jobs:
141141
npm --prefix integration/${{ matrix.suite }} install "./${{ needs.build.outputs.tarball-name }}"
142142
npm --prefix integration/${{ matrix.suite }} test
143143
144-
145144
integration-bun:
146145
needs: [test, build]
147146
runs-on: ubuntu-latest
@@ -172,6 +171,33 @@ jobs:
172171
bun test && break || echo "Test failed, retrying..."
173172
done
174173
174+
integration-deno:
175+
needs: [test, build]
176+
runs-on: ubuntu-latest
177+
178+
env:
179+
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
180+
181+
strategy:
182+
matrix:
183+
deno-version: [v1.x]
184+
suite: [deno]
185+
186+
steps:
187+
- uses: actions/checkout@v4
188+
- uses: actions/download-artifact@v3
189+
with:
190+
name: package-tarball
191+
- name: Use Deno ${{ matrix.deno-version }}
192+
uses: denoland/setup-deno@v1
193+
with:
194+
deno-version: ${{ matrix.deno-version }}
195+
- run: |
196+
cd integration/deno
197+
deno cache --node-modules-dir index.ts
198+
tar -xzf ../../${{ needs.build.outputs.tarball-name }} --strip-components=1 -C node_modules/replicate
199+
deno test --allow-env --allow-net --node-modules-dir index.test.ts
200+
175201
integration-nextjs:
176202
needs: [test, build]
177203
runs-on: ubuntu-latest

integration/deno/deno.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"replicate": "npm:replicate"
4+
}
5+
}

integration/deno/deno.lock

+88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration/deno/index.test.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { assertEquals } from "jsr:@std/assert";
2+
import main from "./index.ts";
3+
4+
// Verify exported types.
5+
import type {
6+
Status,
7+
Visibility,
8+
WebhookEventType,
9+
ApiError,
10+
Collection,
11+
Hardware,
12+
Model,
13+
ModelVersion,
14+
Prediction,
15+
Training,
16+
Page,
17+
ServerSentEvent,
18+
} from "replicate";
19+
20+
Deno.test({
21+
name: "main",
22+
async fn() {
23+
const output = await main();
24+
assertEquals({ output }, { output: "hello Deno the dinosaur" });
25+
},
26+
});

integration/deno/index.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Replicate from "replicate";
2+
3+
const replicate = new Replicate({
4+
auth: Deno.env.get("REPLICATE_API_TOKEN"),
5+
});
6+
7+
export default async function main() {
8+
return await replicate.run(
9+
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
10+
{
11+
input: {
12+
text: "Deno the dinosaur",
13+
},
14+
}
15+
);
16+
}

0 commit comments

Comments
 (0)