-
-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1202 from PokeAPI/db-cicd
test db dump and restore
- Loading branch information
Showing
5 changed files
with
72 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Database | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
sqlite: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- 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@v4 | ||
with: | ||
submodules: recursive | ||
- name: Build | ||
run: | | ||
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d | ||
make docker-migrate | ||
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' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Push Docker image | ||
name: Publish | ||
|
||
on: | ||
push: | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Test Docker, Compose and k8s | ||
name: Container | ||
|
||
on: | ||
pull_request: | ||
|
This file contains 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
This file contains 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