diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d4345e..c6ca04e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases + node-version: [18.x, 20.x] steps: - uses: actions/checkout@v3 @@ -27,23 +27,51 @@ jobs: - run: npm run check - run: npm run lint - integration: + + integration-node: needs: test runs-on: ubuntu-latest + env: + REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }} + strategy: matrix: # See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases node-version: [18.x, 20.x] - suite: [commonjs, esm, typescript, cloudflare-worker] + suite: [commonjs, esm, typescript] exclude: - suite: cloudflare-worker node-version: 18.x # Only test Cloudflare suite with the latest Node version fail-fast: false + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + # Build a production tarball and run the integration tests against it. + - run: | + PKG_TARBALL=$(npm --loglevel error pack) + npm --prefix integration/${{ matrix.suite }} install + npm --prefix integration/${{ matrix.suite }} install "file:/./$PKG_TARBALL" + npm --prefix integration/${{ matrix.suite }} test + + + integration-edge: + needs: test + runs-on: ubuntu-latest + env: REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }} + strategy: + matrix: + node-version: [20.x] + suite: [cloudflare-worker] + steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} @@ -58,3 +86,35 @@ jobs: npm --prefix integration/${{ matrix.suite }} install npm --prefix integration/${{ matrix.suite }} install "file:/./$PKG_TARBALL" npm --prefix integration/${{ matrix.suite }} test + + + integration-bun: + needs: test + runs-on: ubuntu-latest + + env: + REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }} + + strategy: + matrix: + bun-version: [1.0.11] + node-version: [20.x] + suite: [bun] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - name: Use Bun ${{ matrix.bun-version }} + uses: oven-sh/setup-bun@v1 + with: + bun-version: ${{ matrix.bun-version }} + - run: | + PKG_TARBALL=$(npm --loglevel error pack) + cd integration/${{ matrix.suite }} + bun uninstall replicate + bun install "file:../../$PKG_TARBALL" + bun test diff --git a/integration/bun/.gitignore b/integration/bun/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/integration/bun/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/integration/bun/bun.lockb b/integration/bun/bun.lockb new file mode 100755 index 0000000..dd45eaf Binary files /dev/null and b/integration/bun/bun.lockb differ diff --git a/integration/bun/index.test.ts b/integration/bun/index.test.ts new file mode 100644 index 0000000..e9fbaab --- /dev/null +++ b/integration/bun/index.test.ts @@ -0,0 +1,23 @@ +import { expect, test } from "bun:test"; +import main from "./index.js"; + +// Verify exported types. +import type { + Status, + Visibility, + WebhookEventType, + ApiError, + Collection, + Hardware, + Model, + ModelVersion, + Prediction, + Training, + Page, + ServerSentEvent, +} from "replicate"; + +test("main", async () => { + const output = await main(); + expect(output as any).toEqual("hello Brünnhilde Bun"); +}); diff --git a/integration/bun/index.ts b/integration/bun/index.ts new file mode 100644 index 0000000..263a86e --- /dev/null +++ b/integration/bun/index.ts @@ -0,0 +1,16 @@ +import Replicate from "replicate"; + +const replicate = new Replicate({ + auth: process.env.REPLICATE_API_TOKEN, +}); + +export default async function main() { + return await replicate.run( + "replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", + { + input: { + text: "Brünnhilde Bun", + }, + } + ); +} diff --git a/integration/bun/package.json b/integration/bun/package.json new file mode 100644 index 0000000..f4ba202 --- /dev/null +++ b/integration/bun/package.json @@ -0,0 +1,14 @@ +{ + "name": "replicate-app-bun", + "version": "0.0.0", + "private": true, + "description": "Bun integration tests", + "main": "index.js", + "type": "module", + "dependencies": { + "replicate": "file:../../" + }, + "devDependencies": { + "@types/bun": "latest" + } +} diff --git a/integration/bun/tsconfig.json b/integration/bun/tsconfig.json new file mode 100644 index 0000000..2ffa937 --- /dev/null +++ b/integration/bun/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es2018", + "module": "nodenext", + "inlineSourceMap": true, + "outDir": "./dist", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "skipDefaultLibCheck": true, + "skipLibCheck": true + } +} diff --git a/tsconfig.json b/tsconfig.json index b699d79..e6b4ed6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,8 @@ "allowJs": true }, "exclude": [ - "**/node_modules" + "**/node_modules", + "integration/**" ] -} \ No newline at end of file +} +