Default to "most-recent 10 games" in /game/list view
Some checks failed
Publish / build-and-push (push) Failing after 4m6s

Also fully migrate to Gitea Actions (from Drone) for CI/CD.
This commit is contained in:
Jack Jackson 2025-04-05 16:35:39 -07:00
parent 119b086f92
commit 6f6b58159f
3 changed files with 15 additions and 83 deletions

View File

@ -1,82 +0,0 @@
kind: pipeline
name: build-and-deploy
type: docker
platform:
os: linux
arch: arm64
steps:
- name: docker-build-and-push
image: thegeeklab/drone-docker-buildx # Absurd that this isn't offered as first-party!
privileged: true
settings:
# Consider testing with this if the cache-to arguments don't help!
# args:
# - BUILDKIT_INLINE_CACHE=1
cache_from:
- "gitea.scubbo.org/${DRONE_REPO}:${DRONE_BRANCH}"
cache_to:
# https://docs.docker.com/build/cache/backends/registry/
# `mode=max` necessary in order to cache intermediate stages
#
# https://github.com/go-gitea/gitea/issues/28973#issuecomment-1961859655
# Some parameters are necessary in order to make the push to gitea succeed
#
# Another reference:
# https://github.com/thegeeklab/drone-docker-buildx/issues/47
- "type=registry,ref=gitea.scubbo.org/${DRONE_REPO}:${DRONE_BRANCH},mode=max,image-manifest=true,oci-mediatypes=true"
registry: gitea.scubbo.org
username: scubbo
password:
from_secret: gitea_password
repo: gitea.scubbo.org/${DRONE_REPO}
tags:
- ${DRONE_BRANCH}
- ${DRONE_COMMIT_SHA:0:10}
target: prod
platforms:
- linux/arm64
- linux/amd64
- name: Update Helm Chart
image: alpine
environment:
GITEA_PASSWORD:
from_secret: gitea_password
GITEA_PAT:
from_secret: gitea_pat
commands:
# Cannot use `drone/git` plugin because:
# * it cannot check out to a different directory
# * if you try to clear the main directory and use it to checkout, Drone will just re-clone the original repo
# between steps
# ...God, I really need to transition off of Drone and onto a better CI tool...
- find . -not -path '.' | xargs rm -rf
- find . -not -path '.'
- apk add yq git
- git clone https://scubbo:${GITEA_PASSWORD}@gitea.scubbo.org/scubbo/helm-charts.git
- cd helm-charts
- cat charts/edh-elo/values.yaml
- yq -i '.image.tag = "${DRONE_COMMIT_SHA:0:10}"' charts/edh-elo/values.yaml
- git add -A
- git -c user.name="Imagebot" -c user.email="fake@scubbo.org" commit -m 'Update EDH ELO commit to "${DRONE_COMMIT_SHA:0:10}"'
- git remote add origin-with-credentials "https://scubbo:$GITEA_PAT@gitea.scubbo.org/scubbo/helm-charts.git"
- git push origin-with-credentials main:main
- name: update-argo
image: curlimages/curl
environment:
ARGO_TOKEN:
from_secret: argo_token
commands:
- "curl -sS -X POST \"argo-cd-argocd-server.argo.svc.cluster.local/api/v1/applications/edh-elo/sync\" -H \"Authorization: Bearer ${ARGO_TOKEN}\" -H \"Content-Type: application/json\""
- name: purge-cache
image: curlimages/curl
environment:
CLOUDFLARE_TOKEN:
from_secret: cloudflare_token
commands:
- "curl -sS -X POST \"https://api.cloudflare.com/client/v4/zones/c86d55d225ed973d5da45239beac2f99/purge_cache\" -H \"Authorization: Bearer ${CLOUDFLARE_TOKEN}\" -H \"Content-Type:application/json\" -d '{\"files\":[\"https://edh-elo.scubbo.org/*\"]}'"

View File

@ -51,4 +51,15 @@ jobs:
run: | run: |
echo "Image pushed: gitea.scubbo.org/scubbo/edh-elo:${{ gitea.sha }}" echo "Image pushed: gitea.scubbo.org/scubbo/edh-elo:${{ gitea.sha }}"
# TODO - update Helm chart with new image - name: Update Helm Chart
env:
GITEA_PASSWORD: ${{ env.GITEA_TOKEN }}
run: |
git clone https://scubbo:${GITEA_PASSWORD}@gitea.scubbo.org/scubbo/helm-charts.git
cd helm-charts
yq -i '.image.tag = "${{ gitea.sha }}"' charts/edh-elo/values.yaml
git add -A
git -c user.name="Imagebot" -c user.email="fake@scubbo.org" commit -m 'Update EDH ELO commit to "${{ gitea.sha }}"'
git push origin main:main
cd ...
rm -rf helm-charts

View File

@ -168,6 +168,9 @@ def game_create_html(request: Request, db=Depends(get_db)):
@html_router.get("/list") @html_router.get("/list")
def games_html(request: Request, db=Depends(get_db)): def games_html(request: Request, db=Depends(get_db)):
query_parameters = request.query_params query_parameters = request.query_params
if not query_parameters:
# I.e. they navigated to just `/game/list`, meaning we should serve the default view - 10 latest games
query_parameters = {"sort_order": "desc", "limit": 10}
# `**query_parameters` expands the object as named-params to the function - setting `limit` and `offset` appropriately # `**query_parameters` expands the object as named-params to the function - setting `limit` and `offset` appropriately
games = list_games(db=db, **query_parameters) games = list_games(db=db, **query_parameters)
# TODO - a more "data-intensive application" implementation would fetch only the decks involved in the games for # TODO - a more "data-intensive application" implementation would fetch only the decks involved in the games for