Handle PendingMigrationConnection introduced by Rails 7.2 #122
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Test Suite | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
tags: | |
- '**' | |
jobs: | |
export_variables: | |
runs-on: ubuntu-latest | |
outputs: | |
primary_image: ${{ steps.compute_container_registry_name.outputs.CR_NAME }}/postgres_primary:${{ steps.calculate_primary_sha.outputs.PRIMARY_SHA }} | |
replica_image: ${{ steps.compute_container_registry_name.outputs.CR_NAME }}/postgres_replica:${{ steps.calculate_replica_sha.outputs.REPLICA_SHA }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Compute container registry name | |
id: compute_container_registry_name | |
run: echo "CR_NAME=$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
- name: Calculate SHA256 for postgres_primary.dockerfile | |
id: calculate_primary_sha | |
run: echo "PRIMARY_SHA=$(sha256sum postgres_primary.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_OUTPUT | |
- name: Calculate SHA256 for postgres_replica.dockerfile | |
id: calculate_replica_sha | |
run: | | |
checksum () { | |
sha256sum $@ | awk '{print substr($1, 1, 12)}' | |
} | |
REPLICA_DOCKERFILE_SHA=$(checksum postgres_replica.dockerfile) | |
REPLICA_CMD_SHA=$(checksum docker/postgres_replica/cmd.sh) | |
echo "REPLICA_SHA=$(echo \"${REPLICA_DOCKERFILE_SHA}-${REPLICA_CMD_SHA}\" | checksum)" >> $GITHUB_OUTPUT | |
rubocop: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1.6 | |
- name: Install dependencies | |
run: | | |
gem install bundler | |
bundle install | |
- name: Run RuboCop | |
run: bundle exec rubocop | |
rspec: | |
needs: [export_variables] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
ruby: | |
- 3.2.6 | |
- 3.3.6 | |
rails: | |
- 7.0.0 | |
- 7.1.0 | |
- 7.2.0 | |
- 8.0.0 | |
include: | |
- ruby: 3.1.6 | |
rails: 7.0.0 | |
- ruby: 3.1.6 | |
rails: 7.1.0 | |
name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.rails }} | |
services: | |
postgres_primary: | |
image: ${{ needs.export_variables.outputs.primary_image }} | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: postgres_primary_test | |
POSTGRES_USER: postgres_primary_test | |
POSTGRES_PASSWORD: postgres_primary_test | |
POSTGRES_HOST_AUTH_METHOD: "scram-sha-256\nhost replication all 0.0.0.0/0 md5" | |
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256" | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
postgres_replica: | |
image: ${{ needs.export_variables.outputs.replica_image }} | |
ports: | |
- 5433:5432 | |
env: | |
PGUSER: replicator | |
PGPASSWORD: replicator | |
PGPORT: 5432 | |
PRIMARY_DATABASE_HOST: postgres_primary | |
PRIMARY_DATABASE_PORT: 5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
# Install PostgreSQL 17 client tools | |
- name: Add PostgreSQL 17 repository | |
run: | | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install -y postgresql-client-17 | |
- name: Check if primary is available | |
run: pg_isready -h localhost -U postgres_primary_test --dbname=postgres -p 5432 | |
- name: Check if replica is available | |
# run: pg_isready -h localhost -U replicator --dbname=postgres -p 5433 | |
run: pg_isready -h localhost -U postgres_primary_test --dbname=postgres -p 5433 | |
- name: Install dependencies | |
env: | |
RAILS_VERSION: ${{ matrix.rails }} | |
run: | | |
gem install bundler | |
bundle install | |
- name: Run RSpec tests | |
env: | |
RAILS_ENV: test | |
PG_PRIMARY_USER: postgres_primary_test | |
PG_PRIMARY_PASSWORD: postgres_primary_test | |
PG_PRIMARY_HOST: localhost | |
PG_PRIMARY_PORT: 5432 | |
PG_REPLICA_USER: postgres_primary_test | |
PG_REPLICA_PASSWORD: postgres_primary_test | |
PG_REPLICA_HOST: localhost | |
PG_REPLICA_PORT: 5433 | |
run: | | |
export RUBY_VERSION="${{ matrix.ruby }}" | |
export RAILS_VERSION="${{ matrix.rails }}" | |
bundle exec rake db:setup | |
bundle exec rspec --format progress | |
- name: Upload Coverage Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_ruby_${{ matrix.ruby }}_rails_${{ matrix.rails }} | |
path: coverage/ | |
include-hidden-files: true | |
if-no-files-found: error | |
coverage_report: | |
needs: [rspec] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.3.5 | |
- name: Install Dependencies | |
run: | | |
gem install bundler | |
bundle install | |
- name: Download Partial Coverage Resultsets | |
uses: actions/download-artifact@v4 | |
with: | |
path: coverage/ | |
- name: Collate Partial Coverage Resultsets | |
run: bundle exec rake coverage:report | |
- name: Upload Full Coverage Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: coverage/ | |
include-hidden-files: true | |
if-no-files-found: error | |
- uses: joshmfrankel/simplecov-check-action@main | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} |