Skip to content

ci: create + load schema for the host test DB before rspec #3

ci: create + load schema for the host test DB before rspec

ci: create + load schema for the host test DB before rspec #3

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CI: "true"
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
jobs:
lint:
name: RuboCop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clone the sibling seams gem (Gemfile uses path source)
run: git clone --depth 1 https://github.com/Davidslv/seams.git ../seams
- uses: ruby/setup-ruby@v1
with:
ruby-version: ".ruby-version"
bundler-cache: true
- run: bundle exec rubocop --parallel
security:
name: Security (brakeman + bundle-audit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clone the sibling seams gem (Gemfile uses path source)
run: git clone --depth 1 https://github.com/Davidslv/seams.git ../seams
- uses: ruby/setup-ruby@v1
with:
ruby-version: ".ruby-version"
bundler-cache: true
- run: bundle exec brakeman --no-pager --no-progress --quiet --ignore-config config/brakeman.ignore
- run: bundle exec bundle-audit check --update
# Discover engines once and fan out — every engine's specs run in
# parallel under its own job. Seams custom RuboCop cops still run
# against engine code (in the lint job above) but unit specs run
# per engine for fast signal.
discover:
name: Discover engines
runs-on: ubuntu-latest
outputs:
engines: ${{ steps.set.outputs.engines }}
steps:
- uses: actions/checkout@v4
- id: set
run: |
if [ -d engines ]; then
engines=$(find engines -mindepth 1 -maxdepth 1 -type d \
-not -name '.*' -printf '%f\n' \
| jq -R -s -c 'split("\n") | map(select(length > 0))')
else
engines='[]'
fi
echo "engines=$engines" >> "$GITHUB_OUTPUT"
test_engine:
name: Test ${{ matrix.engine }}
needs: discover
if: needs.discover.outputs.engines != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
engine: ${{ fromJson(needs.discover.outputs.engines) }}
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:5432"
PGHOST: "localhost"
PGPORT: "5432"
PGUSER: "postgres"
PGPASSWORD: "postgres"
steps:
- uses: actions/checkout@v4
- name: Clone the sibling seams gem (Gemfile uses path source)
run: git clone --depth 1 https://github.com/Davidslv/seams.git ../seams
- uses: ruby/setup-ruby@v1
with:
ruby-version: ".ruby-version"
bundler-cache: true
- run: bundle exec rspec --default-path engines/${{ matrix.engine }}/spec engines/${{ matrix.engine }}/spec
test_app:
name: Test host app
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:5432"
PGHOST: "localhost"
PGPORT: "5432"
PGUSER: "postgres"
PGPASSWORD: "postgres"
steps:
- uses: actions/checkout@v4
- name: Clone the sibling seams gem (Gemfile uses path source)
run: git clone --depth 1 https://github.com/Davidslv/seams.git ../seams
- uses: ruby/setup-ruby@v1
with:
ruby-version: ".ruby-version"
bundler-cache: true
- name: Prepare test database (create + load schema)
env:
RAILS_ENV: test
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/seams_example_test"
run: bin/rails db:create db:schema:load
- run: bundle exec rspec spec