Skip to content

Fix broken CI #562

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

Merged
merged 2 commits into from
Jul 18, 2018
Merged

Fix broken CI #562

merged 2 commits into from
Jul 18, 2018

Conversation

mtsmfm
Copy link
Contributor

@mtsmfm mtsmfm commented Jun 2, 2018

Current our CI keeps failing.

1. Extend timeout

For some reason, app.run spring_test_command may take 100+ seconds.

`bundle check || bundle update --retry=2`	107.863471355
`bin/rake test /home/travis/build/mtsmfm/spring-debug/test/apps/tmp/test/controllers/posts_controller_test.rb`	105.624732034
`gem install activesupport --version '4.2.10'`	22.66985453
`bin/rails runner 'load Rails.root.join("script.rb")'`	11.518353908
`bin/rake test /home/travis/build/mtsmfm/spring-debug/test/apps/tmp/test/controllers/posts_controller_test.rb`	6.040077579
`bundle exec rails g scaffold post title:string`	4.525084902

https://travis-ci.org/mtsmfm/spring-debug/jobs/404996066

I got above result by applying the following patch:

diff --git a/lib/spring/test/application.rb b/lib/spring/test/application.rb
index 9a00618..93f129e 100644
--- a/lib/spring/test/application.rb
+++ b/lib/spring/test/application.rb
@@ -119,6 +119,8 @@ module Spring
         puts dump_streams(command, output) if ENV["SPRING_DEBUG"]

         @times << (Time.now - start_time) if @times
+        $times ||= []
+        $times << {command: command.to_s, time: Time.now - start_time}

         output.merge(status: status, command: command)
       rescue Timeout::Error
diff --git a/test/acceptance_test.rb b/test/acceptance_test.rb
index 665aff9..c24e82e 100644
--- a/test/acceptance_test.rb
+++ b/test/acceptance_test.rb
@@ -2,3 +2,11 @@ require_relative "helper"

 class AcceptanceTest < Spring::Test::AcceptanceTest
 end
+
+Minitest.after_run do
+  puts ?- * 100
+
+  $times.sort_by {|time| - time[:time] }.each do |time|
+    puts "`#{time[:command]}`\t#{time[:time]}"
+  end
+end

2. Use specific rake version to fix Gem::InstallError

12.2.1 is the last version which supports ruby 1.9.

  1) Error:
AcceptanceTest#test_binstub_upgrade_with_old_binstub:
RuntimeError: command failed
$ bundle check || bundle update --retry=2
--- stdout ---
Bundler can't satisfy your Gemfile's dependencies.
Install missing gems with `bundle install`.
Fetching gem metadata from http://rubygems.org/...............
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies....
Fetching rake 12.3.1
Installing rake 12.3.1
Gem::InstallError: rake requires Ruby version >= 2.0.0.
An error occurred while installing rake (12.3.1), and Bundler cannot continue.
Make sure that `gem install rake -v '12.3.1' --source 'http://rubygems.org/'`
succeeds before bundling.

https://travis-ci.org/mtsmfm/spring-debug/jobs/404541780

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@mtsmfm
Copy link
Contributor Author

mtsmfm commented Jun 2, 2018

This CI still failed but my forked version finary passed after few times restarting 😵
https://travis-ci.org/mtsmfm/spring/builds/387032597

@mtsmfm mtsmfm changed the title Fix broken CI [WIP] Fix broken CI Jun 18, 2018
mtsmfm added 2 commits July 18, 2018 02:36
For some reason, `app.run spring_test_command` may take 100+ seconds.

```
`bundle check || bundle update --retry=2`	107.863471355
`bin/rake test /home/travis/build/mtsmfm/spring-debug/test/apps/tmp/test/controllers/posts_controller_test.rb`	105.624732034
`gem install activesupport --version '4.2.10'`	22.66985453
`bin/rails runner 'load Rails.root.join("script.rb")'`	11.518353908
`bin/rake test /home/travis/build/mtsmfm/spring-debug/test/apps/tmp/test/controllers/posts_controller_test.rb`	6.040077579
`bundle exec rails g scaffold post title:string`	4.525084902
```

https://travis-ci.org/mtsmfm/spring-debug/jobs/404996066

I got above result by applying the following patch:

```diff
diff --git a/lib/spring/test/application.rb b/lib/spring/test/application.rb
index 9a00618..93f129e 100644
--- a/lib/spring/test/application.rb
+++ b/lib/spring/test/application.rb
@@ -119,6 +119,8 @@ module Spring
         puts dump_streams(command, output) if ENV["SPRING_DEBUG"]

         @times << (Time.now - start_time) if @times
+        $times ||= []
+        $times << {command: command.to_s, time: Time.now - start_time}

         output.merge(status: status, command: command)
       rescue Timeout::Error
diff --git a/test/acceptance_test.rb b/test/acceptance_test.rb
index 665aff9..c24e82e 100644
--- a/test/acceptance_test.rb
+++ b/test/acceptance_test.rb
@@ -2,3 +2,11 @@ require_relative "helper"

 class AcceptanceTest < Spring::Test::AcceptanceTest
 end
+
+Minitest.after_run do
+  puts ?- * 100
+
+  $times.sort_by {|time| - time[:time] }.each do |time|
+    puts "`#{time[:command]}`\t#{time[:time]}"
+  end
+end
```
12.2.1 is the last version which supports ruby 1.9.

```
  1) Error:
AcceptanceTest#test_binstub_upgrade_with_old_binstub:
RuntimeError: command failed
$ bundle check || bundle update --retry=2
--- stdout ---
Bundler can't satisfy your Gemfile's dependencies.
Install missing gems with `bundle install`.
Fetching gem metadata from http://rubygems.org/...............
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies....
Fetching rake 12.3.1
Installing rake 12.3.1
Gem::InstallError: rake requires Ruby version >= 2.0.0.
An error occurred while installing rake (12.3.1), and Bundler cannot continue.
Make sure that `gem install rake -v '12.3.1' --source 'http://rubygems.org/'`
succeeds before bundling.
```

https://travis-ci.org/mtsmfm/spring-debug/jobs/404541780
@mtsmfm mtsmfm changed the title [WIP] Fix broken CI Fix broken CI Jul 18, 2018
@mtsmfm
Copy link
Contributor Author

mtsmfm commented Jul 18, 2018

Now it's green 💚
@rafaelfranca Can you review?

@matthewd
Copy link
Member

🙇🙇🙇

@matthewd matthewd merged commit c034d2d into rails:master Jul 18, 2018
@mtsmfm mtsmfm deleted the fix-broken-ci branch July 18, 2018 04:38
@mtsmfm
Copy link
Contributor Author

mtsmfm commented Jul 18, 2018

@matthewd Thanks 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants