Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 91 additions & 91 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
version: 2.1

jobs:
test:
docker:
- image: cimg/python:3.13.7
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- run:
name: Install deps
command: make dev-install
- run:
name: Linting
command: make format-check
- run:
name: Run tests
command: make test
- run:
name: Generate OpenAPI schema
command: make openapi-generate
build:
docker:
- image: cimg/python:3.13.7
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- run:
name: Install deps
command: make install
- run:
name: Run migrations
command: make setup
- run:
name: Build database
command: make build-db
deploy:
machine:
image: ubuntu-2204:2024.11.1
resource_class: large
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- add_ssh_keys:
fingerprints:
- "d3:5f:9d:68:ea:12:9a:42:d3:d3:e1:db:b0:6a:fc:d2"
- run:
name: Generate new data, push to PokeAPI/api-data's staging branch, if master open a Pull Request towards PokeAPI/api-data's master branch
command: bash -x Resources/scripts/updater.sh

workflows:
version: 2
test-and-deploy:
jobs:
- test
- build
- deploy:
requires:
- test
- build
filters:
branches:
only:
- master
- staging
weekly:
jobs:
- test
- build
- deploy:
requires:
- test
triggers:
- schedule:
cron: "0 0 * * 1"
filters:
branches:
only:
- staging
version: 2.1
jobs:
test:
docker:
- image: cimg/python:3.14
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- run:
name: Install deps
command: make install
- run:
name: Linting
command: make format-check
- run:
name: Run tests
command: make test
- run:
name: Generate OpenAPI schema
command: make openapi-generate
build:
docker:
- image: cimg/python:3.14
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- run:
name: Install deps
command: make install-base
- run:
name: Run migrations
command: make setup
- run:
name: Build database
command: make build-db
deploy:
machine:
image: ubuntu-2204:2024.11.1
resource_class: large
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- add_ssh_keys:
fingerprints:
- "d3:5f:9d:68:ea:12:9a:42:d3:d3:e1:db:b0:6a:fc:d2"
- run:
name: Generate new data, push to PokeAPI/api-data's staging branch, if master open a Pull Request towards PokeAPI/api-data's master branch
command: bash -x Resources/scripts/updater.sh
workflows:
version: 2
test-and-deploy:
jobs:
- test
- build
- deploy:
requires:
- test
- build
filters:
branches:
only:
- master
- staging
weekly:
jobs:
- test
- build
- deploy:
requires:
- test
triggers:
- schedule:
cron: "0 0 * * 1"
filters:
branches:
only:
- staging
185 changes: 113 additions & 72 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,113 @@
name: Database

on:
pull_request:

jobs:
csv:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- 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: 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: 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: 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'
name: Database

on:
pull_request:

jobs:
csv:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- 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@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11.19"
enable-cache: true
- name: Generate OpenAPI schema
run: |
make install-base
make openapi-generate
sqlite:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11.19"
enable-cache: true
- name: Start pokeapi
run: |
make install-base
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@v6
with:
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11.19"
enable-cache: true
- name: Install dependencies
run: make install-base
- name: Run migrations & build database
run: |
make setup
make build-db
- 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: 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 pokeapi
run: |
nohup make serve &
sleep 3
- name: Test data
run: curl -Ss http://localhost/api/v2/pokemon/1/ | grep -q 'bulbasaur'
Loading
Loading