CORE-978: Indicate first & last names are required #2182
This file contains hidden or 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: Migrations | |
on: | |
pull_request: | |
types: | |
- opened | |
- edited | |
- synchronize | |
- reopened | |
# Add concurrency to cancel outdated workflow runs | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
migrations: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
issues: write | |
services: | |
postgres: | |
image: postgres:11 | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
# Set health checks to wait until redis has started | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
# Clone repo and checkout merge commit parent (PR target commit) | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- run: git checkout HEAD^ | |
# Install base commit ruby version | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
# Create data to be migrated and revert to PR merge commit | |
- name: Cache database setup | |
uses: actions/cache@v4 | |
with: | |
path: | | |
tmp/cache | |
db/schema.rb | |
key: db-setup-${{ github.sha }} | |
restore-keys: | | |
db-setup- | |
- name: Create data to be migrated | |
env: | |
OXA_DB_USER: postgres | |
OXA_DB_PASS: postgres | |
PGPASSWORD: postgres | |
RAILS_ENV: test | |
run: | | |
bin/rake db:create db:schema:load db:seed --trace | |
bin/rails runner '3.times { FactoryBot.create :user }' | |
# Export data for integrity check | |
pg_dump -U postgres -h localhost -F c -f pre_migration.dump ox_accounts_test | |
git checkout --force - | |
# Install PR ruby version | |
- name: Set up Ruby (PR version) | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
# Migrate the data | |
- name: Migrate and verify | |
env: | |
OXA_DB_USER: postgres | |
OXA_DB_PASS: postgres | |
PGPASSWORD: postgres | |
RAILS_ENV: test | |
run: | | |
# Run migrations | |
bin/rake db:migrate | |
# Verify data integrity | |
bin/rails runner ' | |
begin | |
User.count == 3 or raise "User count mismatch" | |
puts "✅ Data integrity check passed" | |
rescue => e | |
puts "❌ Data integrity check failed: #{e.message}" | |
exit 1 | |
end | |
' | |
# Export post-migration data | |
pg_dump -U postgres -h localhost -F c -f post_migration.dump ox_accounts_test | |
- name: Upload migration artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: migration-artifacts | |
path: | | |
pre_migration.dump | |
post_migration.dump | |
log/development.log | |
retention-days: 7 | |
- name: Notify on failure | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '❌ Migration check failed. Check the [workflow run](' + context.serverUrl + '/' + context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + context.runId + ') for details.' | |
}) |