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
e50630ac3a03f0f43a25129a73d424a9cc7c3345
1 file changed
+46
.github/workflows/ci.yml
+46
index d58c2aa..c633b6c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -65,3 +65,49 @@ jobs:
- name: Lint code for consistent style
run: bin/rubocop -f github
+ test:
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:16
+ env:
+ POSTGRES_USER: postgres
+ POSTGRES_PASSWORD: postgres
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd "pg_isready -U postgres"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ DATABASE_URL: postgres://postgres:postgres@localhost:5432/sigitsi_test
+ # The app reads secret_key_base from ENV (see .env.example); credentials
+ # are not read at boot, so a dummy key is enough to boot in test.
+ SECRET_KEY_BASE: dummy-secret-key-base-for-ci
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v6
+
+ # libvips (+ librsvg and a font) lets the Open Graph card endpoint render
+ # real PNGs in CI, matching production rather than the static fallback.
+ - name: Install libvips for Open Graph image rendering
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends libvips librsvg2-2 fonts-dejavu-core
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Prepare the test database
+ run: bin/rails db:test:prepare
+
+ - name: Run RSpec
+ run: bundle exec rspec
+