Skip to content

Commit e7afd58

Browse files
committed
Move postgres job to not use docker
1 parent 21667f8 commit e7afd58

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

.github/workflows/database.yml

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Database
2+
# These workflows are intended to check that various actions related to the database
3+
# (such as building, exporting, and importing) work as expected.
24

35
on:
46
pull_request:
@@ -52,27 +54,50 @@ jobs:
5254
run: curl -Ss http://localhost:8000/api/v2/pokemon/1/ | grep -q 'bulbasaur'
5355
postgres:
5456
runs-on: ubuntu-latest
57+
services:
58+
postgres:
59+
image: postgres:16
60+
env:
61+
POSTGRES_USER: pokeapi
62+
POSTGRES_PASSWORD: pokeapi
63+
POSTGRES_DB: pokeapi
64+
options: >-
65+
--health-cmd pg_isready
66+
--health-interval 10s
67+
--health-timeout 5s
68+
--health-retries 5
69+
ports:
70+
- 5432:5432
5571
steps:
5672
- name: Checkout
5773
uses: actions/checkout@v5
5874
with:
5975
submodules: recursive
60-
- name: Build
61-
run: |
62-
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
63-
make docker-migrate
64-
make docker-build-db
76+
- name: Install uv
77+
uses: astral-sh/setup-uv@v7
78+
- name: Install dependencies
79+
run: make install
80+
- name: Run migrations
81+
run: uv run manage.py migrate --settings=config.local
82+
- name: Build database
83+
run: uv run manage.py shell --settings=config.local -c "from data.v2.build import build_all; build_all(); exit()"
6584
- name: Dump DB
66-
run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash -N 'hdb_*' pokeapi > pokeapi.dump"
67-
- name: Copy dump
68-
run: docker compose cp db:/tmp/pokeapi.dump ./
69-
- name: Down services
70-
run: docker compose -f docker-compose.yml -f docker-compose-dev.yml down -v
71-
- name: Start services
72-
run: docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
85+
run: pg_dump -h localhost -U pokeapi -Fc -N 'hdb_*' pokeapi > pokeapi.dump
86+
env:
87+
PGPASSWORD: pokeapi
88+
- name: Drop and recreate database
89+
run: |
90+
psql -h localhost -U pokeapi -d postgres -c "DROP DATABASE pokeapi;"
91+
psql -h localhost -U pokeapi -d postgres -c "CREATE DATABASE pokeapi;"
92+
env:
93+
PGPASSWORD: pokeapi
7394
- name: Import database
95+
run: pg_restore -h localhost -U pokeapi -d pokeapi pokeapi.dump
96+
env:
97+
PGPASSWORD: pokeapi
98+
- name: Start server
7499
run: |
75-
docker compose cp ./pokeapi.dump db:/tmp/
76-
docker compose exec -T -u postgres db sh -c "cd /tmp && pg_restore -h localhost -U ash -d pokeapi pokeapi.dump"
100+
nohup uv run manage.py runserver 0.0.0.0:8000 --settings=config.local &
101+
sleep 5
77102
- name: Test data
78-
run: curl -Ss http://localhost/api/v2/pokemon/1/ | grep -q 'bulbasaur'
103+
run: curl -Ss http://localhost:8000/api/v2/pokemon/1/ | grep -q 'bulbasaur'

.github/workflows/docker-k8s.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Container
2+
# These workflows are intended to check that the Docker and Kubernetes
3+
# configurations work as expected in a local development environment.
24

35
on:
46
pull_request:

0 commit comments

Comments
 (0)