Sha256: 512c5fc07398d47760888f63213299336654e91af81704dc439fe006f59e6487

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

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

require "json"

def minor_versions(name, requirement)
  tuples, _errors = Gem::SpecFetcher.fetcher.search_for_dependency(Gem::Dependency.new(name, requirement))
  tuples.map { |tuple, _source| tuple.version.segments.first(2).join(".") }.uniq
end

ruby_activerecord_requirements = {
  "2.7" => ">= 6.0",
  "3.0" => ">= 6.0",
  "3.1" => ">= 6.0",
  "3.2" => ">= 6.0"
}

ruby_pg_requirements = {
  "2.7" => "> 0",
  "3.0" => "> 0",
  "3.1" => "> 0",
  "3.2" => ">= 1.3"
}

activerecord_pg_requirements = {
  "6.0" => [">= 0.18", "< 2.0"],
  "6.1" => "~> 1.1",
  "7.0" => "~> 1.1"
}

versions = ruby_activerecord_requirements.flat_map do |ruby_version, activerecord_requirement|
  minor_versions("activerecord", activerecord_requirement).flat_map do |activerecord_version|
    pg_requirement = [
      ruby_pg_requirements.fetch(ruby_version),
      activerecord_pg_requirements.fetch(activerecord_version)
    ].flatten

    minor_versions("pg", pg_requirement).map do |pg_version|
      {
        ruby: ruby_version,
        activerecord: activerecord_version,
        pg: pg_version
      }
    end
  end
end

matrix = { include: versions }

puts JSON.pretty_generate(matrix)

output_file = ENV.fetch("GITHUB_OUTPUT", false)
File.write output_file, "matrix=#{matrix.to_json}" if output_file

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg-aws_rds_iam-0.4.2 bin/version-matrix