Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

ci: type-check and test before deploying, and check every branch

spacesdrive6c018b8c74b5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..f24c505
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,40 @@
+name: CI
+
+# Checks every pull request and every branch push before it can reach main and deploy.
+on:
+ pull_request:
+ push:
+ branches-ignore: [main]
+ workflow_dispatch:
+
+jobs:
+ check:
+ runs-on: ubuntu-latest
+ name: Type check, lint, test, build
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 24
+ cache: 'npm'
+ cache-dependency-path: package-lock.json
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Type check
+ run: npm run typecheck
+
+ - name: Lint
+ run: npm run lint
+
+ - name: Test
+ run: npm test
+
+ - name: Build frontend
+ run: npm run build
+
+ - name: Bundle Worker
+ run: npx wrangler deploy --dry-run --outdir dist
+ working-directory: backend
diff --git a/.github/workflows/deploy-backend.yml b/.github/workflows/deploy-backend.yml
index 319aabc..b50ce8c 100644
--- a/.github/workflows/deploy-backend.yml
+++ b/.github/workflows/deploy-backend.yml
@@ -5,6 +5,8 @@ on:
branches: [main]
paths:
- 'backend/**'
+ - 'shared/**'
+ - 'tsconfig.base.json'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/deploy-backend.yml'
@@ -27,6 +29,13 @@ jobs:
- name: Install dependencies
run: npm ci
+ # deploy only code that type-checks; Wrangler and Vite strip types without checking them
+ - name: Type check
+ run: npm run typecheck --workspace backend
+
+ - name: Test
+ run: npm test --workspace backend
+
- name: Deploy Worker
uses: cloudflare/wrangler-action@v4
with:
diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml
index dee367d..1383dc7 100644
--- a/.github/workflows/deploy-frontend.yml
+++ b/.github/workflows/deploy-frontend.yml
@@ -5,6 +5,8 @@ on:
branches: [main]
paths:
- 'frontend/**'
+ - 'shared/**'
+ - 'tsconfig.base.json'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/deploy-frontend.yml'
@@ -27,6 +29,13 @@ jobs:
- name: Install dependencies
run: npm ci
+ # deploy only code that type-checks; Wrangler and Vite strip types without checking them
+ - name: Type check
+ run: npm run typecheck --workspace frontend
+
+ - name: Test
+ run: npm test --workspace frontend
+
- name: Build
run: npm run build --workspace frontend
env:
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 4ff43dd..0d44e47 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "target": "ES2024",
+ "target": "ES2022",
"lib": ["ES2024"],
"module": "ESNext",
"moduleResolution": "bundler",