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

Rails 2, 3, and 4 LTS tests #1115

Merged
merged 5 commits into from
Jan 28, 2021
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
45 changes: 7 additions & 38 deletions hatchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
"ruby": [
"sharpstone/ruby_version_does_not_exist",
"sharpstone/cd_ruby",
"sharpstone/mri_187",
"sharpstone/mri_193_p547",
"sharpstone/ruby_193_jruby_173",
"sharpstone/ruby_193_jruby_176",
"sharpstone/ruby_193_jruby_1_7_27",
Expand All @@ -44,43 +42,16 @@
"sharpstone/mri_193",
"sharpstone/mri_200"
],
"rails2": [
"sharpstone/rails23_mri_193"
],
"rails3": [
"sharpstone/rails3_mri_193",
"sharpstone/railties3_mri_193",
"sharpstone/rails3_12factor",
"sharpstone/rails3_one_plugin",
"sharpstone/rails3_runtime_assets",
"sharpstone/rails3-fail-assets-compile",
"sharpstone/rails3-fail-rakefile"
],
"rails4": [
"sharpstone/rails4-manifest",
"sharpstone/rails3-to-4-no-bin",
"rails_versions": [
"sharpstone/rails_lts_23_default_ruby",
"sharpstone/rails3_default_ruby",
"sharpstone/rails4_windows_mri193",
"sharpstone/rails4-fail-assets-compile"
],
"rails41": [
"sharpstone/rails41_scaffold"
],
"rails42": [
"sharpstone/rails42_scaffold",
"sharpstone/rails42_sprockets3_manifest"
],
"rails5": [
"sharpstone/rails5"
],
"rails51": [
"schneems/rails51_webpacker"
],
"rails52": [
"sharpstone/rails42_default_ruby",
"sharpstone/rails5",
"schneems/rails51_webpacker",
"sharpstone/active_storage_non_local",
"sharpstone/active_storage_local",
"sharpstone/sprockets_asset_compile_true"
],
"rails6": [
"sharpstone/sprockets_asset_compile_true",
"sharpstone/rails6-basic"
],
"heroku": [
Expand All @@ -93,8 +64,6 @@
"sharpstone/rails5_ruby_schema_format",
"sharpstone/heroku-ci-json-example",
"sharpstone/rails5_sql_schema_format",
"sharpstone/rails_31_ruby_schema_format",
"sharpstone/rails_31_sql_schema_format",
"sharpstone/ruby_no_rails_test",
"sharpstone/activerecord_rake_tasks_does_not_exist",
"sharpstone/ci_fails_ruby_default_bundler"
Expand Down
62 changes: 16 additions & 46 deletions hatchet.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
- d76be86c66ae8f45ec611fb2c4d8eb3adac0ad4b
- - "./repos/ci/rails5_sql_schema_format"
- df48237c57f89bb3629937ae6b1d6af070100ed3
- - "./repos/ci/rails_31_ruby_schema_format"
- 76dacc65e0483c7c0b659504d8d56e6cfaee4bf1
- - "./repos/ci/rails_31_sql_schema_format"
- 540ec776eff3111ad9bb01af204c62725c94a11d
- - "./repos/ci/ruby_no_rails_test"
- 3916137106d59b008b67d738abe6a1438f8fbde6
- - "./repos/heroku/ruby-getting-started"
Expand All @@ -45,48 +41,26 @@
- 2e9ed455517c57b0dc953f54fbf9fef641c7aadb
- - "./repos/rack/mri_200"
- f9922cbd9c6f44fdded54912f66038db37cb4b8f
- - "./repos/rails2/rails23_mri_193"
- 557f7ba7a9347ebe0dd2038dda7e7a97b2582525
- - "./repos/rails3/rails3-fail-assets-compile"
- 0a2496b162fee373cbd484466abfcac1792510a1
- - "./repos/rails3/rails3-fail-rakefile"
- 85ee71f73a50067ca99163aa3bb23865a1df4c8f
- - "./repos/rails3/rails3_12factor"
- 9aebcf9adccd007e178f71aa49f85ee1a203fc4d
- - "./repos/rails3/rails3_mri_193"
- 88c5d0d067cfd11e4452633994a85b04627ae8c7
- - "./repos/rails3/rails3_one_plugin"
- 4f6ee83f2b977d4c939890ede9f11319ab8fd67c
- - "./repos/rails3/rails3_runtime_assets"
- 6f71613db2ba4e25c82d5986f43e419ed9b2e4b0
- - "./repos/rails3/railties3_mri_193"
- 8cc041cffb9f5635017aa118d16688491f794e91
- - "./repos/rails4/rails3-to-4-no-bin"
- 3fd6e84f5d8eaaadb6d95aeb1f367f62da28cc62
- - "./repos/rails4/rails4-fail-assets-compile"
- 7f65fbb04ca49be526906a1b0d9155cd24941b8e
- - "./repos/rails4/rails4-manifest"
- b700f4683f601f102ab4b65a7e5052e40f2b4def
- - "./repos/rails4/rails4_windows_mri193"
- - "./repos/rails_versions/active_storage_local"
- e2119af6ddd4bc21fda9bc7da6401e7aa256e38d
- - "./repos/rails_versions/active_storage_non_local"
- cba59b7559f1f806684b65654228d44fcda91a82
- - "./repos/rails_versions/rails3_default_ruby"
- a6b44db674c0d3538633989295e2cfd5e8e1ba0d
- - "./repos/rails_versions/rails42_default_ruby"
- dfa0f0133dafa62064968ea2efb6432f54350138
- - "./repos/rails_versions/rails4_windows_mri193"
- f4c7b6209835050468bbb87827acf652b8f4d8ce
- - "./repos/rails41/rails41_scaffold"
- d98e9ccee771b3745f1ab1936a697a05229392df
- - "./repos/rails42/rails42_scaffold"
- 5da1259651bf29b80af2bb27789422def02be5a8
- - "./repos/rails42/rails42_sprockets3_manifest"
- 4ea4b080599b4394bdf6753a7b392d9ed6b844a7
- - "./repos/rails5/rails5"
- - "./repos/rails_versions/rails5"
- 1680c5da829e03ffb9345187971a13e5109d86a6
- - "./repos/rails51/rails51_webpacker"
- - "./repos/rails_versions/rails51_webpacker"
- 75c5c4f21b1d88fc3b8edf60b3f871df3ad70208
- - "./repos/rails52/active_storage_local"
- e2119af6ddd4bc21fda9bc7da6401e7aa256e38d
- - "./repos/rails52/active_storage_non_local"
- cba59b7559f1f806684b65654228d44fcda91a82
- - "./repos/rails52/sprockets_asset_compile_true"
- 98c6675cf97059278709cf75030e28063e0228d2
- - "./repos/rails6/rails6-basic"
- - "./repos/rails_versions/rails6-basic"
- 3b404ac714a16877781b7bf69f1b8a308df6c92f
- - "./repos/rails_versions/rails_lts_23_default_ruby"
- 7178b2f97d3b2b3170b390d997dcb212dd52cd30
- - "./repos/rails_versions/sprockets_asset_compile_true"
- 98c6675cf97059278709cf75030e28063e0228d2
- - "./repos/rake/asset_precompile_fail"
- 16f7834331d6bb3fc5c284130b14eb1ff74d99d5
- - "./repos/rake/asset_precompile_not_found"
Expand All @@ -113,10 +87,6 @@
- f79860bc2866449fe065484f1542aaadd3f7cfd2
- - "./repos/ruby/libpq_connection_error"
- c211c245f09d8335a520cd7a0b5360897d4988eb
- - "./repos/ruby/mri_187"
- 43cecfacbedda64f09310a4408ce73c5dc3a9c44
- - "./repos/ruby/mri_193_p547"
- 39f4753b620f9ff427c547fd19f04c89f8441f6f
- - "./repos/ruby/ruby_193_bad_patch_cedar_14"
- 6948c1460c596f08c4642d616ae73a45dc0ae51a
- - "./repos/ruby/ruby_193_jruby_17161_jdk7"
Expand Down
6 changes: 0 additions & 6 deletions spec/hatchet/ci_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
end
end

it "Works with Rails 3.1 ruby schema apps" do
Hatchet::Runner.new("rails_31_ruby_schema_format").run_ci do |test_run|
expect(test_run.output).to match("db:schema:load completed")
end
end

it "Works with a vanilla ruby app" do
Hatchet::Runner.new("ruby_no_rails_test").run_ci do |test_run|
# Test no whitespace in front of output
Expand Down
14 changes: 10 additions & 4 deletions spec/hatchet/rails23_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
require_relative '../spec_helper'

describe "Rails 2.3.x" do
it "should deploy on ruby 1.9.3 on cedar-14" do
pending("Rails LTS support")
it "should deploy" do
skip("Need RAILS_LTS_CREDS env var set") unless ENV["RAILS_LTS_CREDS"]

Hatchet::Runner.new('rails23_mri_193', stack: "cedar-14").deploy do |app|
# assert deploy is successful
Hatchet::Runner.new('rails_lts_23_default_ruby', config: rails_lts_config).tap do |app|
app.before_deploy do
Pathname("Gemfile").write("ruby '2.7.2'", mode: "a")
end

app.deploy do
# assert deploy is successful
end
end
end
end
67 changes: 22 additions & 45 deletions spec/hatchet/rails3_spec.rb
Original file line number Diff line number Diff line change
@@ -1,51 +1,28 @@
require_relative '../spec_helper'

describe "Rails 3.x" do
it "should deploy on ruby 1.9.3" do
pending("Rails LTS license")

Hatchet::Runner.new("rails3_mri_193", stack: "cedar-14").deploy do |app, heroku|
expect(app.output).to include("Asset precompilation completed")

expect(app.output).to match("WARNING")
expect(app.output).to match("Add 'rails_12factor' gem to your Gemfile to skip plugin injection")

ls = app.run("ls vendor/plugins")
expect(ls).to match("rails3_serve_static_assets")
expect(ls).to match("rails_log_stdout")
end
end

it "should not have warnings when using the rails_12factor gem" do
Hatchet::Runner.new("rails3_12factor").deploy do |app, heroku|
expect(app.output).not_to match("Add 'rails_12factor' gem to your Gemfile to skip plugin injection")

# https://github.com/heroku/heroku-buildpack-ruby/issues/525
env = app.run("env")
expect(env).not_to match("RAILS_GROUPS")
end
end

it "should only display the correct plugin warning" do
Hatchet::Runner.new("rails3_one_plugin").deploy do |app, heroku|
expect(app.output).not_to match("rails_log_stdout")
expect(app.output).to match("rails3_serve_static_assets")
expect(app.output).to match("Add 'rails_12factor' gem to your Gemfile to skip plugin injection")
end
end


it "fails if rake tasks cannot be detected" do
Hatchet::Runner.new("rails3-fail-rakefile", allow_failure: true).deploy do |app|
expect(app.output).to include("raising so the rake task will not load")
expect(app).not_to be_deployed
end
end

it "fails compile if assets:precompile fails" do
Hatchet::Runner.new("rails3-fail-assets-compile", allow_failure: true).deploy do |app, heroku|
expect(app.output).to include("raising on assets:precompile on purpose")
expect(app).not_to be_deployed
it "should deploy and inject plugins" do
skip("Need RAILS_LTS_CREDS env var set") unless ENV["RAILS_LTS_CREDS"]

Hatchet::Runner.new("rails3_default_ruby", config: rails_lts_config).tap do |app|
app.before_deploy do
Pathname("Gemfile").write("ruby '2.7.2'", mode: "a")
end

app.deploy do
# Rails 3 doesn't work with Postgres 8+ out of the box and Rails
# LTS hasn't patched this yet. We're skipping asset compilation for now
# by deleting the Rakefile
#
# expect(app.output).to include("Asset precompilation completed")

expect(app.output).to match("WARNING")
expect(app.output).to match("Add 'rails_12factor' gem to your Gemfile to skip plugin injection")

ls = app.run("ls vendor/plugins")
expect(ls).to match("rails3_serve_static_assets")
expect(ls).to match("rails_log_stdout")
end
end
end
end
94 changes: 32 additions & 62 deletions spec/hatchet/rails4_spec.rb
Original file line number Diff line number Diff line change
@@ -1,81 +1,51 @@
require_relative '../spec_helper'

describe "Rails 4.x" do
it "set RAILS_SERVE_STATIC_FILES" do
Hatchet::Runner.new("rails42_scaffold").deploy do |app, heroku|
output = app.run("rails runner 'puts ENV[%Q{RAILS_SERVE_STATIC_FILES}].present?'")
expect(output).to match(/true/)
end
end

it "should be able to run a migration without heroku specific database.yml" do
Hatchet::Runner.new("rails41_scaffold").deploy do |app, heroku|
expect(app.output).not_to include("Writing config/database.yml to read from DATABASE_URL")
expect(app.run("rake db:migrate")).to include("20140218165801 CreatePeople")
end
end

it "should not overwrite existing files with cached files" do
string = SecureRandom.hex(13)
new_string = SecureRandom.hex(13)
skip("Need RAILS_LTS_CREDS env var set") unless ENV["RAILS_LTS_CREDS"]

Hatchet::Runner.new("rails41_scaffold").deploy do |app, heroku|
# First Deploy
run!(%Q{mkdir public/assets})
run!(%Q{echo #{string} > public/assets/file.txt})
run!(%Q{git add -A; git commit -m 'adding file.txt'})
app.push!
Hatchet::Runner.new("rails42_default_ruby", config: rails_lts_config).tap do |app|
app.before_deploy do
Pathname("Gemfile").write("ruby '2.7.2'", mode: "a")
end
app.deploy do
# it Don't over-write database.yml
expect(app.output).not_to include("Writing config/database.yml to read from DATABASE_URL")

# Second Deploy
run!(%Q{echo #{new_string} > public/assets/file.txt})
run!(%Q{git add -A; git commit -m 'updating file.txt'})
app.push!

# Asserts
result = app.run('cat public/assets/file.txt')
expect(result).not_to match(string)
expect(result).to match(new_string)
# it sets RAILS_SERVE_STATIC_FILES env var
output = app.run("rails runner 'puts ENV[%Q{RAILS_SERVE_STATIC_FILES}].present?'")
expect(output).to match(/true/)
end
end
end

it "should detect rails successfully" do
Hatchet::App.new('rails4-manifest').in_directory_fork do
expect(LanguagePack::Rails4.use?).to eq(true)
end
Hatchet::App.new('rails4-manifest').in_directory_fork do
expect(LanguagePack::Rails3.use?).to eq(false)
end
end
it "should skip asset compilation when deployed with NEW manifest file" do
skip("Need RAILS_LTS_CREDS env var set") unless ENV["RAILS_LTS_CREDS"]

it "should skip asset compilation when deployed with manifest file" do
Hatchet::Runner.new("rails4-manifest").deploy do |app, heroku|
expect(app.output).to include("Detected manifest file, assuming assets were compiled locally")
expect(app.output).not_to match("Include 'rails_12factor' gem to enable all platform features")
end
end
Hatchet::Runner.new("rails42_default_ruby", config: rails_lts_config).tap do |app|
app.before_deploy do
Pathname("Gemfile").write("ruby '2.7.2'", mode: "a")
Pathname("public/assets/manifest-ccf61eade4793995271564a4767ce6b6.json").tap {|p| p.dirname.mkpath; FileUtils.touch(p) }
end

it "detects new manifest file (sprockets 3.x: .sprockets-manifest-<digest>.json) Rails 4.2" do
Hatchet::Runner.new("rails42_sprockets3_manifest").deploy do |app, heroku|
expect(app.output).to include("Detected manifest file, assuming assets were compiled locally")
app.deploy do
expect(app.output).to include("Detected manifest file, assuming assets were compiled locally")
end
end
end

it "upgraded from 3 to 4.2 missing ./bin still works" do
Hatchet::Runner.new("rails3-to-4-no-bin").deploy do |app, heroku|
expect(app.output).to include("Asset precompilation completed")
it "should skip asset compilation when deployed with OLD manifest file" do
skip("Need RAILS_LTS_CREDS env var set") unless ENV["RAILS_LTS_CREDS"]

expect(app.output).to match("WARNING")
expect(app.output).to match("Include 'rails_12factor' gem to enable all platform features")

output = app.run("rails runner 'puts %Q{hello} + %Q{world}'")
expect(output).to match('helloworld')
end
end
Hatchet::Runner.new("rails42_default_ruby", config: rails_lts_config).tap do |app|
app.before_deploy do
Pathname("Gemfile").write("ruby '2.7.2'", mode: "a")
Pathname("public/assets/.sprockets-manifest-040763ccc5036260c52c6adcf77d73f7.json").tap {|p| p.dirname.mkpath; FileUtils.touch(p) }
end

it "fails compile if assets:precompile fails rails 4.2" do
Hatchet::Runner.new("rails4-fail-assets-compile", allow_failure: true).deploy do |app, heroku|
expect(app.output).to include("raising on assets:precompile on purpose")
expect(app).not_to be_deployed
app.deploy do
expect(app.output).to include("Detected manifest file, assuming assets were compiled locally")
end
end
end
end
6 changes: 0 additions & 6 deletions spec/helpers/bundler_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ def wrapper.topic(*args); end # Silence output in tests
end
end

it "handles MRI patchlevel gemfiles" do
Hatchet::App.new("mri_193_p547").in_directory_fork do |dir|
expect(@bundler.ruby_version).to eq("ruby-1.9.3-p547")
end
end

it "handles app with output in their Gemfile" do
Hatchet::App.new("problem_gemfile_version").in_directory_fork do |dir|
run!(%{echo '\nputs "some output"\n' >> Gemfile})
Expand Down
Loading