Skip to content

Fix/docs

Fix/docs #111

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
PYTHON_VERSION: "3.9"
NODE_VERSION: "18"
permissions:
contents: read
security-events: write
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies (Black, MyPy, Ruff)
working-directory: src/backend
run: |
python -m pip install --upgrade pip
pip install black mypy ruff
pip install -r requirements-dev.txt
- name: Run Ruff Linting and Import Sorting check
working-directory: src/backend
run: ruff check .
- name: Run Black formatting check
working-directory: src/backend
run: black --check .
- name: Run MyPy type checking
working-directory: src/backend
run: mypy .
test:
runs-on: ubuntu-latest
needs: lint-and-format
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_PASSWORD: test_password
POSTGRES_USER: test_user
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mongo:
image: mongo:5.0
options: >-
--health-cmd "mongosh --eval 'db.runCommand({ping: 1})'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
working-directory: src/backend
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run unit tests
working-directory: src/backend
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_db
MONGO_HOST: localhost
MONGO_PORT: 27017
MONGO_DB: test_db
run: |
pytest tests/ -v --cov=. --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: src/backend/coverage.xml
flags: unittests
name: codecov-umbrella
# build-and-push:
# runs-on: ubuntu-latest
# needs: [test, security-scan]
# if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Log in to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
#
# - name: Extract metadata
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: olp-2025/backend
# tags: |
# type=ref,event=branch
# type=ref,event=pr
# type=sha,prefix={{branch}}-
#
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# # FIX: ./backend -> src/backend (Update context for new structure)
# context: src/backend
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
#
# deploy-staging:
# runs-on: ubuntu-latest
# needs: build-and-push
# if: github.ref == 'refs/heads/develop'
# environment: staging
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Deploy to staging
# run: |
# echo "Deploying to staging environment"
# # Add your staging deployment commands here
# # For example, using docker-compose or kubectl
#
# deploy-production:
# runs-on: ubuntu-latest
# needs: build-and-push
# if: github.ref == 'refs/heads/main'
# environment: production
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Deploy to production
# run: |
# echo "Deploying to production environment"
# # Add your production deployment commands here
# # For example, using docker-compose or kubectl