Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,26 @@ jobs:
- run: npm run test
- run: npm run check
- run: npm run lint

integration:
needs: test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]
suite: [commonjs, esm, typescript]
# See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases

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

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"
- run: npm --prefix integration/${{ matrix.suite }} ci --omit=dev
- run: npm --prefix integration/${{ matrix.suite }} test
16 changes: 16 additions & 0 deletions integration/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const Replicate = require("replicate");

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

module.exports = async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Claire CommonJS"
}
}
);
};
8 changes: 8 additions & 0 deletions integration/commonjs/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { test } = require('node:test');
const assert = require('node:assert');
const main = require('./index');

test('main', async () => {
const output = await main();
assert.equal(output, "hello Claire CommonJS");
});
42 changes: 42 additions & 0 deletions integration/commonjs/package-lock.json

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

13 changes: 13 additions & 0 deletions integration/commonjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "replicate-app-commonjs",
"version": "0.0.0",
"private": true,
"description": "CommonJS integration tests",
"main": "index.js",
"scripts": {
"test": "node --test ./index.test.js"
},
"dependencies": {
"replicate": "file:../../"
}
}
16 changes: 16 additions & 0 deletions integration/esm/index.js
Original file line number Diff line number Diff line change
@@ -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: "Evelyn ESM"
}
}
);
};
8 changes: 8 additions & 0 deletions integration/esm/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test } from 'node:test';
import assert from 'node:assert';
import main from './index.js';

test('main', async () => {
const output = await main();
assert.equal(output, "hello Evelyn ESM");
});
43 changes: 43 additions & 0 deletions integration/esm/package-lock.json

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

14 changes: 14 additions & 0 deletions integration/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "replicate-app-esm",
"version": "0.0.0",
"private": true,
"description": "ESM (ECMAScript Modules) integration tests",
"main": "index.js",
"type": "module",
"scripts": {
"test": "node --test ./index.test.js"
},
"dependencies": {
"replicate": "file:../../"
}
}
24 changes: 24 additions & 0 deletions integration/typescript/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test } from 'node:test';
import assert from 'node:assert';
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();
assert.equal(output, "hello Tracy TypeScript");
});
16 changes: 16 additions & 0 deletions integration/typescript/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: process.env.REPLICATE_API_TOKEN,
});

export default async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Tracy TypeScript"
}
}
);
};
70 changes: 70 additions & 0 deletions integration/typescript/package-lock.json

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

16 changes: 16 additions & 0 deletions integration/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "replicate-app-typescript",
"version": "0.0.0",
"private": true,
"description": "TypeScript integration tests",
"main": "index.js",
"type": "module",
"scripts": {
"test": "tsc && node --test ./dist/index.test.js"
},
"dependencies": {
"@types/node": "^20.11.0",
"replicate": "file:../../",
"typescript": "^5.3.3"
}
}
Loading