Skip to content

Commit

Permalink
Refactor gemfiles
Browse files Browse the repository at this point in the history
We have several gemfiles in which we have specific version requirements
for `activejob` and `activerecord`, for use in our CI matrix.

The current approach breaks on Ruby HEAD because it is detected as
specifying multiple versions/sources for those gems. Instead, this
refactors them to use an instance variable approach, similar to that
used in Shopify/maintenance_tasks.
  • Loading branch information
sambostock committed Nov 15, 2023
1 parent 742ee07 commit 1a1eb29
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ gemspec
gem "sidekiq"
gem "resque"

if defined?(@rails_gems_requirements) && @rails_gems_requirements
# We avoid the `gem "..."` syntax here so Dependabot doesn't try to update these gems.
[
"activejob",
"activerecord",
].each { |name| gem name, @rails_gems_requirements }
else
# gem "activejob" # Set in gemspec
gem "activerecord"
end

gem "mysql2", github: "brianmario/mysql2"
gem "globalid"
gem "i18n"
Expand Down
5 changes: 2 additions & 3 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

eval_gemfile "../Gemfile"
@rails_gems_requirements = "~> 5.2.0"

gem "activejob", "~> 5.2.0"
gem "activerecord", "~> 5.2.0"
eval_gemfile "../Gemfile"
5 changes: 2 additions & 3 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

eval_gemfile "../Gemfile"
@rails_gems_requirements = "~> 6.0.0"

gem "activejob", "~> 6.0.0"
gem "activerecord", "~> 6.0.0"
eval_gemfile "../Gemfile"
5 changes: 2 additions & 3 deletions gemfiles/rails_6_1.gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

@rails_gems_requirements = "~> 6.1.0"

eval_gemfile "../Gemfile"

if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new("3.1")
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
end

gem "activejob", "~> 6.1.0"
gem "activerecord", "~> 6.1.0"
5 changes: 2 additions & 3 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

eval_gemfile "../Gemfile"
@rails_gems_requirements = "~> 7.0.0"

gem "activejob", "~> 7.0.0"
gem "activerecord", "~> 7.0.0"
eval_gemfile "../Gemfile"
5 changes: 2 additions & 3 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

eval_gemfile "../Gemfile"
@rails_gems_requirements = { github: "rails/rails", branch: "main" }

gem "activejob", github: "rails/rails", branch: "main"
gem "activerecord", github: "rails/rails", branch: "main"
eval_gemfile "../Gemfile"
1 change: 0 additions & 1 deletion job-iteration.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ Gem::Specification.new do |spec|
spec.metadata["changelog_uri"] = "https://github.com/Shopify/job-iteration/blob/main/CHANGELOG.md"
spec.metadata["allowed_push_host"] = "https://rubygems.org"

spec.add_development_dependency("activerecord")
spec.add_dependency("activejob", ">= 5.2")
end

0 comments on commit 1a1eb29

Please sign in to comment.