Skip to content

Merge pull request #2 from P2GX/enhancement/ruff-updates #10

Merge pull request #2 from P2GX/enhancement/ruff-updates

Merge pull request #2 from P2GX/enhancement/ruff-updates #10

Workflow file for this run

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
lint-and-format:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Create virtual environment
run: uv venv
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Check formatting with ruff
run: |
source .venv/bin/activate
ruff format --check src/ tests/
- name: Lint with ruff
run: |
source .venv/bin/activate
ruff check src/ tests/
- name: Type check with mypy
run: |
source .venv/bin/activate
mypy src/
continue-on-error: true
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Create virtual environment
run: uv venv
- name: Install dependencies
run: |
uv pip install -e ".[dev]"
- name: Run tests with coverage
run: |
source .venv/bin/activate
pytest --cov --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.12'
with:
file: ./coverage.xml
fail_ci_if_error: false
docker:
name: Build Docker Image
runs-on: ubuntu-latest
services:
registry:
image: registry:3
ports:
- 5000:5000
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: true
context: .
tags: localhost:5000/beacon-api:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker image
run: |
docker run -d -p 8000:8000 --name beacon-test localhost:5000/beacon-api:latest
echo "Waiting for container to be ready..."
sleep 10
echo "Testing health endpoint..."
curl --fail --retry 3 --retry-delay 2 --retry-all-errors http://localhost:8000/api/monitor/health || {
echo "Health check failed. Container logs:"
docker logs beacon-test
exit 1
}
docker stop beacon-test