Run Gitea CI in host mode, and add uvicorn to the dev extra
CI / test (3.10) (push) Successful in 1m50s
CI / test (3.12) (push) Successful in 53s
CI / test (3.13) (push) Successful in 54s

Every Gitea Actions run failed in actions/checkout: the stpvm runner is
registered against http://localhost:3000, which an ubuntu-latest job
container can't reach. Add .gitea/workflows/ci.yml, which Gitea uses in
place of the GitHub workflow, following web_server's pattern: host mode,
a plain git fetch over Gitea's SSH port, and ruff + pytest inside
python:<version>-slim containers.

That surfaced a real failure: test_serve_refuses_without_token imports
uvicorn, which only the web extra installed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-23 22:15:19 +01:00
co-authored by Claude Opus 5.5
parent 597bace442
commit fa99c3076c
3 changed files with 75 additions and 1 deletions
+73
View File
@@ -0,0 +1,73 @@
# ci.yml - ruff and pytest on every push, on each supported Python.
#
# Gitea runs this file instead of .github/workflows/ci.yml (it ignores
# .github/workflows once .gitea/workflows exists). The .github copy stays for
# GitHub, where `ubuntu-latest` + actions/checkout work.
#
# WHY NOT THE GITHUB WORKFLOW AS-IS
# The act_runner on stpvm is registered against http://localhost:3000.
# `ubuntu-latest` jobs run in a docker container, where localhost is the
# container itself, so actions/checkout can't reach Gitea and every run
# failed before a test ran. Like web_server's deploy.yaml, this runs in
# the runner's host mode (`self-hosted`), fetches the commit with plain git
# over Gitea's SSH port, and runs the checks inside pinned python images.
name: CI
on:
push:
jobs:
test:
runs-on: self-hosted
strategy:
matrix:
python: ["3.10", "3.12", "3.13"]
env:
# Passed through env rather than interpolated into the scripts, so
# a branch name can never be parsed as shell.
SHA: ${{ github.sha }}
REF: ${{ github.ref }}
PYTHON: ${{ matrix.python }}
REMOTE: ssh://git@localhost:2222/adamf/receipt_maker.git
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
# Bare repo kept between runs so each fetch is incremental.
CACHE: /home/adamf/.cache/receipt_maker-ci/repo.git
# This run's tree, keyed by commit and Python so matrix jobs can't share one.
SRC: /home/adamf/.cache/receipt_maker-ci/src-${{ github.sha }}-${{ matrix.python }}
steps:
- name: Export the pushed commit to a scratch directory
shell: bash
run: |
set -eu
mkdir -p "$(dirname "$CACHE")"
[ -d "$CACHE" ] || git init --quiet --bare "$CACHE"
# Test $SHA, not FETCH_HEAD: the branch may have moved on since
# this run was queued.
git --git-dir="$CACHE" fetch --quiet --no-tags "$REMOTE" "$REF"
rm -rf "$SRC"
mkdir -p "$SRC"
git --git-dir="$CACHE" archive --format=tar "$SHA" | tar -x -C "$SRC"
test -f "$SRC/pyproject.toml" # catch a half-failed archive without pipefail
echo "Exported $SHA ($REF) to $SRC"
# The source is mounted read-only (so the root container can't leave
# files the runner user can't delete) and copied inside, because
# pip builds the package in place.
- name: ruff and pytest
shell: bash
run: |
set -eu
docker run --rm \
-v "$SRC":/src:ro \
-v receipt_maker_ci_pip:/root/.cache/pip \
-e PYTHONDONTWRITEBYTECODE=1 \
"python:$PYTHON-slim" \
sh -c 'cp -r /src /work && cd /work \
&& pip install --quiet --disable-pip-version-check --root-user-action=ignore ".[dev]" \
&& ruff check . \
&& python -m pytest -q -p no:cacheprovider'
- name: Remove the scratch directory
if: always()
shell: bash
run: rm -rf "$SRC"
+1 -1
View File
@@ -132,7 +132,7 @@ pytest # run the tests
ruff check . # lint ruff check . # lint
``` ```
Both checks also run in CI on every push and pull request (`.github/workflows/ci.yml`). Both checks also run in CI on every push, on Python 3.10, 3.12 and 3.13. Gitea Actions uses `.gitea/workflows/ci.yml`: the runner on stpvm runs it in host mode and does the checks inside `python:<version>-slim` containers, because its docker-mode jobs can't reach Gitea for `actions/checkout`. `.github/workflows/ci.yml` is the same CI for GitHub.
## Files ## Files
+1
View File
@@ -26,6 +26,7 @@ dev = [
"textual>=1.0", "textual>=1.0",
"rich>=13.0", "rich>=13.0",
"fastapi>=0.110", "fastapi>=0.110",
"uvicorn>=0.29", # imported by receipt_web.serve(), which the tests call
"python-multipart>=0.0.9", "python-multipart>=0.0.9",
"httpx>=0.27", # FastAPI's TestClient "httpx>=0.27", # FastAPI's TestClient
] ]