diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 2758c2fda..d124c7773 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,12 +1 @@ -# These are supported funding model platforms - -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username open_collective: pokeapi -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index c7c2e78c4..c8e82d481 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -2,22 +2,17 @@ name: Code Quality on: pull_request: - paths: + paths: &paths - "**.py" - "**.toml" - - "Makefile" - - "uv.lock" - - ".github/workflows/code-quality.yml" + - "**.lock" + - Makefile + - .github/workflows/code-quality.yml push: branches-ignore: - master - staging - paths: - - "**.py" - - "**.toml" - - "Makefile" - - "uv.lock" - - ".github/workflows/code-quality.yml" + paths: *paths jobs: ruff: diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml index 090a341b4..d894e115f 100644 --- a/.github/workflows/database.yml +++ b/.github/workflows/database.yml @@ -2,10 +2,20 @@ name: Database on: pull_request: + paths: &paths + - "**.py" + - "**.toml" + - "**.lock" + - "data/**" + - "Resources/nginx/**" + - "docker-compose**" + - Makefile + - .github/workflows/database.yml push: branches-ignore: - master - staging + paths: *paths jobs: csv: @@ -66,19 +76,14 @@ jobs: with: submodules: recursive - name: Build and start services - run: | - docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d --build + run: make docker-dev-up - name: Run migrations and build database run: | make docker-migrate make docker-build-db - name: Dump DB - run: docker compose exec -T db pg_dump -U ash -Fc -N 'hdb_*' pokeapi > pokeapi.dump - - name: Drop and recreate database - run: | - docker compose exec -T db psql -U ash -d postgres -c "DROP DATABASE pokeapi WITH (FORCE);" - docker compose exec -T db psql -U ash -d postgres -c "CREATE DATABASE pokeapi;" + run: make docker-dump-db - name: Import database - run: docker compose exec -T db pg_restore -U ash -d pokeapi < pokeapi.dump + run: make docker-restore-db - name: Test data run: curl -Ss http://localhost/api/v2/pokemon/1/ | grep -q 'bulbasaur' diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml index 1c0cce957..08f4f3ba8 100644 --- a/.github/workflows/docker-build-and-push.yml +++ b/.github/workflows/docker-build-and-push.yml @@ -2,9 +2,15 @@ name: Publish on: push: + paths: + - "**.py" + - "**.toml" + - "**.lock" + - "Resources/docker/**" + - .github/workflows/docker-build-and-push.yml branches: - - 'master' - - 'staging' + - master + - staging tags: - '*.*.*' @@ -28,7 +34,6 @@ jobs: id: buildx uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME_NARAMSIM }} diff --git a/.github/workflows/docker-k8s.yml b/.github/workflows/docker-k8s.yml index 6126a568c..19cf154b0 100644 --- a/.github/workflows/docker-k8s.yml +++ b/.github/workflows/docker-k8s.yml @@ -2,6 +2,17 @@ name: Container on: pull_request: + paths: + - "**.py" + - "**.toml" + - "**.lock" + - "data/**" + - "docker-compose**" + - "Resources/docker/**" + - "Resources/k8s/**" + - "Resources/kind/**" + - Makefile + - .github/workflows/docker-k8s.yml jobs: docker: @@ -107,8 +118,8 @@ jobs: uses: actions/checkout@v6 - name: Build dev environment run: | - docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d - sleep 30 + make docker-dev-up + sleep 5 - name: Assert containers running run: | last_command=$(docker ps | grep 'pokeapi-' | wc -l) diff --git a/.github/workflows/nix-environment.yml b/.github/workflows/nix-environment.yml index 9373fb68b..388732725 100644 --- a/.github/workflows/nix-environment.yml +++ b/.github/workflows/nix-environment.yml @@ -2,9 +2,17 @@ name: Nix Environment on: pull_request: + paths: &paths + - "**.py" + - "**.toml" + - "**.lock" + - default.nix + - Makefile + - .github/workflows/nix-environment.yml push: branches: - master + paths: *paths jobs: nix-test: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8fc8985f..9db0d9ea0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,11 @@ name: Release on: push: + paths: + - "**.py" + - "data/**" + - Makefile + - .github/workflows/release.yml branches: - master tags: @@ -18,18 +23,16 @@ jobs: submodules: recursive - name: Start pokeapi (docker) run: | - docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d + make docker-dev-up make docker-migrate make docker-build-db - name: Dump PG db - run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash -N 'hdb_*' pokeapi > pokeapi.pgdump" - - name: Copy PG dump - run: | - docker compose cp db:/tmp/pokeapi.pgdump ./ - ls -larth + run: make docker-dump-db + - name: List folder + run: ls -larth - name: Setup uv uses: ./.github/actions/setup-uv - - name: Start pokeapi + - name: Generate SQLite db run: | rm -rf .venv make install-base @@ -38,7 +41,7 @@ jobs: nohup make serve & sleep 3 - name: Release tag - uses: softprops/action-gh-release@v3.0.1 + uses: softprops/action-gh-release@v3.0.2 if: startsWith(github.ref, 'refs/tags/') with: draft: true @@ -48,7 +51,7 @@ jobs: db.sqlite3 generate_release_notes: true - name: Release master branch - uses: softprops/action-gh-release@v3.0.1 + uses: softprops/action-gh-release@v3.0.2 if: github.ref == 'refs/heads/master' with: body: | diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt deleted file mode 100755 index 21cbd5223..000000000 --- a/CONTRIBUTORS.txt +++ /dev/null @@ -1,5 +0,0 @@ -Paul Hallett paulandrewhallett@gmail.com -Zane Adickes zaneadix@gmail.com -Charles Marttinen charlesmarttinen.ca -Sargun Vohra sargun.vohra@gmail.com -Alessandro Pezzè igougi.ui@gmail.com diff --git a/Makefile b/Makefile index 68778b3f3..ce7e06dd3 100755 --- a/Makefile +++ b/Makefile @@ -62,6 +62,9 @@ openapi-generate: check-uv docker-up: # (Docker) Create services/volumes/networks docker compose up -d +docker-dev-up: # (Docker) Build local pokeapi image and create services/volumes/networks + docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d --build + docker-migrate: # (Docker) Run any pending migrations docker compose exec -T app python manage.py migrate ${docker_config} @@ -95,6 +98,14 @@ docker-prod: docker-setup: docker-up docker-migrate docker-build-db # (Docker) Start services, prepare the latest DB schema, populate the DB +docker-dump-db: + docker compose exec -T db pg_dump -U ash -Fc -N 'hdb_*' pokeapi > pokeapi.pgdump + +docker-restore-db: + docker compose exec -T db psql -U ash -d postgres -c "DROP DATABASE pokeapi WITH (FORCE);" + docker compose exec -T db psql -U ash -d postgres -c "CREATE DATABASE pokeapi;" + docker compose exec -T db pg_restore -U ash -d pokeapi < pokeapi.pgdump + format: check-uv # Format the source code uv run ruff format . diff --git a/scripts/scraping_pokeball_price.py b/Resources/scripts/scraping_pokeball_price.py similarity index 100% rename from scripts/scraping_pokeball_price.py rename to Resources/scripts/scraping_pokeball_price.py