Skip to content

Create session feature #34

Create session feature

Create session feature #34

Workflow file for this run

name: Backend CI/CD
on:
push:
branches: [main, develop]
paths:
- 'backend/**'
- '.github/workflows/backend-ci.yml'
pull_request:
branches: [main, develop]
paths:
- 'backend/**'
jobs:
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip setuptools wheel
pip install -e ".[dev]"
- name: Run Black formatter check
run: |
cd backend
black --check app/ tests/
- name: Run Flake8 (tests)
run: |
cd backend
flake8 tests/
- name: Run Flake8 (app syntax)
run: |
cd backend
flake8 app/ --select=E9,F63,F7,F82 --exclude=app/adapters/outbound/db/migrations
- name: Run Pylint
run: |
cd backend
pylint app/ --disable=R,C,W0612 --fail-under=8.0 || true
- name: Run MyPy type checks
run: |
cd backend
mypy app/ --ignore-missing-imports || true
test:
name: Unit & Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip setuptools wheel
pip install -e ".[dev]"
- name: Run pytest
run: |
cd backend
pytest tests/ -v --cov=app --cov-report=term-missing
env:
ENVIRONMENT: development
JWT_SECRET: test-jwt-secret-for-ci-only-32chars
JWT_KEYS: k1:test-jwt-secret-for-ci-only-32chars
JWT_ACTIVE_KID: k1
DOCUMENT_STORAGE_DIR: /tmp/mindvault-ci-storage
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKER_USERNAME }}/mindvault-backend
ghcr.io/${{ github.repository }}/backend
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: backend
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max