ruff cleanup #691
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: Django CI | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: tally | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
POSTGRES_HOST: 127.0.0.1 | |
POSTGRES_PORT: 5432 | |
POSTGRES_USER: postgres | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Cache Python dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/uv | |
key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements/dev.pip') }} | |
restore-keys: | | |
${{ runner.os }}-uv- | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y memcached redis-server | |
sudo service memcached start | |
sudo service redis-server start | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
version: "latest" | |
- name: Create virtual environment | |
run: uv venv .venv | |
- name: Install Python dependencies | |
run: uv pip install -r requirements/dev.pip | |
- name: Run code quality checks | |
run: | | |
source .venv/bin/activate | |
ruff check . --output-format=github | |
ruff format --check . | |
- name: Run tests with coverage | |
run: | | |
source .venv/bin/activate | |
python -m pytest tally_ho --doctest-modules --junitxml=junit.xml --cov=tally_ho --cov-report=xml --cov-report=html | |
env: | |
POSTGRES_HOST: 127.0.0.1 | |
POSTGRES_PORT: 5432 | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: tally | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-results | |
path: junit.xml | |
- name: Upload coverage reports | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.xml | |
fail_ci_if_error: true |