Skip to content

Commit ea3e643

Browse files
committed
Add integration test for Bun
1 parent 46bc3f2 commit ea3e643

File tree

8 files changed

+404
-5
lines changed

8 files changed

+404
-5
lines changed

.github/workflows/ci.yml

+55-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212

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

1818
steps:
1919
- uses: actions/checkout@v3
@@ -27,23 +27,51 @@ jobs:
2727
- run: npm run check
2828
- run: npm run lint
2929

30-
integration:
30+
31+
integration-node:
3132
needs: test
3233
runs-on: ubuntu-latest
3334

35+
env:
36+
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
37+
3438
strategy:
3539
matrix:
3640
# See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases
3741
node-version: [18.x, 20.x]
38-
suite: [commonjs, esm, typescript, cloudflare-worker]
42+
suite: [commonjs, esm, typescript]
3943
exclude:
4044
- suite: cloudflare-worker
4145
node-version: 18.x # Only test Cloudflare suite with the latest Node version
4246
fail-fast: false
4347

48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: Use Node.js ${{ matrix.node-version }}
51+
uses: actions/setup-node@v3
52+
with:
53+
node-version: ${{ matrix.node-version }}
54+
cache: "npm"
55+
# Build a production tarball and run the integration tests against it.
56+
- run: |
57+
PKG_TARBALL=$(npm --loglevel error pack)
58+
npm --prefix integration/${{ matrix.suite }} install
59+
npm --prefix integration/${{ matrix.suite }} install "file:/./$PKG_TARBALL"
60+
npm --prefix integration/${{ matrix.suite }} test
61+
62+
63+
integration-edge:
64+
needs: test
65+
runs-on: ubuntu-latest
66+
4467
env:
4568
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
4669

70+
strategy:
71+
matrix:
72+
node-version: [20.x]
73+
suite: [cloudflare-worker]
74+
4775
steps:
4876
- uses: actions/checkout@v3
4977
- name: Use Node.js ${{ matrix.node-version }}
@@ -58,3 +86,27 @@ jobs:
5886
npm --prefix integration/${{ matrix.suite }} install
5987
npm --prefix integration/${{ matrix.suite }} install "file:/./$PKG_TARBALL"
6088
npm --prefix integration/${{ matrix.suite }} test
89+
90+
91+
integration-bun:
92+
needs: test
93+
runs-on: ubuntu-latest
94+
95+
env:
96+
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
97+
98+
strategy:
99+
matrix:
100+
bun-version: [1.0.11]
101+
suite: [bun]
102+
103+
steps:
104+
- uses: actions/checkout@v3
105+
- name: Use Bun ${{ matrix.bun-version }}
106+
uses: oven-sh/setup-bun@v1
107+
with:
108+
bun-version: ${{ matrix.bun-version }}
109+
- run: |
110+
cd integration/${{ matrix.suite }}
111+
bun install
112+
bun test

integration/bun/.gitignore

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.parcel-cache
112+
113+
# Next.js build output
114+
115+
.next
116+
out
117+
118+
# Nuxt.js build / generate output
119+
120+
.nuxt
121+
dist
122+
123+
# Gatsby files
124+
125+
# Comment in the public line in if your project uses Gatsby and not Next.js
126+
127+
# https://nextjs.org/blog/next-9-1#public-directory-support
128+
129+
# public
130+
131+
# vuepress build output
132+
133+
.vuepress/dist
134+
135+
# vuepress v2.x temp and cache directory
136+
137+
.temp
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.*
170+
171+
# IntelliJ based IDEs
172+
.idea
173+
174+
# Finder (MacOS) folder config
175+
.DS_Store

integration/bun/bun.lockb

162 KB
Binary file not shown.

integration/bun/index.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { expect, test } from "bun:test";
2+
import main from "./index.js";
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+
test("main", async () => {
21+
const output = await main();
22+
expect(output as any).toEqual("hello Brünnhilde Bun");
23+
});

integration/bun/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: process.env.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: "Brünnhilde Bun",
13+
},
14+
}
15+
);
16+
}

integration/bun/package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "replicate-app-bun",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "Bun integration tests",
6+
"main": "index.js",
7+
"type": "module",
8+
"scripts": {
9+
"test": "tsc && node --test ./dist/index.test.js"
10+
},
11+
"dependencies": {
12+
"@types/node": "^20.11.0",
13+
"replicate": "file:../../",
14+
"typescript": "^5.3.3"
15+
},
16+
"devDependencies": {
17+
"@types/bun": "latest"
18+
},
19+
"peerDependencies": {
20+
"typescript": "^5.0.0"
21+
}
22+
}

0 commit comments

Comments
 (0)