|
6 | 6 | test: |
7 | 7 | runs-on: ubuntu-latest |
8 | 8 |
|
| 9 | + services: |
| 10 | + postgres: |
| 11 | + image: postgres:14 |
| 12 | + env: |
| 13 | + POSTGRES_USER: postgres |
| 14 | + POSTGRES_PASSWORD: postgres |
| 15 | + POSTGRES_DB: journaled_test |
| 16 | + ports: |
| 17 | + - 5432:5432 |
| 18 | + options: >- |
| 19 | + --health-cmd pg_isready |
| 20 | + --health-interval 10s |
| 21 | + --health-timeout 5s |
| 22 | + --health-retries 5 |
| 23 | +
|
9 | 24 | strategy: |
10 | 25 | fail-fast: false |
11 | 26 | matrix: |
12 | 27 | ruby: ['3.2', '3.3', '3.4'] |
13 | 28 | gemfile: |
14 | 29 | - gemfiles/rails_7_2.gemfile |
15 | 30 | - gemfiles/rails_8_0.gemfile |
| 31 | + database: ['sqlite3', 'postgresql'] |
16 | 32 | steps: |
17 | 33 | - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 |
18 | 34 | - uses: ruby/setup-ruby@e34163cd15f4bb403dcd72d98e295997e6a55798 # v1 |
|
21 | 37 | with: |
22 | 38 | ruby-version: ${{ matrix.ruby }} |
23 | 39 | bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 40 | + - name: Setup database |
| 41 | + if: matrix.database == 'postgresql' |
| 42 | + env: |
| 43 | + DATABASE_ADAPTER: postgresql |
| 44 | + DATABASE_USER: postgres |
| 45 | + DATABASE_PASSWORD: postgres |
| 46 | + DATABASE_HOST: localhost |
| 47 | + BUNDLE_GEMFILE: ${{ matrix.gemfile }} |
| 48 | + run: | |
| 49 | + bundle exec rake db:create db:schema:load |
24 | 50 | - name: Run tests |
25 | 51 | env: |
26 | 52 | BUNDLE_GEMFILE: ${{ matrix.gemfile }} |
| 53 | + DATABASE_ADAPTER: ${{ matrix.database }} |
| 54 | + DATABASE_USER: postgres |
| 55 | + DATABASE_PASSWORD: postgres |
| 56 | + DATABASE_HOST: localhost |
27 | 57 | run: bundle exec rake spec |
0 commit comments