Improve CI matrix #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | ||
on: | ||
push: | ||
branches: ['master'] | ||
pull_request: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
### TEST RUBY VERSIONS | ||
- ruby: "2.6" | ||
- ruby: "2.7" | ||
- ruby: "3.0" | ||
db_gem_version: "~> 1.4" # fixes sqlite3 gem dependency issue | ||
- ruby: "3.1" | ||
- ruby: "3.2" | ||
- ruby: "3.3" | ||
### TEST RAILS VERSIONS | ||
- ruby: "2.6" | ||
rails_version: "~> 6.0.0" | ||
- ruby: "2.6" | ||
rails_version: "~> 6.1.0" | ||
- ruby: "3.3" | ||
rails_version: "~> 7.0.0" | ||
- ruby: "3.3" | ||
rails_version: "~> 7.1.0" | ||
- ruby: "3.3" | ||
rails_version: "~> 7.2.0" | ||
### TEST PT VERSIONS | ||
- ruby: "2.6" | ||
paper_trail_version: "~> 12.0" | ||
- ruby: "2.6" | ||
paper_trail_version: "~> 13.0" | ||
- ruby: "2.7" | ||
paper_trail_version: "~> 14.0" | ||
- ruby: "3.1" | ||
paper_trail_version: "~> 15.0" | ||
### TEST NON-SQLITE DATABASES | ||
- ruby: "3.3" | ||
db_gem: "mysql2" | ||
- ruby: "3.3" | ||
db_gem: "pg" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "${{ matrix.ruby }}" | ||
bundler-cache: false ### not compatible with ENV-style Gemfile | ||
services: | ||
mysql: | ||
image: ${{ (matrix.db_gem == 'mysql2' && 'mysql') || '' }} # conditional service | ||
env: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: test | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
ports: ['3306:3306'] | ||
postgres: | ||
image: ${{ (matrix.db_gem == 'pg' && 'postgres') || '' }} # conditional service | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: test | ||
ports: ['5432:5432'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set env DATABASE_URL | ||
run: | | ||
if [[ "${{ matrix.db_gem }}" == 'mysql2' ]]; then | ||
echo "DATABASE_URL=mysql2://root:[email protected]:3306/test" >> "$GITHUB_ENV" | ||
elif [[ "${{ matrix.db_gem }}" == 'pg' ]]; then | ||
echo "DATABASE_URL=postgres://postgres:password@localhost:5432/test" >> "$GITHUB_ENV" | ||
fi | ||
- name: Set env variables | ||
run: | | ||
echo "RAILS_VERSION=${{ matrix.rails_version }}" >> "$GITHUB_ENV" | ||
echo "DB_GEM=${{ matrix.db_gem }}" >> "$GITHUB_ENV" | ||
echo "DB_GEM_VERSION=${{ matrix.db_gem_version }}" >> "$GITHUB_ENV" | ||
echo "PAPER_TRAIL_VERSION=${{ matrix.paper_trail_version }}" >> "$GITHUB_ENV" | ||
- name: Install ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "${{ matrix.ruby }}" | ||
bundler-cache: true | ||
- name: Run tests | ||
env: | ||
RAILS_ENV: test | ||
run: | | ||
bundle install | ||
bundle exec rake |