|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths-ignore: |
| 6 | + - "*.md" |
| 7 | + - "LICENSE.txt" |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + paths-ignore: |
| 12 | + - "*.md" |
| 13 | + - "LICENSE.txt" |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Main test suite - tests Ruby versions and Rails compatibility with SQLite |
| 17 | + sqlite: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + ruby_version: ["3.3", "3.4", "4.0"] |
| 24 | + gemfile: |
| 25 | + - Gemfile |
| 26 | + - gemfiles/rails_7.2.gemfile |
| 27 | + - gemfiles/rails_8.1.gemfile |
| 28 | + |
| 29 | + env: |
| 30 | + RAILS_ENV: test |
| 31 | + BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Set up Ruby ${{ matrix.ruby_version }} |
| 38 | + uses: ruby/setup-ruby@v1 |
| 39 | + with: |
| 40 | + ruby-version: ${{ matrix.ruby_version }} |
| 41 | + bundler-cache: true |
| 42 | + |
| 43 | + - name: Run tests |
| 44 | + run: bundle exec rake test |
| 45 | + |
| 46 | + - name: Upload test results |
| 47 | + if: failure() |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: test-results-sqlite-ruby-${{ matrix.ruby_version }}-${{ matrix.gemfile }} |
| 51 | + path: test/reports/ |
| 52 | + retention-days: 7 |
| 53 | + |
| 54 | + # PostgreSQL compatibility tests |
| 55 | + postgres: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + |
| 58 | + strategy: |
| 59 | + fail-fast: false |
| 60 | + matrix: |
| 61 | + ruby_version: ["3.4"] |
| 62 | + |
| 63 | + services: |
| 64 | + postgres: |
| 65 | + image: postgres:16 |
| 66 | + env: |
| 67 | + POSTGRES_USER: postgres |
| 68 | + POSTGRES_PASSWORD: postgres |
| 69 | + POSTGRES_DB: wallets_test |
| 70 | + ports: |
| 71 | + - 5432:5432 |
| 72 | + options: >- |
| 73 | + --health-cmd="pg_isready -U postgres" |
| 74 | + --health-interval=10s |
| 75 | + --health-timeout=5s |
| 76 | + --health-retries=5 |
| 77 | +
|
| 78 | + env: |
| 79 | + RAILS_ENV: test |
| 80 | + DATABASE_URL: postgres://postgres:postgres@localhost:5432/wallets_test |
| 81 | + |
| 82 | + steps: |
| 83 | + - name: Checkout code |
| 84 | + uses: actions/checkout@v4 |
| 85 | + |
| 86 | + - name: Set up Ruby ${{ matrix.ruby_version }} |
| 87 | + uses: ruby/setup-ruby@v1 |
| 88 | + with: |
| 89 | + ruby-version: ${{ matrix.ruby_version }} |
| 90 | + bundler-cache: true |
| 91 | + |
| 92 | + - name: Prepare database |
| 93 | + # Use db:migrate:reset instead of db:test:prepare to avoid loading schema.rb |
| 94 | + # which has SQLite-specific defaults that fail on PostgreSQL. |
| 95 | + # db:migrate:reset does: db:drop, db:create, db:migrate (using migrations, not schema.rb) |
| 96 | + run: bundle exec rake db:migrate:reset |
| 97 | + |
| 98 | + - name: Run tests |
| 99 | + run: bundle exec rake test |
| 100 | + |
| 101 | + - name: Upload test results |
| 102 | + if: failure() |
| 103 | + uses: actions/upload-artifact@v4 |
| 104 | + with: |
| 105 | + name: test-results-postgres-ruby-${{ matrix.ruby_version }} |
| 106 | + path: test/reports/ |
| 107 | + retention-days: 7 |
| 108 | + |
| 109 | + # MySQL compatibility tests |
| 110 | + mysql: |
| 111 | + runs-on: ubuntu-latest |
| 112 | + |
| 113 | + strategy: |
| 114 | + fail-fast: false |
| 115 | + matrix: |
| 116 | + ruby_version: ["3.4"] |
| 117 | + |
| 118 | + services: |
| 119 | + mysql: |
| 120 | + image: mysql:8 |
| 121 | + env: |
| 122 | + MYSQL_ROOT_PASSWORD: root |
| 123 | + MYSQL_DATABASE: wallets_test |
| 124 | + ports: |
| 125 | + - 3306:3306 |
| 126 | + options: >- |
| 127 | + --health-cmd="mysqladmin ping -h localhost" |
| 128 | + --health-interval=10s |
| 129 | + --health-timeout=5s |
| 130 | + --health-retries=5 |
| 131 | +
|
| 132 | + env: |
| 133 | + RAILS_ENV: test |
| 134 | + DATABASE_URL: mysql2://root:root@127.0.0.1:3306/wallets_test |
| 135 | + |
| 136 | + steps: |
| 137 | + - name: Checkout code |
| 138 | + uses: actions/checkout@v4 |
| 139 | + |
| 140 | + - name: Set up Ruby ${{ matrix.ruby_version }} |
| 141 | + uses: ruby/setup-ruby@v1 |
| 142 | + with: |
| 143 | + ruby-version: ${{ matrix.ruby_version }} |
| 144 | + bundler-cache: true |
| 145 | + |
| 146 | + - name: Prepare database |
| 147 | + # Use db:migrate:reset instead of db:test:prepare to avoid loading schema.rb |
| 148 | + # which has SQLite-specific defaults that fail on MySQL (JSON column defaults). |
| 149 | + # db:migrate:reset does: db:drop, db:create, db:migrate (using migrations, not schema.rb) |
| 150 | + run: bundle exec rake db:migrate:reset |
| 151 | + |
| 152 | + - name: Run tests |
| 153 | + run: bundle exec rake test |
| 154 | + |
| 155 | + - name: Upload test results |
| 156 | + if: failure() |
| 157 | + uses: actions/upload-artifact@v4 |
| 158 | + with: |
| 159 | + name: test-results-mysql-ruby-${{ matrix.ruby_version }} |
| 160 | + path: test/reports/ |
| 161 | + retention-days: 7 |
0 commit comments