From f0e09f84a3fc77cd0278543029faf3a90f326091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Co=C3=AAlho?= Date: Wed, 8 Nov 2023 15:26:16 -0300 Subject: [PATCH] Update CI --- .github/workflows/ci.yml | 71 +++++++++++++++++++++++++++++-------- Gemfile | 59 +++++------------------------- bin/prepare_coverage | 27 -------------- bin/test | 53 --------------------------- gemfiles/rails_5.2/Gemfile | 24 +++++++++++++ gemfiles/rails_6.0/Gemfile | 24 +++++++++++++ gemfiles/rails_6.1/Gemfile | 24 +++++++++++++ gemfiles/rails_7.0/Gemfile | 24 +++++++++++++ gemfiles/rails_7.1/Gemfile | 24 +++++++++++++ gemfiles/rails_edge/Gemfile | 24 +++++++++++++ 10 files changed, 209 insertions(+), 145 deletions(-) delete mode 100755 bin/prepare_coverage delete mode 100755 bin/test create mode 100644 gemfiles/rails_5.2/Gemfile create mode 100644 gemfiles/rails_6.0/Gemfile create mode 100644 gemfiles/rails_6.1/Gemfile create mode 100644 gemfiles/rails_7.0/Gemfile create mode 100644 gemfiles/rails_7.1/Gemfile create mode 100644 gemfiles/rails_edge/Gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4100dc49..6574cf5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,27 +1,70 @@ -name: build +name: Test on: [push, pull_request] jobs: test: + name: "Ruby ${{ matrix.ruby }} - Rails ${{ matrix.rails }} - Transitions: ${{ matrix.transitions }}" runs-on: ubuntu-latest strategy: matrix: - ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 3.0, 3.1] + ruby: [2.7, 3.0, 3.1, 3.2, head] + rails: ["6.1", "7.0", "7.1", "edge"] + transitions: ["true", "false"] + include: + - ruby: 2.5 + rails: "5.2" + transitions: true + - ruby: 2.5 + rails: "6.0" + transitions: true + - ruby: 2.5 + rails: "6.1" + transitions: true + - ruby: 2.6 + rails: "5.2" + transitions: true + - ruby: 2.6 + rails: "6.0" + transitions: true + - ruby: 2.6 + rails: "6.1" + transitions: true + - ruby: 2.5 + rails: "5.2" + transitions: false + - ruby: 2.5 + rails: "6.0" + transitions: false + - ruby: 2.5 + rails: "6.1" + transitions: false + - ruby: 2.6 + rails: "5.2" + transitions: false + - ruby: 2.6 + rails: "6.0" + transitions: false + - ruby: 2.6 + rails: "6.1" + transitions: false + - ruby: 2.7 + rails: "6.0" + transitions: true + - ruby: 2.7 + rails: "6.0" + transitions: false + env: + BUNDLE_GEMFILE: "gemfiles/rails_${{ matrix.rails }}/Gemfile" + ENABLE_TRANSITIONS: ${{ matrix.transitions }} + ACTIVERECORD_VERSION: ${{ matrix.rails }} + CC_TEST_REPORTER_ID: 0377ece62be9c7042557d76e4e38b867e51c51b2a42d10ef5102b613ac077eab steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: Test and generate coverage - run: bin/test - - name: Format coverage - if: ${{ matrix.ruby >= 3 }} - run: bin/prepare_coverage - - uses: paambaati/codeclimate-action@v2.7.5 - if: ${{ matrix.ruby >= 3 }} - env: - CC_TEST_REPORTER_ID: 0377ece62be9c7042557d76e4e38b867e51c51b2a42d10ef5102b613ac077eab - with: - debug: true - coverageLocations: coverage/.resultset.json:simplecov + run: bundle exec rake test + - uses: paambaati/codeclimate-action@v5 + if: ${{ matrix.ruby == 3.2 && matrix.rails == '7.1' && matrix.transitions == 'true' }} diff --git a/Gemfile b/Gemfile index d28e82f7..bdeaf236 100644 --- a/Gemfile +++ b/Gemfile @@ -2,65 +2,22 @@ source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } -activerecord_version = ENV.fetch('ACTIVERECORD_VERSION', '7') - -activerecord = - case activerecord_version - when '3.2' then '3.2.22' - when '4.0' then '4.0.13' - when '4.1' then '4.1.16' - when '4.2' then '4.2.11' - when '5.0' then '5.0.7' - when '5.1' then '5.1.7' - when '5.2' then '5.2.4' - when '6.0' then '6.0.3.4' - when '6.1' then '6.1.2' - end - -simplecov_version = - case RUBY_VERSION - when /\A2.[23]/ then '~> 0.17.1' - when /\A2.4/ then '~> 0.18.5' - else '~> 0.21.2' - end - group :test do - gem 'minitest', activerecord_version < '4.1' ? '~> 4.2' : '~> 5.0' + gem 'minitest' - gem 'simplecov', simplecov_version, require: false + gem 'simplecov', require: false - if activerecord - sqlite3 = - case activerecord - when /\A6\.(0|1)/, nil then '~> 1.4.0' - else '~> 1.3.0' - end - - gem 'sqlite3', sqlite3 - gem 'activerecord', activerecord, require: 'active_record' - end + gem 'sqlite3' + gem 'activerecord', require: 'active_record' end -pry_byebug_version = - case RUBY_VERSION - when /\A2.[23]/ then '3.6' - else '3.9' - end - -pry_version = - case RUBY_VERSION - when /\A2.2/ then '0.12.2' - when /\A2.3/ then '0.12.2' - else '0.13.1' - end - group :development, :test do - gem 'awesome_print', '~> 1.8' + gem 'awesome_print' - gem 'byebug', '~> 10.0', '>= 10.0.2' if RUBY_VERSION =~ /\A2.[23]/ + gem 'byebug' - gem 'pry', "~> #{pry_version}" - gem 'pry-byebug', "~> #{pry_byebug_version}" + gem 'pry' + gem 'pry-byebug' end # Specify your gem's dependencies in u-case.gemspec diff --git a/bin/prepare_coverage b/bin/prepare_coverage deleted file mode 100755 index 92f72171..00000000 --- a/bin/prepare_coverage +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true -# Borrowed from https://gist.github.com/qortex/7e7c49f3731391a91ee898336183acef - -# Temporary hack to get CodeClimate to work with SimpleCov 0.18 JSON format until issue is fixed -# upstream: https://github.com/codeclimate/test-reporter/issues/413 - -require "json" - -filename = "coverage/.resultset.json" -contents = JSON.parse(File.read(filename)) - -def remove_lines_key(obj) - case obj - when Hash - obj.transform_values do |val| - val.is_a?(Hash) && val.key?("lines") ? val["lines"] : remove_lines_key(val) - end - else - obj - end -end - -# overwrite -File.write(filename, JSON.generate(remove_lines_key(contents))) - -puts Dir['coverage/.*.json'] diff --git a/bin/test b/bin/test deleted file mode 100755 index f3e3b1d2..00000000 --- a/bin/test +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -e - -RUBY_V=$(ruby -v) - -function reset_gemfile_and_test { - rm Gemfile.lock - - eval "$1 bundle update" - eval "$1 ENABLE_TRANSITIONS=true bundle exec rake test" - eval "$1 ENABLE_TRANSITIONS=false bundle exec rake test" -} - -function test_with_activerecord { - reset_gemfile_and_test "ACTIVERECORD_VERSION=$1" -} - -RUBY_2_2345="ruby 2.[2345]." -RUBY_2_234="ruby 2.[234]." -RUBY_2_567="ruby 2.[567]." -RUBY_2_23="ruby 2.[23]." -RUBY_2_2="ruby 2.2." -RUBY_3_01="ruby 3.[01]." - -if [[ $RUBY_V =~ $RUBY_2_2345 ]]; then - if [[ $RUBY_V =~ $RUBY_2_234 ]]; then - reset_gemfile_and_test - fi - - if [[ $RUBY_V =~ $RUBY_2_2 ]]; then - test_with_activerecord "3.2" - fi - - if [[ $RUBY_V =~ $RUBY_2_23 ]]; then - test_with_activerecord "4.0" - test_with_activerecord "4.1" - test_with_activerecord "4.2" - fi - - test_with_activerecord "5.0" - test_with_activerecord "5.1" - test_with_activerecord "5.2" -fi - -if [[ $RUBY_V =~ $RUBY_2_567 ]] || [[ $RUBY_V =~ $RUBY_3_01 ]]; then - gem install bundler -v ">= 2" --no-doc - - reset_gemfile_and_test - - test_with_activerecord "6.0" - test_with_activerecord "6.1" -fi diff --git a/gemfiles/rails_5.2/Gemfile b/gemfiles/rails_5.2/Gemfile new file mode 100644 index 00000000..9c35e8ba --- /dev/null +++ b/gemfiles/rails_5.2/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +group :test do + gem 'minitest' + + gem 'simplecov', require: false + + gem 'sqlite3' + gem 'activerecord', '~> 5.2.0', require: 'active_record' +end + +group :development, :test do + gem 'awesome_print' + + gem 'byebug' + + gem 'pry' + gem 'pry-byebug' +end + +# Specify your gem's dependencies in u-case.gemspec +gemspec path: "../.." diff --git a/gemfiles/rails_6.0/Gemfile b/gemfiles/rails_6.0/Gemfile new file mode 100644 index 00000000..40f59aa3 --- /dev/null +++ b/gemfiles/rails_6.0/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +group :test do + gem 'minitest' + + gem 'simplecov', require: false + + gem 'sqlite3' + gem 'activerecord', '~> 6.0.0', require: 'active_record' +end + +group :development, :test do + gem 'awesome_print' + + gem 'byebug' + + gem 'pry' + gem 'pry-byebug' +end + +# Specify your gem's dependencies in u-case.gemspec +gemspec path: "../.." diff --git a/gemfiles/rails_6.1/Gemfile b/gemfiles/rails_6.1/Gemfile new file mode 100644 index 00000000..b3625846 --- /dev/null +++ b/gemfiles/rails_6.1/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +group :test do + gem 'minitest' + + gem 'simplecov', require: false + + gem 'sqlite3' + gem 'activerecord', '~> 6.1.0', require: 'active_record' +end + +group :development, :test do + gem 'awesome_print' + + gem 'byebug' + + gem 'pry' + gem 'pry-byebug' +end + +# Specify your gem's dependencies in u-case.gemspec +gemspec path: "../.." diff --git a/gemfiles/rails_7.0/Gemfile b/gemfiles/rails_7.0/Gemfile new file mode 100644 index 00000000..7f57ac5f --- /dev/null +++ b/gemfiles/rails_7.0/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +group :test do + gem 'minitest' + + gem 'simplecov', require: false + + gem 'sqlite3' + gem 'activerecord', '~> 7.0.0', require: 'active_record' +end + +group :development, :test do + gem 'awesome_print' + + gem 'byebug' + + gem 'pry' + gem 'pry-byebug' +end + +# Specify your gem's dependencies in u-case.gemspec +gemspec path: "../.." diff --git a/gemfiles/rails_7.1/Gemfile b/gemfiles/rails_7.1/Gemfile new file mode 100644 index 00000000..0c9ba8d1 --- /dev/null +++ b/gemfiles/rails_7.1/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +group :test do + gem 'minitest' + + gem 'simplecov', require: false + + gem 'sqlite3' + gem 'activerecord', '~> 7.1.0', require: 'active_record' +end + +group :development, :test do + gem 'awesome_print' + + gem 'byebug' + + gem 'pry' + gem 'pry-byebug' +end + +# Specify your gem's dependencies in u-case.gemspec +gemspec path: "../.." diff --git a/gemfiles/rails_edge/Gemfile b/gemfiles/rails_edge/Gemfile new file mode 100644 index 00000000..b8469b6f --- /dev/null +++ b/gemfiles/rails_edge/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +group :test do + gem 'minitest' + + gem 'simplecov', require: false + + gem 'sqlite3' + gem 'activerecord', git: "https://github.com/rails/rails", branch: "main", require: 'active_record' +end + +group :development, :test do + gem 'awesome_print' + + gem 'byebug' + + gem 'pry' + gem 'pry-byebug' +end + +# Specify your gem's dependencies in u-case.gemspec +gemspec path: "../.."