ci.yml•4.42 kB
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
PYTHON_VERSION: "3.12"
jobs:
# Linting and formatting checks
lint:
name: Lint and Format 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: ${{ env.PYTHON_VERSION }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
uv sync --frozen
- name: Run ruff format check
run: |
uv run ruff format --check .
- name: Run ruff lint
run: |
uv run ruff check .
# Type checking
typecheck:
name: Type Check (mypy)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
uv sync --frozen
- name: Run mypy
run: |
uv run mypy src tests
# Unit and integration tests
test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
matrix:
test-group: [unit, integration]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
uv sync --frozen
- name: Run tests
env:
HOSTAWAY_CLIENT_ID: test_client_id
HOSTAWAY_CLIENT_SECRET: test_client_secret
HOSTAWAY_API_BASE_URL: https://api.hostaway.com/v1
TEST_GROUP: ${{ matrix.test-group }}
run: |
uv run pytest tests/${TEST_GROUP} -v --cov=src --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
# Coverage check
coverage:
name: Coverage Check
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
uv sync --frozen
- name: Run full test suite with coverage
env:
HOSTAWAY_CLIENT_ID: test_client_id
HOSTAWAY_CLIENT_SECRET: test_client_secret
HOSTAWAY_API_BASE_URL: https://api.hostaway.com/v1
run: |
uv run pytest --cov=src --cov-report=term --cov-fail-under=80
# Security audit
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
uv sync --frozen
- name: Run bandit security scan
run: |
uv pip install bandit
uv run bandit -r src/
# Docker build
docker:
name: Docker Build
runs-on: ubuntu-latest
needs: [lint, typecheck, test, coverage]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
# All checks passed
all-checks:
name: All Checks Passed
runs-on: ubuntu-latest
needs: [lint, typecheck, test, coverage, security]
steps:
- name: Success
run: echo "All CI checks passed"