Files
shopdb-flask/.gitea/workflows/ci.yml
cproudlock 702861f1f9
Some checks failed
CI / naming (push) Successful in 28s
CI / frontend (push) Successful in 12s
CI / migrations-mysql (push) Failing after 15s
CI / backend (push) Successful in 4m7s
ci: pin Python 3.14 and stop depending on the runner's environment
Three failures, all from the workflow inheriting whatever the runner
happened to have rather than declaring what it needs.

- backend ran pytest without installing it. pytest is in
  requirements-dev.txt, which nothing installed, so the step died with
  "No module named pytest".
- Both Python jobs used the runner's system interpreter. The old host
  executor had a matching Python by accident; a container image has
  3.10, where alembic additionally requires tomli. requirements.txt is
  hash-pinned and compiled on 3.14, so tomli has no hash and pip refuses
  the whole install under --require-hashes. 3.14 matches the Dockerfile,
  the README and the .github workflow.
- The utf8mb4 step shelled out to the mysql client, which is not in
  every runner image. pymysql is already a runtime dependency.
2026-08-27 01:37:39 +00:00

149 lines
5.7 KiB
YAML

# CI for shopdb-flask.
#
# The Gitea runner executes jobs on the host (act host executor), so
# actions/setup-python cannot provision interpreters (no prebuilt binaries
# for the host distro). The backend job uses the system python3 in a venv
# instead. setup-node works because node is resolved differently.
#
# Jobs run on push and pull_request:
# backend - pytest (tests use in-memory SQLite via TestingConfig, so no
# database service is needed).
# naming - the CONTRIBUTING.md naming/style gate.
# frontend - Vue build.
# migrations-mysql - proves the REAL multi-site deploy path: a fresh
# `flask db upgrade` + per-plugin install on utf8mb4 MySQL
# from empty, idempotent on a second run. The pytest suite
# only exercises SQLite create_all(), so without this a
# regression in the Alembic chain on MySQL would ship
# undetected. Needs a runner that supports service
# containers; if yours does not, run these steps against a
# host MySQL instead.
name: CI
on:
push:
pull_request:
jobs:
backend:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Python
# Pin the interpreter instead of inheriting the runner image's default.
# requirements.txt is hash-pinned and was compiled on 3.14; on an older
# Python, alembic additionally requires tomli, which has no hash in the
# lock file and pip then refuses the whole install.
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install dependencies
run: |
python3 --version
python3 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
# pytest lives in requirements-dev.txt, not requirements.txt. Without
# this the test step dies with "No module named pytest".
.venv/bin/pip install -r requirements-dev.txt
- name: Run backend tests
run: .venv/bin/python -m pytest
naming:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Run naming and style check
run: bash scripts/check-naming-and-style.sh
frontend:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install and build frontend
run: |
npm ci
npm run build
working-directory: frontend
migrations-mysql:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: shopdb_ci
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost -uroot -proot"
--health-interval=5s --health-timeout=5s --health-retries=20
env:
DATABASE_URL: mysql+pymysql://root:root@127.0.0.1:3306/shopdb_ci?charset=utf8mb4
SECRET_KEY: ci-secret
JWT_SECRET_KEY: ci-jwt-secret
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Python
# Pin the interpreter instead of inheriting the runner image's default.
# requirements.txt is hash-pinned and was compiled on 3.14; on an older
# Python, alembic additionally requires tomli, which has no hash in the
# lock file and pip then refuses the whole install.
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install dependencies
run: |
python3 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt
- name: Force utf8mb4 on the CI database
# Uses pymysql, already a runtime dependency, rather than the mysql CLI,
# which is not present in every runner image.
run: |
.venv/bin/python - <<'PY'
import pymysql
c = pymysql.connect(host="127.0.0.1", port=3306, user="root", password="root")
with c.cursor() as cur:
cur.execute("ALTER DATABASE shopdb_ci CHARACTER SET utf8mb4 "
"COLLATE utf8mb4_unicode_ci")
c.close()
PY
- name: Fresh core upgrade from empty
run: .venv/bin/flask db upgrade
- name: Install every bundled plugin (runs its chain)
run: |
for p in computers employees geenforce knowledgebase machines \
measuringtools network notifications printers slides usb warranty; do
.venv/bin/flask plugin install "$p"
done
- name: Assert schema built + utf8mb4, and a second upgrade is a no-op
run: |
.venv/bin/python - <<'PY'
from shopdb import create_app
from shopdb.extensions import db
from sqlalchemy import text
app = create_app()
with app.app_context():
insp = db.inspect(db.engine)
tables = insp.get_table_names()
assert len(tables) >= 70, f'only {len(tables)} tables built'
row = db.session.execute(text(
"SELECT default_character_set_name FROM information_schema.schemata "
"WHERE schema_name = 'shopdb_ci'")).first()
assert row[0] == 'utf8mb4', f'charset is {row[0]}, not utf8mb4'
print(f'OK: {len(tables)} tables, charset {row[0]}')
PY
- name: Second core upgrade must be a clean no-op
run: .venv/bin/flask db upgrade