Files
Anubis/.gitea/workflows/ci.yml
T
Alby96andClaude Opus 5.5 46e4a2bf6a
ci / test (postgres) (push) Successful in 5m50s
ci / test (sqlite) (push) Successful in 5m11s
ci / test (postgres) (pull_request) Successful in 5m40s
ci / test (sqlite) (pull_request) Successful in 5m0s
ci / image (push) Successful in 2m37s
ci / image (pull_request) Successful in 1m0s
Keep the data of the CI's PostgreSQL service in memory
The PostgreSQL job of the Phase 9 CI failed once on a read timeout while a
test connected: the service log showed the runner's disk stalled, with a
25-second checkpoint even with fsync off and a forced DROP DATABASE
waiting on a stuck backend. The data of the service now live on a tmpfs
at /var/lib/postgresql, which holds PGDATA in PostgreSQL 18, like the
SQLite test databases already do (ADR 0019).

Tried in the CI's SDK container against postgres:18 with the same
options: 706 tests passed of 709 (3 skipped), peak use 295 MB, no stall.
The limit is 1 GB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 14:29:00 +01:00

115 lines
4.9 KiB
YAML

# CI (SPEC 15.5, ADR 0003/0004): only run steps with git, dotnet and docker, no external actions.
# The image is published only on v* tags, after the tests and the drill (SPEC 15.5, ADR 0002 and 0020); never on fase-N.
name: ci
on:
push:
branches: ["**"]
tags: ["v*"]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:10.0
# The databases of the tests live in memory: the disk of the runner stops for seconds under load (ADR 0019).
# exec: Docker mounts a tmpfs noexec by default, and the tests run the fake git and docker they write there.
options: --tmpfs /test-tmp:size=4g,exec
strategy:
fail-fast: false
matrix:
db: [sqlite, postgres]
services:
postgres:
image: postgres:18
env:
POSTGRES_DB: anubis
POSTGRES_USER: anubis
POSTGRES_PASSWORD: anubis-ci
# A throwaway server on a slow disk: without syncs to disk, the checkpoint that every DROP DATABASE of the
# tests forces takes milliseconds instead of up to 37 seconds (ADR 0015). Never for a real database.
POSTGRES_INITDB_ARGS: "--no-sync -c fsync=off -c synchronous_commit=off -c full_page_writes=off"
# --init and a pg_isready that gives up before Docker does (ADR 0015, issue #98). Without them a health
# check that outlives its timeout leaves pg_isready to PostgreSQL as PID 1, and its exit restarts the server.
# The data live in memory too (ADR 0019): /var/lib/postgresql holds PGDATA of PostgreSQL 18; the whole
# suite peaks at about 300 MB.
options: >-
--init
--tmpfs /var/lib/postgresql:size=1g
--health-cmd "pg_isready -U anubis -d anubis -t 5"
--health-interval 3s
--health-timeout 15s
--health-retries 20
env:
ANUBIS_TEST_DB: ${{ matrix.db }}
ANUBIS_TEST_PG_HOST: postgres
ANUBIS_TEST_PG_PORT: "5432"
ANUBIS_TEST_PG_PASSWORD: anubis-ci
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "1"
TESTINGPLATFORM_TELEMETRY_OPTOUT: "1"
steps:
- name: Checkout
# The token goes to git through its environment, so it is on no command line.
env:
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: http.extraHeader
GIT_CONFIG_VALUE_0: "Authorization: token ${{ github.token }}"
run: |
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git fetch -q --depth 1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
- name: Check
run: |
df -h /test-tmp
TMPDIR=/test-tmp sh ./tasks.sh check
# The log of the PostgreSQL service, read through the Docker socket the runner mounts in the job (issue #98).
- name: PostgreSQL log
if: always() && matrix.db == 'postgres'
run: sh ./tasks.sh ci-service-log postgres
image:
needs: test
runs-on: ubuntu-latest
env:
# The Docker daemon of the runner is shared between runs: a name of this run only, so what is published is what was tried.
IMAGE: anubis:ci-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Checkout
# The token goes to git through its environment, so it is on no command line.
env:
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: http.extraHeader
GIT_CONFIG_VALUE_0: "Authorization: token ${{ github.token }}"
run: |
git init -q .
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git fetch -q --depth 1 origin "${{ github.sha }}"
git checkout -q FETCH_HEAD
- name: Build image
env:
REF: ${{ github.ref }}
REF_NAME: ${{ github.ref_name }}
run: |
case "$REF" in refs/tags/v*) version=${REF_NAME#v} ;; *) version=dev ;; esac
docker build -f deploy/docker/Dockerfile --build-arg "ANUBIS_VERSION=$version" --build-arg "ANUBIS_COMMIT=$(git rev-parse HEAD)" -t "$IMAGE" .
# The guard drill inside the image (issue #48): offline, its own SQLite database in a temporary folder.
- name: Guard drill in the image
run: docker run --rm "$IMAGE" drill
- name: Publish image
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
REGISTRY: ${{ vars.REGISTRY || 'gitea.encke-hake.ts.net' }}
REGISTRY_USER: ${{ vars.REGISTRY_USER || github.actor }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
TAG: ${{ github.ref_name }}
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: http.extraHeader
GIT_CONFIG_VALUE_0: "Authorization: token ${{ github.token }}"
run: sh ./deploy/docker/publish.sh "$IMAGE" "$TAG"
- name: Remove the image of this run
if: always()
run: docker image rm -f "$IMAGE" || true