forked from fixin.me/fixin.me
- .gitea/workflows/test.yml: two parallel CI jobs (SQLite and MySQL), each generates its own database.yml inline and runs the test suite - lib/tasks/test_multi_db.rake: `rails test:all_adapters` runs both adapters sequentially using DATABASE_URL to switch at runtime Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
96 lines
2.0 KiB
YAML
96 lines
2.0 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
jobs:
|
|
test-sqlite:
|
|
name: Tests (SQLite)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: '3.3'
|
|
bundler-cache: true
|
|
env:
|
|
BUNDLE_WITH: "sqlite:development:test"
|
|
|
|
- name: Generate database.yml
|
|
run: |
|
|
cat > config/database.yml <<'EOF'
|
|
test:
|
|
adapter: sqlite3
|
|
database: db/test.sqlite3
|
|
pool: 5
|
|
EOF
|
|
|
|
- name: Set up test database
|
|
run: bin/rails db:create db:schema:load
|
|
env:
|
|
RAILS_ENV: test
|
|
|
|
- name: Run tests
|
|
run: bin/rails test
|
|
env:
|
|
RAILS_ENV: test
|
|
CI: "true"
|
|
|
|
test-mysql:
|
|
name: Tests (MySQL)
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: ""
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
|
MYSQL_DATABASE: fixin_test
|
|
ports:
|
|
- 3306:3306
|
|
options: >-
|
|
--health-cmd="mysqladmin ping"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=3
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: '3.3'
|
|
bundler-cache: true
|
|
env:
|
|
BUNDLE_WITH: "mysql:development:test"
|
|
|
|
- name: Generate database.yml
|
|
run: |
|
|
cat > config/database.yml <<'EOF'
|
|
test:
|
|
adapter: mysql2
|
|
encoding: utf8mb4
|
|
collation: utf8mb4_0900_as_ci
|
|
database: fixin_test
|
|
host: 127.0.0.1
|
|
username: root
|
|
password: ""
|
|
pool: 5
|
|
EOF
|
|
|
|
- name: Set up test database
|
|
run: bin/rails db:schema:load
|
|
env:
|
|
RAILS_ENV: test
|
|
|
|
- name: Run tests
|
|
run: bin/rails test
|
|
env:
|
|
RAILS_ENV: test
|
|
CI: "true"
|