Run Gitea CI in host mode, and add uvicorn to the dev extra
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:
@@ -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"
|
||||
Reference in New Issue
Block a user