Enhancement/ruff updates #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| steps: | |
| - 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 | |
| tags: 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 beacon-api:latest | |
| sleep 5 | |
| curl --fail http://localhost:8000/health || exit 1 | |
| docker stop beacon-test |