add integ test step in github actions
This commit is contained in:
parent
f919c3f3e1
commit
9950766b32
@ -17,6 +17,9 @@ jobs:
|
|||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: bun install
|
run: bun install
|
||||||
|
|
||||||
|
- name: run api integ test
|
||||||
|
run: bun integ-test-api
|
||||||
|
|
||||||
- name: Deploy Doorman UI and API
|
- name: Deploy Doorman UI and API
|
||||||
run: bun run deploy-serverless
|
run: bun run deploy-serverless
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
"bun-types": "latest"
|
"bun-types": "latest"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"integ-test-api": "bun --filter 'doorman-api' integ-test",
|
||||||
"prepare-ui": "bun --filter 'doorman-ui' build && rm -rf packages/doorman-api/assets/* && mkdir -p packages/doorman-api/assets/assets && cp -fr packages/doorman-ui/dist/* packages/doorman-api/assets/ && cp -f packages/doorman-api/assets/index.html packages/doorman-api/assets/assets/index.html",
|
"prepare-ui": "bun --filter 'doorman-ui' build && rm -rf packages/doorman-api/assets/* && mkdir -p packages/doorman-api/assets/assets && cp -fr packages/doorman-ui/dist/* packages/doorman-api/assets/ && cp -f packages/doorman-api/assets/index.html packages/doorman-api/assets/assets/index.html",
|
||||||
"deploy-serverless": "bun run prepare-ui && bun run build-twilio-api && bun --filter 'doorman-api' deploy",
|
"deploy-serverless": "bun run prepare-ui && bun run build-twilio-api && bun --filter 'doorman-api' deploy",
|
||||||
"build-twilio-client": "bun --filter 'doorman-client' build",
|
"build-twilio-client": "bun --filter 'doorman-client' build",
|
||||||
|
|||||||
@ -8,6 +8,8 @@ AWS_SECRET_ACCESS_KEY=
|
|||||||
|
|
||||||
# discord notifs
|
# discord notifs
|
||||||
DISCORD_BOT_TOKEN=
|
DISCORD_BOT_TOKEN=
|
||||||
|
DISCORD_CLIENT_ID=
|
||||||
|
DISCORD_CLIENT_SECRET=
|
||||||
|
|
||||||
# metrics
|
# metrics
|
||||||
PUSHGATEWAY_URL=https://metrics.chromart.cc
|
PUSHGATEWAY_URL=https://metrics.chromart.cc
|
||||||
@ -22,4 +24,5 @@ LOKI_PW=doormanlogs
|
|||||||
|
|
||||||
NOTIFY_SECRET_KEY=discordnotifyme
|
NOTIFY_SECRET_KEY=discordnotifyme
|
||||||
|
|
||||||
DOORMAN_URL=https://doorman.chromart.cc
|
DOORMAN_URL=https://doorman.chromart.cc
|
||||||
|
DISCORD_GUILD_ID=1299812960553795655
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"integ-test": "export $(grep -v '^#' .env.example | grep -v '=$' | xargs) && concurrently --success first --kill-others \"bun run start\" \"bun test\"",
|
||||||
"start-twilio": "twilio-run --live --port 8080",
|
"start-twilio": "twilio-run --load-local-env --live --port 8080",
|
||||||
"watch-build": "bun run --watch src/index.ts",
|
"watch-build": "bun run --watch src/index.ts",
|
||||||
"start": "concurrently \"bun run watch-build\" \"bun run start-twilio\"",
|
"start": "concurrently \"bun run watch-build\" \"bun run start-twilio\"",
|
||||||
"build": "bun run src/index.ts",
|
"build": "bun run src/index.ts",
|
||||||
@ -14,6 +14,7 @@
|
|||||||
"@aws-sdk/client-dynamodb": "^3.821.0",
|
"@aws-sdk/client-dynamodb": "^3.821.0",
|
||||||
"@twilio-labs/serverless-runtime-types": "^4.0.1",
|
"@twilio-labs/serverless-runtime-types": "^4.0.1",
|
||||||
"@twilio/runtime-handler": "1.3.0",
|
"@twilio/runtime-handler": "1.3.0",
|
||||||
|
"discord-oauth2": "^2.12.1",
|
||||||
"discord.js": "^14.19.3",
|
"discord.js": "^14.19.3",
|
||||||
"dynabridge": "^0.3.8",
|
"dynabridge": "^0.3.8",
|
||||||
"prom-client": "^15.1.3",
|
"prom-client": "^15.1.3",
|
||||||
|
|||||||
40
packages/doorman-api/tst/info.test.ts
Normal file
40
packages/doorman-api/tst/info.test.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { describe, test, expect, beforeAll } from "bun:test";
|
||||||
|
|
||||||
|
const baseUrl = "http://localhost:8080";
|
||||||
|
const doorName = "test";
|
||||||
|
const buzzerNumber = "6133163433";
|
||||||
|
|
||||||
|
const waitForService = async (url: string, timeout = 30000) => {
|
||||||
|
const start = Date.now();
|
||||||
|
|
||||||
|
while (Date.now() - start < timeout) {
|
||||||
|
try {
|
||||||
|
await fetch(url);
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Service at ${url} did not start within ${timeout}ms`);
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await waitForService(baseUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("info route works", () => {
|
||||||
|
test("info works from UI", async () => {
|
||||||
|
const resp = await fetch(baseUrl + `/api/door/info?door=${doorName}`).then(res => res.json()) as any;
|
||||||
|
|
||||||
|
expect(resp.id as string).toBe(doorName);
|
||||||
|
expect(resp.buzzer).toBe(buzzerNumber);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("info works from client", async () => {
|
||||||
|
const resp = await fetch(baseUrl + `/api/door/info?buzzer=${buzzerNumber}`).then(res => res.json()) as any;
|
||||||
|
|
||||||
|
// TODO: why is this different?
|
||||||
|
expect(resp.door as string).toBe(doorName);
|
||||||
|
expect(resp.buzzer).toBe(buzzerNumber);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user