|
| 1 | +name: RSpec PostgreSQL 18 |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - development |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened] |
| 9 | + release: |
| 10 | + types: [published] |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: ${{ github.workflow }}, Ruby ${{ matrix.ruby_version }}, Rails ${{ matrix.rails_version }} |
| 15 | + runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + ruby_version: |
| 20 | + - 3.1 |
| 21 | + - 3.2 |
| 22 | + - 3.3 |
| 23 | + - 3.4 |
| 24 | + - jruby |
| 25 | + rails_version: |
| 26 | + - 7_0 |
| 27 | + - 7_1 |
| 28 | + - 7_2 |
| 29 | + - 8_0 |
| 30 | + - 8_1 |
| 31 | + exclude: |
| 32 | + - ruby_version: jruby |
| 33 | + rails_version: 7_1 |
| 34 | + - ruby_version: jruby |
| 35 | + rails_version: 7_2 |
| 36 | + - ruby_version: jruby |
| 37 | + rails_version: 8_0 |
| 38 | + - ruby_version: 3.1 |
| 39 | + rails_version: 8_0 |
| 40 | + - ruby_version: jruby |
| 41 | + rails_version: 8_1 |
| 42 | + - ruby_version: 3.1 |
| 43 | + rails_version: 8_1 |
| 44 | + - ruby_version: 3.1 |
| 45 | + env: |
| 46 | + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails_version }}${{ matrix.ruby_version == 'jruby' && '_jdbc' || '' }}_postgresql.gemfile |
| 47 | + CI: true |
| 48 | + DATABASE_ENGINE: postgresql |
| 49 | + RUBY_VERSION: ${{ matrix.ruby_version }} |
| 50 | + RAILS_VERSION: ${{ matrix.rails_version }} |
| 51 | + services: |
| 52 | + postgres: |
| 53 | + image: postgres:18-alpine |
| 54 | + env: |
| 55 | + POSTGRES_PASSWORD: postgres |
| 56 | + POSTGRES_HOST_AUTH_METHOD: trust |
| 57 | + POSTGRES_DB: apartment_postgresql_test |
| 58 | + options: >- |
| 59 | + --health-cmd pg_isready |
| 60 | + --health-interval 10s |
| 61 | + --health-timeout 5s |
| 62 | + --health-retries 5 |
| 63 | + ports: |
| 64 | + - 5432:5432 |
| 65 | + steps: |
| 66 | + - name: Install PostgreSQL client |
| 67 | + run: | |
| 68 | + sudo apt-get update -qq |
| 69 | + sudo apt-get install -y --no-install-recommends postgresql-common |
| 70 | + echo | sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh |
| 71 | + sudo apt-get update -qq |
| 72 | + sudo apt-get install -y --no-install-recommends postgresql-client-18 |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + - name: Set up Ruby ${{ matrix.ruby-version }} |
| 75 | + uses: ruby/setup-ruby@v1 |
| 76 | + with: |
| 77 | + ruby-version: ${{ matrix.ruby_version }} |
| 78 | + bundler-cache: true |
| 79 | + - name: Configure config database.yml |
| 80 | + run: bundle exec rake db:load_credentials |
| 81 | + - name: Database Setup |
| 82 | + run: bundle exec rake db:test:prepare |
| 83 | + - name: Run tests |
| 84 | + id: rspec-tests |
| 85 | + timeout-minutes: 20 |
| 86 | + continue-on-error: true |
| 87 | + run: | |
| 88 | + mkdir -p ./coverage |
| 89 | + bundle exec rspec --format progress \ |
| 90 | + --format RspecJunitFormatter -o ./coverage/test-results.xml \ |
| 91 | + --profile |
| 92 | + - name: Codecov Upload |
| 93 | + uses: codecov/codecov-action@v4 |
| 94 | + with: |
| 95 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 96 | + verbose: true |
| 97 | + disable_search: true |
| 98 | + env_vars: DATABASE_ENGINE, RUBY_VERSION, RAILS_VERSION |
| 99 | + file: ./coverage/coverage.json |
| 100 | + - name: Upload test results to Codecov |
| 101 | + uses: codecov/test-results-action@v1 |
| 102 | + with: |
| 103 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 104 | + verbose: true |
| 105 | + disable_search: true |
| 106 | + env_vars: DATABASE_ENGINE, RUBY_VERSION, RAILS_VERSION |
| 107 | + file: ./coverage/test-results.xml |
| 108 | + - name: Notify of test failure |
| 109 | + if: steps.rspec-tests.outcome == 'failure' |
| 110 | + run: exit 1 |
0 commit comments