diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab2f26a..ad7ba7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,51 +1,43 @@ name: Tests - on: push: - branches: - - master + branches: ['master'] pull_request: - branches: - - '*' jobs: - test_sqlite: - runs-on: ubuntu-20.04 + test: + runs-on: ubuntu-latest + + env: + RAILS_ENV: test + strategy: fail-fast: false matrix: include: - ### TEST ALL RUBY VERSIONS, USE DEFAULT GEMFILE - - ruby: 2.5 - - ruby: 2.6 - - ruby: 2.7 - - ruby: "3.0" ### must be quoted otherwise will be treated as "3" which will resolve to latest 3.x version - - ruby: 3.1 - - ruby: 3.2 - - ### RAILS VERSION TESTING - - ruby: 2.6 - env: - RAILS_VERSION: "5.0" - - ruby: 2.6 - env: - RAILS_VERSION: "5.1" - - ruby: 2.6 + ### TEST RUBY VERSIONS + - ruby: "2.5" + - ruby: "2.6" + - ruby: "2.7" + - ruby: "3.0" + - ruby: "3.1" + - ruby: "3.2" + ### TEST RAILS VERSIONS + - ruby: "2.6" env: RAILS_VERSION: "5.2" - - ruby: 2.6 + - ruby: "2.6" env: RAILS_VERSION: "6.0" - - ruby: 2.6 + - ruby: "2.6" env: RAILS_VERSION: "6.1" - - ruby: "3.1" + - ruby: "3.2" env: RAILS_VERSION: "7.0" - - env: - BUNDLE_GEMFILE: "${{ matrix.gemfile }}" - DB_GEM: "sqlite3" + - ruby: "3.2" + env: + RAILS_VERSION: "7.1" steps: - uses: actions/checkout@v3 @@ -54,10 +46,11 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: "${{ matrix.ruby }}" - bundler-cache: true + bundler-cache: false ### not compatible with ENV-style Gemfile - - name: Run tests + - name: Run test run: | + bundle install bundle exec rake db:create bundle exec rake db:migrate bundle exec rake test diff --git a/.gitignore b/.gitignore index 8d12a7f..9f408cd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ log/*.log pkg/ spec/dummy/db/*.sqlite3 -spec/dummy/db/*.sqlite3-journal +spec/dummy/db/*.sqlite3* spec/dummy/log/*.log spec/dummy/storage/ spec/dummy/tmp/ diff --git a/Gemfile b/Gemfile index 49c23ed..e82190b 100644 --- a/Gemfile +++ b/Gemfile @@ -11,10 +11,12 @@ gemspec # Git. Remember to move these dependencies to your gemspec before releasing # your gem to rubygems.org. -ENV['DB_GEM'] ||= 'sqlite3' +def get_env(name) + (ENV[name] && !ENV[name].empty?) ? ENV[name] : nil +end -gem 'rails', ENV["RAILS_VERSION"] -gem ENV['DB_GEM'] +gem "rails", get_env("RAILS_VERSION") +gem "sqlite3" group :development, :test do gem "sprockets-rails" ### just for dummy app diff --git a/Rakefile b/Rakefile index 4a97f76..135b003 100644 --- a/Rakefile +++ b/Rakefile @@ -11,9 +11,9 @@ load 'rails/tasks/statistics.rake' require 'bundler/gem_tasks' -task :test do - system("rspec", out: STDOUT) - exit $?.exitstatus -end +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) + +task test: [:spec] -task default: :test +task default: [:spec]