Sha256: 68f80af7dd8733da81ade2750698f4f6f53975723bde6d1d5527792cad782768

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "English"
require "yaml"

active_record_versions = %w[6.1.7.2 6.0.6]
database_adapters = %w[mysql postgresql sqlite3]

class Matrix
  def initialize(active_record_versions, database_adapters)
    @active_record_versions = active_record_versions
    @database_adapters = database_adapters
    @exit_status_code = 0
  end

  def run
    original_ar_version = `bundle show activerecord`.split("-").last.strip
    @active_record_versions.each do |ar_version|
      run_with_active_record_version(ar_version)
    end
    puts "----> Reverting back to original ActiveRecord version (#{original_ar_version})"
    cmd("ACTIVE_RECORD_VERSION=#{original_ar_version} bundle update")

    exit(@exit_status_code) unless @exit_status_code.zero?
  end

  private

  def cmd(cmd)
    system(cmd)
    @exit_status_code = $CHILD_STATUS.exitstatus unless $CHILD_STATUS.success?
  end

  def run_with_active_record_version(ar_version)
    puts "----> Switching ActiveRecord to version #{ar_version}"
    cmd("ACTIVE_RECORD_VERSION=#{ar_version} bundle update")

    @database_adapters.each do |adapter|
      puts "----> Running tests with ActiveRecord #{ar_version} and #{adapter} adapter"
      cmd("DATABASE_ADAPTER=#{adapter} ACTIVE_RECORD_VERSION=#{ar_version} bundle exec rake test")
    end
  end
end

Matrix.new(active_record_versions.flatten.uniq, database_adapters.uniq).run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-cte-0.4.0 bin/test
activerecord-cte-0.3.0 bin/test