Skip to content

Commit

Permalink
Fix tests to work with sharpstone/default_ruby (#1527)
Browse files Browse the repository at this point in the history
* Update bundler version for jruby app

Fixes:

```
Hatchet::App::FailedDeployError Could not deploy 'hatchet-t-741ea26fdf' (default_ruby) using 'Hatchet::GitApp' at path: './repos/rack/default_ruby'
if this was expected add `allow_failure: true` to your deploy hash.
Buildpack: nil
Repo: https://git.heroku.com/hatchet-t-741ea26fdf.git
output:
remote: Updated 5 paths from 3dac5f9
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: https://github.com/heroku/heroku-buildpack-ruby#schneems/ci-queue-dec3
remote: -----> Ruby app detected
remote:
remote:        ## Warning: Your app needs java
remote:
remote:        The Ruby buildpack determined your app needs java installed
remote:        we recommend you add the jvm buildpack to your application:
remote:
remote:          $ heroku buildpacks:add heroku/jvm --index=1
remote:
remote: -----> Installing Java
remote:
remote: -----> Downloading Buildpack: heroku/jvm
remote: -----> Detected Framework: JVM Common
remote:
remote:  !     WARNING: No OpenJDK version specified
remote:        Your application does not explicitly specify an OpenJDK
remote:        version. OpenJDK 1.8 will be installed.
remote:
remote:        This default version will change at some point. Your
remote:        application might fail to build with the new version. We
remote:        recommend explicitly setting the required OpenJDK version for
remote:        your application.
remote:
remote:        To set the OpenJDK version, add or edit the system.properties
remote:        file in the root directory of your application to contain:
remote:
remote:        java.runtime.version = 1.8
remote:
remote:
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Installing bundler 1.17.3
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rack
remote: -----> Using Ruby version: ruby-2.5.7-jruby-9.2.13.0
remote: -----> Installing dependencies using bundler 1.17.3
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE=1 bundle install -j4
remote:        You are trying to install in deployment mode after changing
remote:        your Gemfile. Run `bundle install` elsewhere and add the
remote:        updated Gemfile.lock to version control.
remote:
remote:        If this is a development machine, remove the /tmp/build_3b0d62e8/Gemfile freeze
remote:        by running `bundle install --no-deployment`.
remote:
remote:        Bundler is unlocking ruby
remote:
remote:        You have added to the Gemfile:
remote:        * webrick
remote:        Bundler Output: You are trying to install in deployment mode after changing
remote:        your Gemfile. Run `bundle install` elsewhere and add the
remote:        updated Gemfile.lock to version control.
remote:
remote:        If this is a development machine, remove the /tmp/build_3b0d62e8/Gemfile freeze
remote:        by running `bundle install --no-deployment`.
remote:
remote:        Bundler is unlocking ruby
remote:
remote:        You have added to the Gemfile:
remote:        * webrick
remote:
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: df7a92f56ea636831f28033356791f2ba6ba0ef0
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version df7a92f56ea636831f28033356791f2ba6ba0ef0
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !	Push rejected to hatchet-t-741ea26fdf.
remote:
To https://git.heroku.com/hatchet-t-741ea26fdf.git
 ! [remote rejected] HEAD -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hatchet-t-741ea26fdf.git'
  /app/vendor/bundle/ruby/3.1.0/gems/heroku_hatchet-8.0.4/lib/hatchet/git_app.rb:36:in `git_push_heroku_yall'
  /app/vendor/bundle/ruby/3.1.0/gems/heroku_hatchet-8.0.4/lib/hatchet/git_app.rb:13:in `block in push_without_retry!'
  /app/vendor/bundle/ruby/3.1.0/gems/heroku_hatchet-8.0.4/lib/hatchet/shell_throttle.rb:28:in `block (2 levels) in call'
  /app/vendor/bundle/ruby/3.1.0/gems/heroku_hatchet-8.0.4/lib/hatchet/shell_throttle.rb:27:in `catch'
  /app/vendor/bundle/ruby/3.1.0/gems/heroku_hatchet-8.0.4/lib/hatchet/shell_throttle.rb:27:in `block in call'
```

https://dashboard.heroku.com/pipelines/ac057663-170b-4bdd-99d0-87560eb3a570/tests/2165

* Update jruby version for bundler support

```
       remote: -----> Installing dependencies using bundler 2.5.6
       remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       remote:        NoMethodError: undefined method `union' for ["BUNDLE_JOBS"]:Array
       remote:                               all at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/settings.rb:169
       remote:                            report at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/env.rb:20
       remote:          request_issue_report_for at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:71
       remote:                         log_error at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:50
       remote:              with_friendly_errors at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:123
       remote:                            <main> at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/exe/bundle:20
       remote:                              load at org/jruby/RubyKernel.java:1009
       remote:                            <main> at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/bin/bundle:25
       remote:        Bundler Output: NoMethodError: undefined method `union' for ["BUNDLE_JOBS"]:Array
       remote:                               all at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/settings.rb:169
       remote:                            report at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/env.rb:20
       remote:          request_issue_report_for at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:71
       remote:                         log_error at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:50
       remote:              with_friendly_errors at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:123
       remote:                            <main> at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/gems/bundler-2.5.6/exe/bundle:20
       remote:                              load at org/jruby/RubyKernel.java:1009
       remote:                            <main> at /tmp/build_0e08ea51/vendor/bundle/jruby/2.5.0/bin/bundle:25
```

* Update test to not be on deprecated stack

* Update gem versions

* Inspect ruby version instead of jar file

From https://github.com/heroku/heroku-buildpack-java/blob/b3c51f94de6a43bc656b777bc84ef2a9451371aa/test/spec/java_spec.rb#L78

> OpenJDK versions > 9 do not have the jre/lib/ext directory where we drop the pgconfig.jar

This test was added by Joe in 248b30a later I moved to not having a separate track for installing JVM 648a149 so I removed the logic for installing a pgconfig.jar and relied on the buildpack. According to the JVM buildpack it's no longer in this updated version.

It seems the original PR was using this to test that installation logic. While we no longer need to do that (as the logic is part of the `heroku/jvm` buildpack) I wanted to preserve calling a `heroku run` to assert something about the dyno that would indicate that jruby was installed as we expect.
  • Loading branch information
schneems authored Dec 5, 2024
1 parent bfb911a commit b1c482c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions spec/hatchet/rubies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,30 @@
end

describe "Ruby versions" do
it "should deploy jdk on heroku-20" do
Hatchet::Runner.new("default_ruby", stack: "heroku-20").tap do |app|
it "should deploy jdk on heroku-24" do
Hatchet::Runner.new("default_ruby", stack: "heroku-24").tap do |app|
app.before_deploy do |app|
Pathname("Gemfile.lock").write(<<~EOM)
GEM
remote: https://rubygems.org/
specs:
rack (2.2.2)
rake (13.0.1)
rack (3.1.8)
rake (13.2.1)
webrick (1.9.1)
PLATFORMS
java
DEPENDENCIES
rack
rake
webrick
RUBY VERSION
ruby 2.5.7p0 (jruby 9.2.13.0)
ruby 3.1.4p0 (jruby 9.4.8.0)
BUNDLED WITH
2.5.23
EOM

Pathname("Rakefile").write(<<~'EOM')
Expand All @@ -50,7 +54,7 @@
app.push!
expect(app.output).to match("JRUBY_OPTS is: --dev")

expect(app.run("ls .jdk/jre/lib/ext/")).to match("pgconfig.jar")
expect(app.run("ruby -v")).to match("jruby")
end
end
end
Expand Down

0 comments on commit b1c482c

Please sign in to comment.