Skip to content
Open
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
64 changes: 54 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2.1

jobs:
test:
static-checks:
docker:
- image: cimg/python:3.13.7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a matrix here and test LTS and the newest python version?

@FallenDeity FallenDeity Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a matrix in circle ci for make test and one in database.yml sqlite job for make build-db which are python version dependent moved the formatting and openapi spec generation to a separate step in circleci since they are not python version dependent

- image: cimg/python:3.14
steps:
- checkout
- run:
Expand All @@ -13,19 +13,45 @@ jobs:
git submodule update --remote
- run:
name: Install deps
command: make dev-install
command: make install
- run:
name: Linting
name: Format Check
command: make format-check
- run:
name: Generate OpenAPI schema
command: make openapi-generate

run-tests:
parameters:
python_version:
type: string
docker:
- image: cimg/python:<< parameters.python_version >>
steps:
- checkout
- run:
name: Pull Submodules
command: |
git submodule init
git submodule update --remote
- run:
name: Install deps
command: make install
- run:
name: Run tests
command: make test

test:
docker:
- image: cimg/base:stable
steps:
- run:
name: Generate OpenAPI schema
command: make openapi-generate
name: All tests passed
command: echo "All matrix tests completed successfully"

build:
docker:
- image: cimg/python:3.13.7
- image: cimg/python:3.14
steps:
- checkout
- run:
Expand All @@ -35,13 +61,14 @@ jobs:
git submodule update --remote
- run:
name: Install deps
command: make install
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
Expand All @@ -64,10 +91,18 @@ workflows:
version: 2
test-and-deploy:
jobs:
- test
- static-checks
- run-tests:
matrix:
parameters:
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
- test:
requires:
- run-tests
- build
- deploy:
requires:
- static-checks
- test
- build
filters:
Expand All @@ -77,11 +112,20 @@ workflows:
- staging
weekly:
jobs:
- test
- static-checks
- run-tests:
matrix:
parameters:
python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
- test:
requires:
- run-tests
- build
- deploy:
requires:
- static-checks
- test
- build
triggers:
- schedule:
cron: "0 0 * * 1"
Expand Down
88 changes: 70 additions & 18 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Lint
run: |
set -e
Expand All @@ -21,52 +21,104 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
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
make install-base
make openapi-generate
sqlite:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11.19"
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Start pokeapi
run: |
make install
make migrate
make install-base
make setup
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'
run: |
name=$(curl -fsSL http://localhost:8000/api/v2/pokemon/1/ | jq -r '.name')
echo "Returned name: $name"
test "$name" = "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
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: 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
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: |
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"
nohup make serve &
sleep 3
- name: Test data
run: curl -Ss http://localhost/api/v2/pokemon/1/ | grep -q 'bulbasaur'
run: |
name=$(curl -fsSL http://localhost:8000/api/v2/pokemon/1/ | jq -r '.name')
echo "Returned name: $name"
test "$name" = "bulbasaur"
6 changes: 4 additions & 2 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: recursive
- name: Docker meta
Expand Down Expand Up @@ -41,13 +41,15 @@ jobs:
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
file: ./Resources/docker/app/Dockerfile
push: true
platforms: linux/amd64,linux/arm64 #,linux/arm/v7,linux/arm/v6
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=docker
cache-to: type=gha,scope=docker,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
10 changes: 7 additions & 3 deletions .github/workflows/docker-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: recursive
- name: Docker meta
Expand All @@ -31,13 +31,15 @@ jobs:
platforms: linux/amd64,linux/arm64 #,linux/arm/v7,linux/arm/v6
tags: pokeapi/pokeapi:local
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=docker
cache-to: type=gha,scope=docker,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
k8s:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: recursive
- name: Docker meta
Expand All @@ -61,6 +63,8 @@ jobs:
platforms: local
tags: pokeapi/pokeapi:local
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=docker
cache-to: type=gha,scope=docker,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Lint k8s
Expand Down Expand Up @@ -104,7 +108,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Build dev environment
run: |
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
submodules: recursive
- name: Start pokeapi (docker)
Expand All @@ -26,8 +26,8 @@ jobs:
ls -larth
- name: Start pokeapi
run: |
make install
make migrate
make install-base
make setup
make build-db
nohup make serve &
sleep 3
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file? I'd like to support multiple Python versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well there are a few benefits to having the interpreter version pinned, the pipeline uv sets up automatically + make install/setup (uv sync) auto installs the suitable python version

I think having a pinned python version for the project is fine since uv handles that anyways and to run it with diff versions locally the developer can either use the --python flag with uv or modify the version pin temporarily https://docs.astral.sh/uv/concepts/python-versions/#requesting-a-version

instead in the pipeline we can have the matrix which runs the project against diff version and the dev can later modify it locally we can make a note in the readme

Loading
Loading