The runner has docker, so the database container started; the job just could not reach it. pytest-databases takes the address from DOCKER_HOST, and unset means 127.0.0.1 -- the job container's loopback, not the namespace the sibling published on. A dind service makes it resolve to a host that answers.
97 lines
2.8 KiB
YAML
97 lines
2.8 KiB
YAML
name: ci
|
|
|
|
# Formatting, linting, types and tests on every push and pull request.
|
|
#
|
|
# Blocking: ruff format, ruff check, pytest, prettier and svelte-check.
|
|
# Non-blocking: eslint, which reports two `{@html}` XSS findings in collapsible-text.svelte.
|
|
# Those are a real vulnerability rather than a lint nit — book descriptions from EPUB files
|
|
# are not sanitized — and fixing them is a backend change. Drop the `continue-on-error` once
|
|
# that lands, at which point every check blocks.
|
|
#
|
|
# The release workflow runs the blocking half again before it publishes anything.
|
|
|
|
on:
|
|
push:
|
|
branches: ['**']
|
|
pull_request:
|
|
|
|
jobs:
|
|
backend:
|
|
runs-on: ubuntu-latest
|
|
|
|
# pytest-databases starts PostgreSQL in a container and then connects to it. Which address
|
|
# it connects to is decided by DOCKER_HOST: unset or unix:// means 127.0.0.1, which is wrong
|
|
# here because the job is itself a container and the database is a sibling, published on
|
|
# another network namespace. Pointing at a dind service instead makes pytest-databases
|
|
# resolve the host to `docker`, where the port really is.
|
|
#
|
|
# If the runner is ever configured with its own dind sidecar, delete this block and the
|
|
# DOCKER_HOST below: every job gets a daemon then, including the ones in release.yml.
|
|
services:
|
|
docker:
|
|
image: docker:27-dind
|
|
options: --privileged
|
|
env:
|
|
DOCKER_TLS_CERTDIR: ''
|
|
|
|
env:
|
|
DOCKER_HOST: tcp://docker:2375
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# astral-sh/setup-uv is not mirrored on gitea.com, unlike the actions used elsewhere
|
|
# here, so install uv directly rather than depending on DEFAULT_ACTIONS_URL.
|
|
- name: Install uv
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
|
|
|
- name: Install dependencies
|
|
run: uv sync --locked
|
|
|
|
- name: Format
|
|
run: uv run ruff format --check src/ tests/
|
|
|
|
- name: Lint
|
|
run: uv run ruff check src/ tests/
|
|
|
|
- name: Tests
|
|
run: uv run pytest tests/ -q
|
|
|
|
frontend:
|
|
runs-on: ubuntu-latest
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: frontend
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
|
|
- name: Enable pnpm
|
|
run: corepack enable
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
# Split out of `pnpm lint` (which is prettier && eslint) so formatting can block
|
|
# while eslint does not.
|
|
- name: Format
|
|
run: pnpm exec prettier --check .
|
|
|
|
- name: Lint
|
|
run: pnpm exec eslint .
|
|
continue-on-error: true
|
|
|
|
- name: Types
|
|
run: pnpm check
|