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
54 changes: 54 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deployment

on:
push:
branches:
- main
workflow_dispatch:

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

permissions:
contents: read
packages: write

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: ./backend
file: ./backend/Dockerfile
push: false
tags: |
ai-personalization:${{ github.sha }}
ai-personalization:latest
outputs: type=docker,dest=/tmp/image.tar

- name: Load Docker image
run: |
docker load --input /tmp/image.tar

- name: Docker image built successfully
run: |
echo "Docker image built with tag: ai-personalization:${{ github.sha }}"
echo "Latest tag: ai-personalization:latest"

- name: Push to registry (placeholder)
run: |
echo "Pushing to container registry..."
echo "In production, configure Docker registry credentials and push image"
echo "Example: docker push registry.example.com/ai-personalization:${{ github.sha }}"

- name: Deploy to production (placeholder)
run: |
echo "Deploying to production environment..."
echo "In production, configure deployment credentials and deploy"
echo "Example: kubectl set image deployment/ai-personalization app=registry.example.com/ai-personalization:${{ github.sha }}"
66 changes: 66 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Performance Testing

on:
push:
branches:
- main
schedule:
- cron: '0 3 * * *' # Daily at 3 AM UTC

jobs:
performance-test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

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

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies and locust
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install locust

- name: Run locust load test
working-directory: ./backend
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
FLASK_ENV: testing
run: |
locust -f tests/locustfile.py \
--headless \
-u 100 \
-r 10 \
--run-time 60s \
--csv=results \
--html=report.html || echo "Load test completed"

- name: Upload performance report
if: always()
uses: actions/upload-artifact@v3
with:
name: performance-report
path: |
backend/results*.csv
backend/report.html
44 changes: 44 additions & 0 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Security Scanning

on:
push:
branches:
- main
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC

jobs:
security-scan:
runs-on: ubuntu-latest

permissions:
contents: read
security-events: write

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

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'

- name: Upload Trivy results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Run safety check on requirements.txt
working-directory: ./backend
run: |
pip install safety
safety check -r requirements.txt --json || true
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Automated Testing

on:
push:
branches:
- main
- develop
- 'feature/**'
pull_request:
branches:
- main
- develop

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

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

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install black flake8 pytest pytest-cov

- name: Run linting with black
working-directory: ./backend
run: black --check .

- name: Run linting with flake8
working-directory: ./backend
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

- name: Run pytest with coverage
working-directory: ./backend
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
FLASK_ENV: testing
run: pytest --cov=app --cov-report=xml --cov-report=term

- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
files: ./backend/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.worktrees/
Binary file not shown.
Binary file not shown.
Loading
Loading