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

on:
push:
branches: [main, develop]
paths:
- "backend/Dockerfile"
- "backend/docker-compose.yml"
- "backend/requirements.txt"
- ".github/workflows/docker.yml"
pull_request:
branches: [main]

jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest

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

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

- name: Install docker-compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

- name: Build backend image
run: |
cd backend
docker build --tag codeguard-backend:${{ github.sha }} .

- name: Test Docker image
run: |
docker run --rm codeguard-backend:${{ github.sha }} python --version

- name: Test Docker Compose (validation only)
run: |
cd backend
docker-compose config

- name: Summary
if: success()
run: |
echo " Docker image built successfully!"
echo " Image: codeguard-backend:${{ github.sha }}"
56 changes: 56 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Lint & Format Check

on:
push:
branches: [main, develop, "feature/**"]
paths:
- "backend/**/*.py"
- ".github/workflows/lint.yml"
pull_request:
branches: [main, develop]
paths:
- "backend/**/*.py"

jobs:
lint:
name: Code Quality Check
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install linting dependencies
run: |
python -m pip install --upgrade pip
pip install black>=23.0.0 flake8>=7.0.0 isort>=5.13.0

- name: Check code formatting with Black
run: |
cd backend
black src/ --line-length=100 --check

- name: Check import sorting with isort
run: |
cd backend
isort src/ --profile=black --line-length=100 --check-only

- name: Lint with Flake8
run: |
cd backend
flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src/ --count --max-complexity=10 --max-line-length=100 --statistics

- name: Summary
if: success()
run: |
echo "= All code quality checks passed!"
echo "- Black formatting: ✓"
echo "- Import sorting (isort): ✓"
echo "- Linting (flake8): ✓"
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Tests & Coverage

on:
push:
branches: [main, develop, "feature/**"]
paths:
- "backend/**/*.py"
- "backend/tests/**"
- ".github/workflows/test.yml"
pull_request:
branches: [main, develop]
paths:
- "backend/**/*.py"
- "backend/tests/**"

jobs:
test:
name: Run Tests & Coverage
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest>=8.0.0 pytest-asyncio>=0.23.0 pytest-cov>=4.1.0

- name: Run tests with coverage
run: |
cd backend
pytest tests/ --cov=src --cov-report=html --cov-report=term-missing --cov-report=xml --cov-fail-under=75 -v
continue-on-error: false

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: backend/htmlcov/
retention-days: 30

- name: Upload coverage to Codecov (optional)
if: always()
uses: codecov/codecov-action@v4
with:
file: backend/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Summary
if: success()
run: |
echo "All tests passed with >75% coverage!"
echo "Coverage report uploaded as artifact"
Loading