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
30 changes: 30 additions & 0 deletions .github/workflows/mainnet-api-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,33 @@ jobs:
flyctl deploy --remote-only --config ./fly.mainnet.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_API_MAIN }}

smoke-tests:
needs: [ deploy-mainnet ]
if: needs.deploy-mainnet.result == 'success'
uses: ./.github/workflows/smoke-tests.yml
secrets: inherit
with:
app_name: dither-mainnet-api-main

notify:
needs: [ smoke-tests ]
if: failure()
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@v1.0.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: |
🚨 **Smoke Tests Failed** 🚨

🔗 Repository: ${{ github.repository }}
📝 Commit: ${{ github.event.commits[0].message }}
👤 Author: ${{ github.actor }}
⛓️‍💥 App: dither-mainnet-api-main

⚠️ **Failed Tests:**
🔍 [View Logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})

Please investigate and fix ASAP! 🔧
32 changes: 32 additions & 0 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Smoke Tests

on:
workflow_call:
app_name:
tag:
required: true
type: string

jobs:
smoke-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install pnpm with npm
run: npm install -g pnpm

- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'pnpm'

- name: Install dependencies with pnpm
run: pnpm install

- name: Run tests
working-directory: packages/api-main
run: pnpm run test:smoke
env:
APP_NAME: ${{ inputs.app_name }}
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
jobs:
api-main-test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
Expand Down Expand Up @@ -44,15 +43,17 @@ jobs:
run: pnpm install

- name: Setup database schema
run: cd packages/api-main && pnpm db:push:force
working-directory: packages/api-main
run: pnpm db:push:force
env:
PG_URI: postgresql://default:password@localhost:5432/postgres

- name: Run tests
run: cd packages/api-main && pnpm test
working-directory: packages/api-main
run: pnpm test
env:
NODE_OPTIONS: --experimental-global-webcrypto
PG_URI: postgresql://default:password@localhost:5432/postgres
JWT: default_jwt_secret
JWT_STRICTNESS: lax
AUTH: whatever
AUTH: whatever
32 changes: 31 additions & 1 deletion .github/workflows/testnet-api-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
pnpm test

deploy-testnet:
needs: [detect-changes, test]
needs: [ detect-changes, test ]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.changed == 'true'
runs-on: ubuntu-latest
environment: testnet
Expand All @@ -92,3 +92,33 @@ jobs:
flyctl deploy --remote-only --config ./fly.testnet.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_API_MAIN }}

smoke-tests:
needs: [ deploy-testnet ]
if: needs.deploy-testnet.result == 'success'
uses: ./.github/workflows/smoke-tests.yml
secrets: inherit
with:
app_name: dither-testnet-api-main

notify:
needs: [ smoke-tests ]
if: failure()
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@v1.0.1
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: |
🚨 **Smoke Tests Failed** 🚨

🔗 Repository: ${{ github.repository }}
📝 Commit: ${{ github.event.commits[0].message }}
👤 Author: ${{ github.actor }}
⛓️‍💥 App: dither-testnet-api-main

⚠️ **Failed Tests:**
🔍 [View Logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})

Please investigate and fix ASAP! 🔧
2 changes: 1 addition & 1 deletion .github/workflows/testnet-reader-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# Add reader-main specific test steps here

deploy-testnet:
needs: [detect-changes, test]
needs: [ detect-changes, test ]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.detect-changes.outputs.changed == 'true'
runs-on: ubuntu-latest
environment: testnet
Expand Down
101 changes: 51 additions & 50 deletions packages/api-main/package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
{
"name": "api-feed",
"version": "1.0.0",
"description": "",
"author": "stuyk",
"main": "dist/index.js",
"type": "module",
"scripts": {
"start": "vite-node ./src/index.ts",
"build": "tsc",
"test": "vitest",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:push:force": "drizzle-kit push --force",
"push-and-start": "drizzle-kit push --force && pnpm start"
},
"dependencies": {
"@atomone/chronostate": "^2.3.0",
"@atomone/dither-api-types": "^1.8.0",
"@cosmjs/crypto": "^0.33.1",
"@cosmjs/encoding": "^0.33.1",
"@elysiajs/cors": "~1.2.0",
"@elysiajs/node": "~1.2.6",
"@keplr-wallet/cosmos": "^0.12.280",
"@sinclair/typebox": "^0.34.41",
"dotenv": "^16.6.1",
"drizzle-orm": "^0.43.1",
"drizzle-typebox": "^0.3.3",
"elysia": "~1.2.25",
"jsonwebtoken": "^9.0.2",
"pg": "^8.16.3",
"postgres": "^3.4.7",
"ws": "^8.18.3"
},
"devDependencies": {
"@cosmjs/amino": "^0.33.1",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.18.10",
"@types/pg": "^8.15.5",
"drizzle-kit": "^0.31.5",
"tsx": "^4.20.6",
"vite-node": "^3.2.4",
"vitest": "^3.2.4"
},
"prettier": {
"tabWidth": 4,
"singleQuote": true,
"semi": true,
"printWidth": 120
}
"name": "api-feed",
"version": "1.0.0",
"description": "",
"author": "stuyk",
"main": "dist/index.js",
"type": "module",
"scripts": {
"start": "vite-node ./src/index.ts",
"build": "tsc",
"test": "vitest --exclude tests/smoke",
"test:smoke": "vitest run tests/smoke",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:push:force": "drizzle-kit push --force",
"push-and-start": "drizzle-kit push --force && pnpm start"
},
"dependencies": {
"@atomone/chronostate": "^2.3.0",
"@atomone/dither-api-types": "^1.8.0",
"@cosmjs/crypto": "^0.33.1",
"@cosmjs/encoding": "^0.33.1",
"@elysiajs/cors": "~1.2.0",
"@elysiajs/node": "~1.2.6",
"@keplr-wallet/cosmos": "^0.12.280",
"@sinclair/typebox": "^0.34.41",
"dotenv": "^16.6.1",
"drizzle-orm": "^0.43.1",
"drizzle-typebox": "^0.3.3",
"elysia": "~1.2.25",
"jsonwebtoken": "^9.0.2",
"pg": "^8.16.3",
"postgres": "^3.4.7",
"ws": "^8.18.3"
},
"devDependencies": {
"@cosmjs/amino": "^0.33.1",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.18.10",
"@types/pg": "^8.15.5",
"drizzle-kit": "^0.31.5",
"tsx": "^4.20.6",
"vite-node": "^3.2.4",
"vitest": "^3.2.4"
},
"prettier": {
"tabWidth": 4,
"singleQuote": true,
"semi": true,
"printWidth": 120
}
}
11 changes: 11 additions & 0 deletions packages/api-main/tests/smoke/health.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, expect, it } from 'vitest';

describe('smoke', () => {
it('GET /v1/health returns 200', async () => {
const res = await fetch(`https://${process.env.APP_NAME}.fly.dev/v1/health`);
const json = await res.json().catch(() => null);

expect(res.ok).toBe(true);
expect(json).toBeTruthy();
});
});