Skip to content

chore(#52): OSS/Hex packaging hygiene #88

chore(#52): OSS/Hex packaging hygiene

chore(#52): OSS/Hex packaging hygiene #88

Workflow file for this run

name: Elixir CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
name: Build and test (PG ${{ matrix.postgres }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# PostgreSQL 15+ is required: the auth profile mirror uses
# `security_invoker` views (added in PG15).
postgres: [ '15', '16', '17' ]
services:
postgres:
image: postgres:${{ matrix.postgres }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# Wait for the server to accept connections before the job runs.
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
# config/test.exs reads these; the `mix test` alias runs
# `mix bier.fixtures.load`, which connects to localhost:5432 and loads
# spec/conformance/fixtures.sql into a fresh `bier_test`.
PGHOST: localhost
PGPORT: '5432'
PGUSER: postgres
PGPASSWORD: postgres
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.24.0
with:
elixir-version: '1.19.5'
otp-version: '28'
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-otp28-elixir1.19-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-otp28-elixir1.19-mix-
- name: Install dependencies
run: mix deps.get
- name: Check unused dependencies
run: mix deps.unlock --check-unused
- name: Check formatting
run: mix format --check-formatted
- name: Compile (warnings as errors)
run: mix compile --warnings-as-errors
- name: Lint (credo)
run: mix credo --strict
- name: Build docs (warnings as errors)
run: mix docs --warnings-as-errors
- name: Run tests (conformance regression ratchet)
# The `test` alias loads spec/conformance/fixtures.sql into `bier_test`
# (via psql, preinstalled on the runner) before running ExUnit.
#
# The conformance suite has a known set of failures that are NOT Bier
# defects — they are frozen-harness / environment limits (the test client
# rejecting unencoded URLs, stripping Content-Length, dropping request
# bodies; missing PostGIS; a fixture-seed bug). See the issues labeled
# `conformance`. Until those are resolved, `mix test` exits non-zero, so we
# gate on a baseline instead: CI is green at the baseline and red only if
# failures INCREASE (a real regression). Lower BASELINE_FAILURES as the
# harness/env issues are fixed.
env:
BASELINE_FAILURES: '16'
run: |
set -o pipefail
mix test 2>&1 | tee test_output.txt || true
summary=$(grep -E '[0-9]+ tests?, [0-9]+ failures' test_output.txt | tail -1)
if [ -z "$summary" ]; then
echo "::error::test suite did not report a summary (fixtures load or compile failed)"
exit 1
fi
fails=$(echo "$summary" | grep -oE '[0-9]+ failures' | grep -oE '[0-9]+')
echo "Conformance failures: $fails (baseline $BASELINE_FAILURES)"
if [ "$fails" -gt "$BASELINE_FAILURES" ]; then
echo "::error::regression — $fails failures > baseline $BASELINE_FAILURES"
exit 1
fi
if [ "$fails" -lt "$BASELINE_FAILURES" ]; then
echo "::notice::$fails < baseline $BASELINE_FAILURES — lower BASELINE_FAILURES to lock in the gain"
fi
# Last so that newly published advisories against locked deps (which need
# a `mix deps.update` to clear) still fail the job without also hiding
# the compile/lint/docs/test results for the change under review.
- name: Audit Hex dependencies
run: mix hex.audit