freightdesk/.github/workflows/deploy.yml
FreightDesk 8ae3b403ab [OWL] Roadmap batch: CI/CD, observability, testing, UX polish
CI/CD:
- Add .github/workflows/deploy.yml (lint, test, build Docker, Coolify deploy)

Observability:
- Add Pino logger (services/logger.js) — structured JSON logging
- Add Prometheus metrics (services/metrics.js) — /metrics endpoint
- Replace console.error with pino in error handler
- Track http_request_duration, http_requests_total, active_loads, total_commission

Testing:
- Add Jest config to package.json
- Add integration tests (tests/integration/app.test.js) — health, metrics, auth, 404
- Add unit tests (tests/unit/utils.test.js) — formatINR, getStatusColor, calcCommission, WhatsApp parser
- Add devDeps: jest, supertest, eslint, prettier

UX:
- Debounced search (400ms) on Loads list page
- Cache-busting asset versioning (?v=timestamp) on CSS/JS includes
- ESLint + Prettier configs

Package updates:
- Add pino, pino-http, prom-client to dependencies
- Add jest, eslint, prettier, supertest, nodemon to devDependencies
2026-06-07 19:46:45 +00:00

96 lines
2.8 KiB
YAML

name: FreightDesk CI/CD
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
NODE_VERSION: '20'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# ── Lint & Test ──────────────────────────────────────────
test:
name: Lint & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: webapp/package-lock.json
- name: Install dependencies
working-directory: ./webapp
run: npm ci
- name: Run linter
working-directory: ./webapp
run: npm run lint --if-present
- name: Run tests
working-directory: ./webapp
run: npm test --if-present
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
- name: Smoke test
working-directory: ./webapp
run: |
timeout 15 npm start &
sleep 5
curl -sf http://localhost:3000/health || exit 1
echo "✅ Smoke test passed"
env:
NODE_ENV: test
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
SESSION_SECRET: test-secret
# ── Build & Push Docker Image ────────────────────────────
build:
name: Build Docker Image
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Build Docker image
working-directory: ./webapp
run: |
docker build -t freightdesk:${{ github.sha }} .
echo "✅ Docker image built"
- name: Tag image
run: |
docker tag freightdesk:${{ github.sha }} freightdesk:latest
echo "✅ Image tagged"
# ── Deploy to Coolify ────────────────────────────────────
deploy:
name: Deploy to Coolify
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Trigger Coolify deployment
run: |
if [ -n "${{ secrets.COOLIFY_WEBHOOK_URL }}" ]; then
curl -sf -X POST "${{ secrets.COOLIFY_WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-d '{"sha": "${{ github.sha }}", "branch": "master"}'
echo "✅ Coolify deployment triggered"
else
echo "⚠️ COOLIFY_WEBHOOK_URL not set — skipping deployment"
fi