asxpio/.forgejo/workflows/test.yaml
Sergei Poljanski 4c0b6c3eef
All checks were successful
Build and Deploy to Production / test (push) Successful in 10m15s
Build and Deploy to Production / build (push) Successful in 59s
Build and Deploy to Production / deploy (push) Successful in 1m42s
Build the app as a Nix package, with a NixOS module to run it
packages.default is the app with its gems (bundlerEnv from Gemfile.lock
and gemset.nix, generated by bundix): bin/asxpio is Puma serving
config.ru, bin/asxpio-monitor the reachability worker. Photos are
resized with ImageMagick 7's magick. nixosModules.default
(services.asxpio) runs both as hardened systemd services with a dynamic
user, the web one with readiness from Puma (Type=notify); settings and
secrets come from one environment file. CI checks that gemset.nix
matches Gemfile.lock (bin/check-gemset) and builds the package.

Checked locally: migrations on an empty database, /healthz and /, an
invoice PDF with the Noto fonts, a photo resized to WebP and cropped.

The container deploy stays until the NixOS service has taken over.

Assisted-by: Claude:opus-5-5
2026-11-17 14:01:16 +04:00

70 lines
2.3 KiB
YAML

name: Tests
# main is covered by the test job inside deploy.yaml (which gates the build);
# this workflow covers every other branch.
on:
push:
branches-ignore:
- main
jobs:
test:
runs-on: nix-latest
# Settings via env, not /etc/nix/nix.conf: in the image that is a
# symlink into /nix/store, which the runner's nix-store volume
# shadows, so it dangles once the image moves on.
env:
NIX_CONFIG: |
experimental-features = nix-command flakes
build-users-group =
sandbox = false
services:
# CI stand-in for bin/test's ephemeral Postgres: the nix container runs
# as root and initdb refuses to run as root, so the DB lives in a
# service container instead and the suite connects via TEST_DATABASE_URL.
# Job and service share the per-workflow bridge network (the runner's
# container.network must stay "" — with "host" the service network is
# never created and services fail to start).
postgres:
image: postgres:18.7-alpine
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: asxpio_test
steps:
- name: Prepare container for actions
run: |
# node for JS actions (checkout); git-minimal is already in the image
nix-env -iA nixpkgs.nodejs_22
- name: Checkout
uses: actions/checkout@v7.0.1
# The nix closure persists in the runner's nix-store volume; gems live
# in the workspace (.gems via the flake's BUNDLE_PATH), so cache those.
- name: Cache gems
uses: actions/cache@v6.1.0
with:
path: .gems
key: gems-${{ hashFiles('Gemfile.lock') }}
- name: Wait for Postgres
run: |
for i in $(seq 1 30); do
nix develop -c pg_isready -h postgres -U postgres && exit 0
sleep 2
done
echo "Postgres service never became ready" >&2
exit 1
- name: Run test suite
env:
TEST_DATABASE_URL: postgres://postgres@postgres:5432/asxpio_test
run: nix develop -c bundle exec rake test
# What the servers run: gemset.nix in step with Gemfile.lock, and
# the package builds
- name: Package
run: |
nix develop -c ruby bin/check-gemset
nix build .#default