Files
romm/.github/workflows/migrations.yml
Georges-Antoine Assi a874e4d012 ci: keep CI jobs off Ubuntu apt mirrors (#5182)
* ci: bound apt network timeouts for Playwright's dependency install

`npx playwright install --with-deps` runs its own `apt-get update`, so the
`-o` flags from #5181 could not reach it, and a stalled Ubuntu mirror hung
the frontend test job until the 15 minute limit cancelled it. Move the
retry/timeout options into an apt.conf.d file written by a small composite
action, used by setup-backend and the frontend test job.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: install Playwright's headless shell without apt

The apt.conf.d timeouts did not stop the hang: on a runner whose Azure
mirror is unreachable, apt falls back to archive.ubuntu.com and stalls
while downloading the package indexes, slowly enough that no timeout
fires. The ubuntu-latest image already ships Chrome's system libraries,
so drop --with-deps from the frontend and e2e jobs and keep apt out of
their path. Revert the bound-apt-timeouts action, and run the frontend
checks when frontend.yml itself changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: install setup-backend's apt packages from a cache

The MariaDB connector .debs (plus each job's extra apt packages) were
fetched from an Ubuntu mirror on every backend job, so a stalled mirror
could hang any of them until the 15 minute limit, the same way it hung
Playwright's dependency install. Cache the downloaded .debs keyed on the
runner image OS and package list, saved from master only, and install
from them without apt-get update on a hit. A miss still downloads them
with the #5181 retry and timeout options.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: install cached apt packages without re-downloading them

With package lists present, apt fetched the mirror's copy of each local
.deb instead of installing the file, so even the cached path reached the
mirror. Point apt's archives dir at the .deb directory and pass
--no-download. Also read ImageOS in a shell step: it is a runner shell
variable, not in the `env` context, so the cache key came out empty.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: pin workflow runners to ubuntu-24.04

The apt .deb cache in setup-backend only holds packages built for one
Ubuntu release. Pin every job to ubuntu-24.04 so a GitHub move of
ubuntu-latest can't restore noble packages onto a newer image, and
hardcode the release in the cache key instead of reading ImageOS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 16:56:47 -04:00

133 lines
4.2 KiB
YAML

name: Run Migrations
on:
pull_request:
paths:
- "backend/alembic/versions/**"
- ".github/workflows/migrations.yml"
- pyproject.toml
- uv.lock
- .python-version
# A new push cancels a PR's superseded run; each master commit keeps its own.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
migrate-postgres:
runs-on: ubuntu-24.04
timeout-minutes: 15
services:
postgres:
image: postgres:18
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up the backend
uses: ./.github/actions/setup-backend
- name: Run PostgreSQL Migrations
working-directory: backend
env:
ROMM_DB_DRIVER: postgresql
DB_HOST: localhost
DB_PORT: 5432
DB_USER: user
DB_PASSWD: password
DB_NAME: testdb
ROMM_AUTH_SECRET_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ROMM_BASE_PATH: romm_test
run: uv run alembic upgrade head
migrate-mariadb:
# A server configured for utf8mb3 makes the roms table, the view literals
# and the JSON_TABLE columns utf8mb3, which breaks collation-sensitive
# migration SQL that a default utf8mb4 server accepts (issue #4350).
name: migrate-mariadb (${{ matrix.mariadb }}, ${{ matrix.collation }})
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
# renovate: datasource=docker depName=mariadb
- mariadb: "13.0.2"
charset: utf8mb4
collation: utf8mb4_general_ci
# renovate: datasource=docker depName=mariadb
- mariadb: "13.0.2"
charset: utf8mb3
collation: utf8mb3_unicode_ci
# Oldest supported LTS, and the only leg still on the pre-uca1400
# default. Unmarked so updates cannot raise it off that floor.
- mariadb: "10.11.19"
charset: utf8mb4
collation: utf8mb4_general_ci
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up the backend
uses: ./.github/actions/setup-backend
- name: Start MariaDB
env:
CHARSET: ${{ matrix.charset }}
COLLATION: ${{ matrix.collation }}
MARIADB_IMAGE_TAG: ${{ matrix.mariadb }}
run: |
docker run -d --name mariadb -p 3306:3306 \
-e MARIADB_USER=user \
-e MARIADB_PASSWORD=password \
-e MARIADB_DATABASE=testdb \
-e MARIADB_ROOT_PASSWORD=root \
--health-cmd "healthcheck.sh --connect --innodb_initialized" \
--health-interval 5s \
--health-timeout 2s \
--health-retries 10 \
"mariadb:$MARIADB_IMAGE_TAG" \
--character-set-server="$CHARSET" \
--collation-server="$COLLATION"
for _ in $(seq 1 30); do
if [ "$(docker inspect -f '{{.State.Health.Status}}' mariadb)" = healthy ]; then
exit 0
fi
sleep 2
done
echo "MariaDB never became healthy" >&2
docker logs mariadb >&2
exit 1
- name: Run MariaDB Migrations
working-directory: backend
env:
ROMM_DB_DRIVER: mariadb
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: user
DB_PASSWD: password
DB_NAME: testdb
ROMM_AUTH_SECRET_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ROMM_BASE_PATH: romm_test
run: uv run alembic upgrade head