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
84 changes: 84 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Backend CI

on:
push:
branches:
- main
paths:
- 'backend/**'
- 'docker-compose.yml'
- '.github/workflows/backend-ci.yml'
pull_request:
branches:
- main
paths:
- 'backend/**'
- 'docker-compose.yml'
- '.github/workflows/backend-ci.yml'

jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: diacify_db
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root -prootpassword"
--health-interval=10s
--health-timeout=5s
--health-retries=10
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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

- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'backend/package-lock.json'

- name: Install backend dependencies
run: npm ci
working-directory: backend

- name: Run database migrations
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: rootpassword
MYSQL_DATABASE: diacify_db
run: |
for file in backend/database/migrations/00[1-5]_*.sql; do
echo "Running migration: $file"
mysql -h 127.0.0.1 -P 3306 -u root -prootpassword diacify_db < "$file"
done

- name: Run tests
env:
NODE_ENV: test
TEST_DB_HOST: 127.0.0.1
TEST_DB_PORT: 3306
TEST_DB_USER: root
TEST_DB_PASSWORD: rootpassword
TEST_DB_NAME: diacify_db
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
ML_INTERNAL_SECRET: ${{ secrets.ML_INTERNAL_SECRET }}
ML_SERVICE_URL: http://localhost:8001
run: npm test
working-directory: backend

deploy:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Trigger backend redeploy
run: curl --fail -X POST "${{ secrets.RENDER_BACKEND_HOOK }}"
42 changes: 42 additions & 0 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Frontend CI

on:
push:
branches:
- main
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yml'
pull_request:
branches:
- main
paths:
- 'frontend/**'
- '.github/workflows/frontend-ci.yml'

jobs:
build:
runs-on: ubuntu-latest

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

Comment thread
deshanekanayaka marked this conversation as resolved.
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
Comment thread
deshanekanayaka marked this conversation as resolved.

- name: Install frontend dependencies
run: npm ci
working-directory: frontend

- name: Run linter
run: npm run lint
working-directory: frontend

- name: Build frontend
run: npm run build
working-directory: frontend
84 changes: 84 additions & 0 deletions .github/workflows/ml-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: ML CI
Comment thread
deshanekanayaka marked this conversation as resolved.

on:
push:
branches:
- main
paths:
- 'machine-learning/**'
- 'docker-compose.yml'
- '.github/workflows/ml-ci.yml'
pull_request:
branches:
- main
paths:
- 'machine-learning/**'
- 'docker-compose.yml'
- '.github/workflows/ml-ci.yml'

jobs:
test:
runs-on: ubuntu-latest

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

- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'machine-learning/requirements.txt'

- name: Install dependencies
run: pip install -r requirements.txt
working-directory: machine-learning

- name: Train model for tests
working-directory: machine-learning
run: python train_model.py

- name: Run pytest
env:
ML_INTERNAL_SECRET: ${{ secrets.ML_INTERNAL_SECRET || 'test_secret' }}
run: pytest tests/ -v
Comment thread
deshanekanayaka marked this conversation as resolved.
working-directory: machine-learning

- name: Build Docker image for validation
run: docker build -t diacify-ml:ci .
working-directory: machine-learning

deploy:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write

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

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: machine-learning
push: true
tags: ghcr.io/${{ github.repository_owner }}/diacify-ml:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Trigger ML service redeploy
run: curl --fail -X POST "${{ secrets.ML_DEPLOY_HOOK }}"
Loading
Loading