-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
103 lines (101 loc) · 3.18 KB
/
database.yml
File metadata and controls
103 lines (101 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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'