Files
romm/.github/workflows/docker-pr.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

98 lines
3.4 KiB
YAML

name: Docker Image Check
# Releases and the nightly are the only other builds of docker/Dockerfile, so a
# change to what the image is built from gets built and booted here first.
on:
pull_request:
paths:
- "docker/**"
- "backend/**"
- "frontend/**"
- pyproject.toml
- uv.lock
- .python-version
- .github/workflows/docker-pr.yml
# 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:
build-and-boot:
runs-on: ubuntu-24.04
timeout-minutes: 45
services:
mariadb:
image: mariadb:13.0.2
ports:
- 3306:3306
env:
MARIADB_USER: romm
MARIADB_PASSWORD: passwd
MARIADB_DATABASE: romm
MARIADB_ROOT_PASSWORD: passwd
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3 --health-start-period=30s
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
# The cache is public, so fork PRs read it too. Nothing is written back:
# layers built from PR content must not reach a release image.
- name: Build the full image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
file: docker/Dockerfile
context: .
platforms: linux/amd64
target: full-image
load: true
tags: romm:pr
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/romm-buildcache:release-amd64
# Host networking reaches the MariaDB service on localhost. The image
# generates its own auth key and runs its own valkey when none is set.
- name: Start the container
run: |
mkdir -p "$RUNNER_TEMP/library"
docker run -d --name romm --network host \
-e DB_HOST=127.0.0.1 \
-e DB_NAME=romm \
-e DB_USER=romm \
-e DB_PASSWD=passwd \
-v "$RUNNER_TEMP/library:/romm/library" \
romm:pr
# Startup runs the migrations first, so a green heartbeat also means the
# image migrated a fresh database.
- name: Wait for the API through nginx
run: |
for i in $(seq 1 120); do
if curl -sf http://127.0.0.1:8080/api/heartbeat >/dev/null; then
echo "API up after ${i}s"
exit 0
fi
if [[ "$(docker inspect -f '{{.State.Running}}' romm)" != "true" ]]; then
echo "::error::The container exited during startup"
exit 1
fi
sleep 1
done
echo "::error::The API did not answer within 120s"
exit 1
- name: Check the frontend is served
run: curl -sf http://127.0.0.1:8080/ | grep -q '<div id="app"'
- name: Dump container logs
if: failure()
run: docker logs romm 2>&1 | tail -200 || true