Add UV for project management, Ruff for formatting. #409
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: Database | |
| # These workflows are intended to check that various actions related to the database | |
| # (such as building, exporting, and importing) work as expected. | |
| on: | |
| pull_request: | |
| jobs: | |
| csv: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Lint | |
| run: | | |
| set -e | |
| curl -sSL https://github.com/Clever/csvlint/releases/download/v0.3.0/csvlint-v0.3.0-linux-amd64.tar.gz | tar xz --strip-components=1 | |
| for filename in data/v2/csv/*.csv; do | |
| echo "$filename" | |
| ./csvlint -lazyquotes "$filename" # TODO: remove lazyquotes when https://github.com/Clever/csvlint/issues/45 will be addressed | |
| done | |
| openapi: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Generate OpenAPI schema | |
| run: | | |
| make install | |
| make openapi-generate | |
| sqlite: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Start pokeapi | |
| run: | | |
| make install | |
| make migrate | |
| make build-db | |
| nohup make serve & | |
| sleep 3 | |
| - name: Dump DB | |
| run: stat db.sqlite3 | |
| - name: Test data | |
| run: curl -Ss http://localhost:8000/api/v2/pokemon/1/ | grep -q 'bulbasaur' | |
| postgres: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: pokeapi | |
| POSTGRES_PASSWORD: pokeapi | |
| POSTGRES_DB: pokeapi | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install dependencies | |
| run: make install | |
| - name: Run migrations | |
| run: uv run manage.py migrate --settings=config.local | |
| - name: Build database | |
| run: uv run manage.py shell --settings=config.local -c "from data.v2.build import build_all; build_all(); exit()" | |
| - name: Dump DB | |
| run: pg_dump -h localhost -U pokeapi -Fc -N 'hdb_*' pokeapi > pokeapi.dump | |
| env: | |
| PGPASSWORD: pokeapi | |
| - name: Drop and recreate database | |
| run: | | |
| psql -h localhost -U pokeapi -d postgres -c "DROP DATABASE pokeapi;" | |
| psql -h localhost -U pokeapi -d postgres -c "CREATE DATABASE pokeapi;" | |
| env: | |
| PGPASSWORD: pokeapi | |
| - name: Import database | |
| run: pg_restore -h localhost -U pokeapi -d pokeapi pokeapi.dump | |
| env: | |
| PGPASSWORD: pokeapi | |
| - name: Start server | |
| run: | | |
| nohup uv run manage.py runserver 0.0.0.0:8000 --settings=config.local & | |
| sleep 5 | |
| - name: Test data | |
| run: curl -Ss http://localhost:8000/api/v2/pokemon/1/ | grep -q 'bulbasaur' |