asxpio/.forgejo/workflows/test.yaml
Sergei Poljanski 6807d41aa4
Some checks failed
Tests / test (push) Failing after 1s
Build and Deploy to Production / build (push) Successful in 53s
Build and Deploy to Production / deploy (push) Successful in 25s
ci: publish postgres service port — job containers use host network
2026-07-02 17:57:25 +04:00

47 lines
1.4 KiB
YAML

name: Tests
on:
push:
branches:
- '**'
jobs:
test:
runs-on: nix-latest
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.
# The runner puts job containers on the host network while services sit
# on the per-workflow bridge, so the `postgres` hostname doesn't resolve
# from the job — the service publishes 5432 and the suite dials loopback.
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: asxpio_test
ports:
- 5432:5432
steps:
- name: Prepare container for actions
run: |
echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
nix-env -iA nixpkgs.nodejs_22 nixpkgs.git
- name: Checkout
uses: actions/checkout@v4
- name: Wait for Postgres
run: |
for i in $(seq 1 30); do
nix develop -c pg_isready -h 127.0.0.1 -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@127.0.0.1:5432/asxpio_test
run: nix develop -c bundle exec rake test