Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specialize Rails7 Database setup on Heroku CI #1257

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Main (unreleased)

## v236 (2022/01/04)

* Fix deprecated rake tasks for Rails 7 on Heroku CI (https://github.com/heroku/heroku-buildpack-ruby/pull/1257)

## v235 (2022/01/03)

* Bundler 2.x is now 2.2.33 (https://github.com/heroku/heroku-buildpack-ruby/pull/1248)
Expand Down
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ namespace :buildpack do

changelog_md.write(contents.gsub("## Main (unreleased)", new_section))
end

version_rb = Pathname(__dir__).join("lib/language_pack/version.rb")
puts "Updating version.rb"
contents = version_rb.read.gsub(/BUILDPACK_VERSION = .*$/, %Q{BUILDPACK_VERSION = "#{deploy.next_version.to_s}"})
version_rb.write(contents)
end

desc "releases the next version of the buildpack"
Expand Down
2 changes: 1 addition & 1 deletion hatchet.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
- - "./repos/rails_versions/active_storage_non_local"
- 86dddf0127043abba1cb2890590a1d38f111edbd
- - "./repos/rails_versions/rails-jsbundling"
- 192a71e0931aa00724412521dcad4d1e1db2ec0f
- 34bd25cef7c09758b3e7763a5d4be6dc94364606
- - "./repos/rails_versions/rails3_default_ruby"
- a6b44db674c0d3538633989295e2cfd5e8e1ba0d
- - "./repos/rails_versions/rails42_default_ruby"
Expand Down
3 changes: 3 additions & 0 deletions lib/language_pack/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
module LanguagePack::Test
end

# Behavior changes for the test pack work by opening existing language_pack
# classes and over-writing their behavior to extend test functionality
require "language_pack/test/ruby"
require "language_pack/test/rails2"
require "language_pack/test/rails7"
4 changes: 2 additions & 2 deletions lib/language_pack/test/rails2.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#module LanguagePack::Test::Rails2
# Opens up the class of the Rails2 language pack and
# overwrites methods defined in `language_pack/test/ruby.rb`
class LanguagePack::Rails2
# sets up the profile.d script for this buildpack
def setup_profiled(ruby_layer_path: , gem_layer_path: )
Expand Down Expand Up @@ -51,7 +52,6 @@ def clear_db_test_tasks
end
end

private
def db_prepare_test_rake_tasks
schema_load = rake.task("db:schema:load_if_ruby")
structure_load = rake.task("db:structure:load_if_sql")
Expand Down
9 changes: 9 additions & 0 deletions lib/language_pack/test/rails7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Opens up the class of the Rails7 language pack and
# overwrites methods defined in `language_pack/test/ruby.rb` or `language_pack/test/rails2.rb`
class LanguagePack::Rails7
# Rails removed the db:schema:load_if_ruby and `db:structure:load_if_sql` tasks
# they've been replaced by `db:schema:load` instead
def db_prepare_test_rake_tasks
["db:schema:load", "db:migrate"].map {|name| rake.task(name) }
end
end
7 changes: 5 additions & 2 deletions lib/language_pack/test/ruby.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#module LanguagePack::Test::Ruby
# Opens up the class of the Ruby language pack and
# overwrites methods defined in `language_pack/ruby.rb`
#
# Other "test packs" futher extend this behavior by hooking into
# methods or over writing methods defined here.
class LanguagePack::Ruby
def compile
new_app?
Expand Down Expand Up @@ -26,7 +30,6 @@ def compile
super
end

private
def db_prepare_test_rake_tasks
["db:schema:load", "db:migrate"].map {|name| rake.task(name) }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module LanguagePack
class LanguagePack::Base
BUILDPACK_VERSION = "v234"
BUILDPACK_VERSION = "v236"
end
end
7 changes: 7 additions & 0 deletions spec/hatchet/rails7_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
end
end
end

it "Works on Heroku CI" do
Hatchet::Runner.new("rails-jsbundling").run_ci do |test_run|
expect(test_run.output).to match("db:schema:load")
expect(test_run.output).to match("db:migrate")
end
end
end