ci: run RSpec on a Postgres service with libvips

Adds a `test` job to the CI workflow so the spec suite runs on every PR. Spins up a postgres:16 service, installs libvips/librsvg/fonts so the Open Graph card endpoint renders real PNGs (matching production rather than the static fallback), prepares the test database, and runs `bundle exec rspec`. The app reads secret_key_base from ENV and does not read credentials at boot, so a dummy SECRET_KEY_BASE is enough to boot in test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Seto Elkahfi committed Jun 30, 2026 at 19:57 UTC b0d012159f4204acb15ad3eda3f600e9722105af
1 file changed +46
.github/workflows/ci.yml
+46
@@ -65,3 +65,49 @@ jobs:
65 - name: Lint code for consistent style
66 run: bin/rubocop -f github
67
68 + test:
69 + runs-on: ubuntu-latest
70 +
71 + services:
72 + postgres:
73 + image: postgres:16
74 + env:
75 + POSTGRES_USER: postgres
76 + POSTGRES_PASSWORD: postgres
77 + ports:
78 + - 5432:5432
79 + options: >-
80 + --health-cmd "pg_isready -U postgres"
81 + --health-interval 10s
82 + --health-timeout 5s
83 + --health-retries 5
84 +
85 + env:
86 + RAILS_ENV: test
87 + DATABASE_URL: postgres://postgres:postgres@localhost:5432/sigitsi_test
88 + # The app reads secret_key_base from ENV (see .env.example); credentials
89 + # are not read at boot, so a dummy key is enough to boot in test.
90 + SECRET_KEY_BASE: dummy-secret-key-base-for-ci
91 +
92 + steps:
93 + - name: Checkout code
94 + uses: actions/checkout@v6
95 +
96 + # libvips (+ librsvg and a font) lets the Open Graph card endpoint render
97 + # real PNGs in CI, matching production rather than the static fallback.
98 + - name: Install libvips for Open Graph image rendering
99 + run: |
100 + sudo apt-get update
101 + sudo apt-get install -y --no-install-recommends libvips librsvg2-2 fonts-dejavu-core
102 +
103 + - name: Set up Ruby
104 + uses: ruby/setup-ruby@v1
105 + with:
106 + bundler-cache: true
107 +
108 + - name: Prepare the test database
109 + run: bin/rails db:test:prepare
110 +
111 + - name: Run RSpec
112 + run: bundle exec rspec
113 +