test-migrations-two-step.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. name: Test two step migrations
  2. on:
  3. push:
  4. branches-ignore:
  5. - 'dependabot/**'
  6. - 'renovate/**'
  7. pull_request:
  8. jobs:
  9. pre_job:
  10. runs-on: ubuntu-latest
  11. outputs:
  12. should_skip: ${{ steps.skip_check.outputs.should_skip }}
  13. steps:
  14. - id: skip_check
  15. uses: fkirc/skip-duplicate-actions@v5
  16. with:
  17. paths: '["Gemfile*", ".ruby-version", "**/*.rb", ".github/workflows/test-migrations-two-step.yml", "lib/tasks/tests.rake"]'
  18. test:
  19. runs-on: ubuntu-latest
  20. needs: pre_job
  21. if: needs.pre_job.outputs.should_skip != 'true'
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. postgres:
  26. - 14-alpine
  27. - 15-alpine
  28. services:
  29. postgres:
  30. image: postgres:${{ matrix.postgres}}
  31. env:
  32. POSTGRES_PASSWORD: postgres
  33. POSTGRES_USER: postgres
  34. options: >-
  35. --health-cmd pg_isready
  36. --health-interval 10s
  37. --health-timeout 5s
  38. --health-retries 5
  39. ports:
  40. - 5432:5432
  41. redis:
  42. image: redis:7-alpine
  43. options: >-
  44. --health-cmd "redis-cli ping"
  45. --health-interval 10s
  46. --health-timeout 5s
  47. --health-retries 5
  48. ports:
  49. - 6379:6379
  50. env:
  51. CONTINUOUS_INTEGRATION: true
  52. DB_HOST: localhost
  53. DB_USER: postgres
  54. DB_PASS: postgres
  55. DISABLE_SIMPLECOV: true
  56. RAILS_ENV: test
  57. BUNDLE_CLEAN: true
  58. BUNDLE_FROZEN: true
  59. BUNDLE_WITHOUT: 'development production'
  60. BUNDLE_JOBS: 3
  61. BUNDLE_RETRY: 3
  62. steps:
  63. - uses: actions/checkout@v4
  64. - name: Install native Ruby dependencies
  65. run: |
  66. sudo apt-get update
  67. sudo apt-get install -y libicu-dev libidn11-dev
  68. - name: Set up bundler cache
  69. uses: ruby/setup-ruby@v1
  70. with:
  71. ruby-version: .ruby-version
  72. bundler-cache: true
  73. - name: Create database
  74. run: './bin/rails db:create'
  75. - name: Run migrations up to v2.0.0
  76. run: './bin/rails db:migrate VERSION=20171010025614'
  77. - name: Populate database with test data
  78. run: './bin/rails tests:migrations:populate_v2'
  79. - name: Run pre-deployment migrations up to v2.4.0
  80. run: './bin/rails db:migrate VERSION=20180514140000'
  81. env:
  82. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  83. - name: Populate database with test data
  84. run: './bin/rails tests:migrations:populate_v2_4'
  85. - name: Run migrations up to v2.4.3
  86. run: './bin/rails db:migrate VERSION=20180707154237'
  87. env:
  88. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  89. - name: Populate database with test data
  90. run: './bin/rails tests:migrations:populate_v2_4_3'
  91. - name: Run all remaining pre-deployment migrations
  92. run: './bin/rails db:migrate'
  93. env:
  94. SKIP_POST_DEPLOYMENT_MIGRATIONS: true
  95. - name: Run all post-deployment migrations
  96. run: './bin/rails db:migrate'
  97. - name: Check migration result
  98. run: './bin/rails tests:migrations:check_database'