Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
π§ wip (#248)
Thibault Le Ouay5e0e75079f3f
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 800a0e7cf..b14484104 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -47,6 +47,7 @@ jobs:env:TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}TURBO_TEAM: ${{ secrets.TURBO_TEAM }}+steps:- name: β¬οΈ Checkout repouses: actions/checkout@v3diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlnew file mode 100644index 000000000..78489ff28--- /dev/null+++ b/.github/workflows/test.yml@@ -0,0 +1,62 @@+# https://github.com/kentcdodds/kentcdodds.com/blob/main/.github/workflows/deployment.yml+name: Tests+on:+ push:+ branches:+ - "*"+ pull_request: {}++concurrency:+ group: ${{ github.job }}-${{ github.ref }}+ cancel-in-progress: true++jobs:+ tests:+ name: π§ͺ Tests+ runs-on: ubuntu-latest+ timeout-minutes: 15+ services:+ sqld:+ image: ghcr.io/libsql/sqld:latest+ ports:+ - 8080:8080++ env:+ TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}+ TURBO_TEAM: ${{ secrets.TURBO_TEAM }}+ DATABASE_URL: http://127.0.0.1:8080+ DATABASE_AUTH_TOKEN: "hello"+ steps:+ - name: β¬οΈ Checkout repo+ uses: actions/checkout@v3++ - name: Set up pnpm+ uses: pnpm/action-setup@v2+ with:+ version: 8++ - name: β Setup node+ uses: actions/setup-node@v3+ with:+ node-version: 18+ cache: "pnpm"++ - name: π₯ Install bun+ uses: oven-sh/setup-bun@v1+ with:+ bun-version: latest++ - name: π₯ Download deps+ run: pnpm install++ - name: ποΈ Run migrations+ run: pnpm migrate+ working-directory: ./packages/db++ - name: π½ Seed database+ run: pnpm seed+ working-directory: ./packages/db++ - name: π§ͺ Tests+ run: pnpm test+ working-directory: ./packages/apidiff --git a/.gitignore b/.gitignoreindex 387be28e8..f67af55e3 100644--- a/.gitignore+++ b/.gitignore@@ -51,3 +51,6 @@ openstatus.db-shmpackages/tinybird/.tinybapps/web/tsconfig.tsbuildinfo+openstatus-test.db+openstatus-test.db-shm+openstatus-test.db-waldiff --git a/packages/api/src/router/page.test.ts b/packages/api/src/router/page.test.tsindex 000dcb18e..8f499f9a8 100644--- a/packages/api/src/router/page.test.ts+++ b/packages/api/src/router/page.test.ts@@ -27,7 +27,7 @@ test("Get Test Page", async () => {{active: true,createdAt: expect.any(Date),- description: "description",+ description: "OpenStatus website",id: 1,jobType: "other",name: "OpenStatus",@@ -35,10 +35,10 @@ test("Get Test Page", async () => {status: "inactive",updatedAt: expect.any(Date),url: "https://www.openstatus.dev",- workspaceId: null,+ workspaceId: 1,},],- published: false,+ published: true,slug: "status",title: "Test Page",updatedAt: expect.any(Date),diff --git a/packages/api/src/router/workspace.test.ts b/packages/api/src/router/workspace.test.tsindex 870525f6f..3ffb6d9c2 100644--- a/packages/api/src/router/workspace.test.ts+++ b/packages/api/src/router/workspace.test.ts@@ -32,7 +32,7 @@ test("Get Test Workspace", async () => {});test("No workspace", async () => {- const ctx = await createTRPCContext({+ const ctx = createTRPCContext({req: {},});@@ -48,7 +48,7 @@ test("No workspace", async () => {});test("All workspaces", async () => {- const ctx = await createTRPCContext({+ const ctx = createTRPCContext({req: {},});@@ -60,7 +60,7 @@ test("All workspaces", async () => {const caller = edgeRouter.createCaller(ctx);const result = await caller.workspace.getUserWithWorkspace();- expect(result).toMatchInlineSnapshot([+ expect(result).toMatchObject([{createdAt: expect.any(Date),email: "[email protected]",diff --git a/packages/db/package.json b/packages/db/package.jsonindex f86725f46..1a8a4d68c 100644--- a/packages/db/package.json+++ b/packages/db/package.json@@ -7,7 +7,8 @@"generate": "drizzle-kit generate:sqlite","push": "drizzle-kit push:sqlite","migrate": "ts-node --esm src/migrate.mts",- "studio": "drizzle-kit studio"+ "studio": "drizzle-kit studio",+ "seed": "bun src/seed.mts"},"dependencies": {"@libsql/client": "0.3.1",diff --git a/packages/db/src/seed.mts b/packages/db/src/seed.mtsnew file mode 100644index 000000000..030b5af38--- /dev/null+++ b/packages/db/src/seed.mts@@ -0,0 +1,100 @@+import "dotenv/config";++import { createClient } from "@libsql/client";+import { drizzle } from "drizzle-orm/libsql";++import { env } from "../env.mjs";+import {+ monitor,+ monitorsToPages,+ page,+ user,+ usersToWorkspaces,+ workspace,+} from "./schema";++async function main() {+ const db = drizzle(+ createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN }),+ );+ console.log("Seeding database ");+ await db+ .insert(workspace)+ .values({+ id: 1,+ slug: "test",+ stripeId: "stripeId",+ name: "test",+ subscriptionId: "subscriptionId",+ plan: "free",+ endsAt: null,+ paidUntil: null,+ })+ .run();+ await db+ .insert(monitor)+ .values([+ {+ id: 1,+ workspaceId: 1,+ active: true,+ url: "https://www.openstatus.dev",+ name: "OpenStatus",+ description: "OpenStatus website",+ method: "POST",+ periodicity: "1m",+ regions: "fra1",+ headers: '[{"key":"key", "value":"value"}]',+ body: '{"hello":"world"}',+ },+ {+ id: 2,+ active: false,+ workspaceId: 1,+ periodicity: "10m",+ url: "https://www.google.com",+ method: "GET",+ regions: "fra1",+ },+ ])+ .run();++ await db+ .insert(page)+ .values({+ id: 1,+ workspaceId: 1,+ title: "Test Page",+ description: "hello",+ icon: "https://www.openstatus.dev/favicon.ico",+ slug: "status",+ customDomain: "",+ published: true,+ })+ .run();++ await db+ .insert(user)+ .values({+ id: 1,+ tenantId: "1",+ firstName: "test",+ lastName: "user",+ email: "[email protected]",+ photoUrl: "",+ })+ .run();+ await db+ .insert(usersToWorkspaces)+ .values({ workspaceId: 1, userId: 1 })+ .run();++ await db.insert(monitorsToPages).values({ monitorId: 1, pageId: 1 }).run();+ process.exit(0);+}++main().catch((e) => {+ console.error("Seed failed");+ console.error(e);+ process.exit(1);+});