Add UV for project management, Ruff for formatting. #252
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 | |
| 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 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build | |
| run: | | |
| docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d | |
| docker compose --verbose exec -T app uv run manage.py migrate --settings=config.docker-compose | |
| make docker-build-db | |
| - name: Dump DB | |
| run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash -N 'hdb_*' pokeapi > pokeapi.dump" | |
| - name: Copy dump | |
| run: docker compose cp db:/tmp/pokeapi.dump ./ | |
| - name: Down services | |
| run: docker compose -f docker-compose.yml -f docker-compose-dev.yml down -v | |
| - name: Start services | |
| run: docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d | |
| - name: Import database | |
| run: | | |
| docker compose cp ./pokeapi.dump db:/tmp/ | |
| docker compose exec -T -u postgres db sh -c "cd /tmp && pg_restore -h localhost -U ash -d pokeapi pokeapi.dump" | |
| - name: Test data | |
| run: curl -Ss http://localhost/api/v2/pokemon/1/ | grep -q 'bulbasaur' |