From b64ac23c16b940a3ceb3dca962e212cecf96acc2 Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Mon, 16 Oct 2023 18:45:59 -0700 Subject: [PATCH] Refractor CI, Add Rails 7.1 to CI --- .github/workflows/test.yml | 68 ++++++++++++++-------------- .gitignore | 2 +- Appraisals | 42 ----------------- Gemfile | 19 ++++---- gemfiles/rails_5.0.sqlite3.gemfile | 9 ---- gemfiles/rails_5.1.sqlite3.gemfile | 9 ---- gemfiles/rails_5.2.sqlite3.gemfile | 9 ---- gemfiles/rails_6.0.sqlite3.gemfile | 9 ---- gemfiles/rails_6.1.sqlite3.gemfile | 9 ---- gemfiles/rails_7.0.sqlite3.gemfile | 9 ---- spreadsheet_architect.gemspec | 13 ++---- test/dummy_app/config/application.rb | 4 +- 12 files changed, 46 insertions(+), 156 deletions(-) delete mode 100644 Appraisals delete mode 100644 gemfiles/rails_5.0.sqlite3.gemfile delete mode 100644 gemfiles/rails_5.1.sqlite3.gemfile delete mode 100644 gemfiles/rails_5.2.sqlite3.gemfile delete mode 100644 gemfiles/rails_6.0.sqlite3.gemfile delete mode 100644 gemfiles/rails_6.1.sqlite3.gemfile delete mode 100644 gemfiles/rails_7.0.sqlite3.gemfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d09143b..e6ba0e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,46 +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.3 - - ruby: 2.4 - - ruby: 2.5 - - ruby: 2.6 - - ruby: 2.7 - - ruby: "3.0" ### must be quoted otherwise will be treated as "3" which resolves to latest 3.x version - - ruby: 3.1 - - ruby: 3.2 - - ### RAILS VERSION TESTING - - ruby: 2.6 - gemfile: gemfiles/rails_5.0.sqlite3.gemfile - - ruby: 2.6 - gemfile: gemfiles/rails_5.1.sqlite3.gemfile - - ruby: 2.6 - gemfile: gemfiles/rails_5.2.sqlite3.gemfile - - ruby: 2.6 - gemfile: gemfiles/rails_6.0.sqlite3.gemfile - - ruby: 2.6 - gemfile: gemfiles/rails_6.1.sqlite3.gemfile + ### TEST RUBY VERSIONS + - ruby: "2.5" + - ruby: "2.6" + - ruby: "2.7" - ruby: "3.0" - gemfile: gemfiles/rails_7.0.sqlite3.gemfile - - env: - BUNDLE_GEMFILE: "${{ matrix.gemfile }}" + - ruby: "3.1" + - ruby: "3.2" + ### TEST RAILS VERSIONS + - ruby: "2.6" + env: + RAILS_VERSION: "5.2" + - ruby: "2.6" + env: + RAILS_VERSION: "6.0" + - ruby: "2.6" + env: + RAILS_VERSION: "6.1" + - ruby: "3.2" + env: + RAILS_VERSION: "7.0" + - ruby: "3.2" + env: + RAILS_VERSION: "7.1" steps: - uses: actions/checkout@v3 @@ -49,8 +46,9 @@ 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 exec rake + bundle install + bundle exec rake test diff --git a/.gitignore b/.gitignore index c3404a0..2784c11 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ coverage/ doc/ pkg/ spec/reports/ -test/dummy_app/**/*.sqlite3.db +test/dummy_app/**/*.sqlite3* test/dummy_app/**/*.sqlite3 test/dummy_app/**/*.csv test/dummy_app/**/*.ods diff --git a/Appraisals b/Appraisals deleted file mode 100644 index 5669cca..0000000 --- a/Appraisals +++ /dev/null @@ -1,42 +0,0 @@ -["sqlite3"].each do |db_gem| - appraise "rails_7.0.#{db_gem}" do - gem "rails", "~> 7.0.0" - gem 'responders' - gem db_gem - end - - appraise "rails_6.1.#{db_gem}" do - gem "rails", "~> 6.1.1" - gem 'responders' - gem db_gem - end - - appraise "rails_6.0.#{db_gem}" do - gem "rails", "~> 6.0.3" - gem 'responders' - gem db_gem - end - - appraise "rails_5.2.#{db_gem}" do - gem "rails", "~> 5.2.4" - gem 'responders' - gem db_gem - end - - appraise "rails_5.1.#{db_gem}" do - gem "rails", "~> 5.1.7" - gem 'responders' - gem db_gem - end - - appraise "rails_5.0.#{db_gem}" do - gem "rails", "~> 5.0.7" - gem 'responders' - - if db_gem == 'sqlite3' - gem "sqlite3", "~> 1.3.13" - else - gem db_gem - end - end -end diff --git a/Gemfile b/Gemfile index e4b79e2..08f763a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,16 +3,13 @@ source 'https://rubygems.org' gemspec ### Must remain in the Gemfile, not gemspec, otherwise Rails integration tests fail -gem 'responders' +gem 'responders' -if (RUBY_VERSION.to_f < 2.5 || false) ### set to true if locally testing old Rails version - #gem 'rails', '~> 5.0.7' - #gem 'rails', '~> 5.1.7' - gem 'rails', "~> 5.2.4" - gem 'sqlite3', '~> 1.3.6' -else - #gem 'rails', '~> 6.0.3' - #gem 'rails', '~> 6.1.1' - gem 'rails' - gem 'sqlite3' +def get_env(name) + (ENV[name] && !ENV[name].empty?) ? ENV[name] : nil end + +gem "rails", get_env("RAILS_VERSION") +gem "sqlite3" + +gem "minitest-spec-rails", git: "https://github.com/metaskills/minitest-spec-rails.git" diff --git a/gemfiles/rails_5.0.sqlite3.gemfile b/gemfiles/rails_5.0.sqlite3.gemfile deleted file mode 100644 index 36cab31..0000000 --- a/gemfiles/rails_5.0.sqlite3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "responders" -gem "rails", "~> 5.0.7" -gem "sqlite3", "~> 1.3.13" - -gemspec path: "../" diff --git a/gemfiles/rails_5.1.sqlite3.gemfile b/gemfiles/rails_5.1.sqlite3.gemfile deleted file mode 100644 index b3e169d..0000000 --- a/gemfiles/rails_5.1.sqlite3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "responders" -gem "rails", "~> 5.1.7" -gem "sqlite3" - -gemspec path: "../" diff --git a/gemfiles/rails_5.2.sqlite3.gemfile b/gemfiles/rails_5.2.sqlite3.gemfile deleted file mode 100644 index 15c88bc..0000000 --- a/gemfiles/rails_5.2.sqlite3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "responders" -gem "rails", "~> 5.2.4" -gem "sqlite3" - -gemspec path: "../" diff --git a/gemfiles/rails_6.0.sqlite3.gemfile b/gemfiles/rails_6.0.sqlite3.gemfile deleted file mode 100644 index 7295ff6..0000000 --- a/gemfiles/rails_6.0.sqlite3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "responders" -gem "rails", "~> 6.0.3" -gem "sqlite3" - -gemspec path: "../" diff --git a/gemfiles/rails_6.1.sqlite3.gemfile b/gemfiles/rails_6.1.sqlite3.gemfile deleted file mode 100644 index 4250493..0000000 --- a/gemfiles/rails_6.1.sqlite3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "responders" -gem "rails", "~> 6.1.1" -gem "sqlite3" - -gemspec path: "../" diff --git a/gemfiles/rails_7.0.sqlite3.gemfile b/gemfiles/rails_7.0.sqlite3.gemfile deleted file mode 100644 index e50ea75..0000000 --- a/gemfiles/rails_7.0.sqlite3.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "responders" -gem "rails", "~> 7.0.0" -gem "sqlite3" - -gemspec path: "../" diff --git a/spreadsheet_architect.gemspec b/spreadsheet_architect.gemspec index 61e14b1..824cd34 100644 --- a/spreadsheet_architect.gemspec +++ b/spreadsheet_architect.gemspec @@ -8,27 +8,20 @@ Gem::Specification.new do |s| s.author = "Weston Ganger" s.email = 'weston@westonganger.com' s.homepage = 'https://github.com/westonganger/spreadsheet_architect' - + s.summary = "Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets easily from ActiveRecord relations, Plain Ruby classes, or predefined data." - s.description = s.summary + s.description = s.summary s.license = 'MIT' s.files = Dir.glob("{lib/**/*}") + %w{ LICENSE README.md Rakefile CHANGELOG.md } s.require_path = 'lib' - s.required_ruby_version = '>= 2.3.0' - s.add_runtime_dependency 'caxlsx', ['>= 3.3.0', '<4'] s.add_runtime_dependency 'rodf', ['>= 1.0.0', '<2'] - + s.add_development_dependency 'rake' - s.add_development_dependency 'bundler' s.add_development_dependency 'minitest' s.add_development_dependency 'minitest-reporters' - s.add_development_dependency 'minitest-spec-rails' - s.add_development_dependency 'appraisal' - s.add_development_dependency 'sqlite3' - s.add_development_dependency 'rails' s.add_development_dependency 'pry' if RUBY_VERSION.to_f >= 2.4 diff --git a/test/dummy_app/config/application.rb b/test/dummy_app/config/application.rb index 1e2b7fc..092f0b1 100644 --- a/test/dummy_app/config/application.rb +++ b/test/dummy_app/config/application.rb @@ -48,9 +48,7 @@ class Application < Rails::Application if ActiveRecord.respond_to?(:gem_version) gem_version = ActiveRecord.gem_version - if gem_version >= Gem::Version.new("7.0.0") - config.active_record.legacy_connection_handling = false - elsif gem_version.to_s.start_with?("5.2.") + if gem_version.to_s.start_with?("5.2.") config.active_record.sqlite3.represent_boolean_as_integer = true end end