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
16 changes: 16 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Database Configuration
# TimescaleDB connection string
# Default: postgresql://postgres:password@localhost:5432/watchtower
DATABASE_URL=postgresql://postgres:password@localhost:5432/watchtower

# Redis Configuration
# Default: redis://localhost:6379
REDIS_URL=redis://localhost:6379

# Soroban RPC Endpoints
SOROBAN_RPC_MAINNET=https://mainnet.stellar.org:443
SOROBAN_RPC_TESTNET=https://soroban-testnet.stellar.org:443

# Security
# Random string for JWT signing
JWT_SECRET=your_super_secret_jwt_token_here
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Lint
run: npx turbo run lint
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

- name: Type-check
run: npx turbo run type-check
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

- name: Unit Tests
run: npx turbo run test -- --watch=false
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

integration-tests:
runs-on: ubuntu-latest
needs: build-and-test

services:
timescaledb:
image: timescale/timescaledb:latest
env:
POSTGRES_DB: watchtower
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run Integration Tests
run: npx turbo run test:integration
env:
DATABASE_URL: postgresql://postgres:password@localhost:5432/watchtower
REDIS_URL: redis://localhost:6379
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
6 changes: 5 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"scripts": {
"build": "tsc",
"dev": "tsx watch src/index.ts",
"start": "node dist/index.js"
"start": "node dist/index.js",
"lint": "eslint src --ext .ts",
"test": "vitest run unit",
"test:integration": "vitest run integration",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@fastify/cors": "^9.0.0",
Expand Down
6 changes: 5 additions & 1 deletion apps/workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"scripts": {
"build": "tsc",
"dev": "tsx src/index.ts",
"start": "node dist/index.js"
"start": "node dist/index.js",
"lint": "eslint src --ext .ts",
"test": "vitest run unit",
"test:integration": "vitest run integration",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@stellar/stellar-sdk": "^11.0.0",
Expand Down
70 changes: 70 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: '3.8'

services:
db:
image: timescale/timescaledb:latest
container_name: watchtower-db
restart: always
environment:
POSTGRES_DB: watchtower
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
TS_TUNE_MEMORY: "512MB"
TS_TUNE_NUM_CPUS: "2"
ports:
- "5432:5432"
volumes:
- ./docker/db/init.sql:/docker-entrypoint-initdb.d/init.sql
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d watchtower"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s

redis:
image: redis:7-alpine
container_name: watchtower-redis
restart: always
ports:
- "6379:6379"
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s

# Optional services - Uncomment when Dockerfiles are ready
# api:
# build:
# context: .
# dockerfile: apps/api/Dockerfile
# environment:
# - DATABASE_URL=postgresql://postgres:password@db:5432/watchtower
# - REDIS_URL=redis://redis:6379
# depends_on:
# db:
# condition: service_healthy
# redis:
# condition: service_healthy

# worker:
# build:
# context: .
# dockerfile: apps/workers/Dockerfile
# environment:
# - DATABASE_URL=postgresql://postgres:password@db:5432/watchtower
# - REDIS_URL=redis://redis:6379
# depends_on:
# db:
# condition: service_healthy
# redis:
# condition: service_healthy

volumes:
pgdata:
redisdata:
11 changes: 11 additions & 0 deletions docker/db/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create the database if it doesn't exist (though usually the POSTGRES_DB env var handles this)
-- CREATE DATABASE watchtower;

-- Connect to the database
-- \c watchtower;

-- Enable TimescaleDB extension
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

-- Verify extension is enabled
SELECT * FROM timescaledb_information.hypertables;
Loading
Loading