Skip to content

Update Spring to 3.1.1 - #51022

Merged
Hamms merged 2 commits into
stagingfrom
spring-3.1.1
Apr 10, 2023
Merged

Update Spring to 3.1.1#51022
Hamms merged 2 commits into
stagingfrom
spring-3.1.1

Conversation

@Hamms

@Hamms Hamms commented Mar 29, 2023

Copy link
Copy Markdown
Contributor

To pick up full support for Ruby 3.x, added in that version.

The primary breaking change since 2.0.1 is the removal of support for versions of Ruby older than 2.5

Links

https://github.com/rails/spring/blob/main/CHANGELOG.md#311

Testing story

Tested locally; both that this version of Spring fixes the issues we otherwise run into on Ruby 3, and that it works as expected in Ruby 2

@Hamms Hamms added the Ruby Update Everything related to work to update the version of Ruby our codebase runs on label Mar 29, 2023
@Hamms Hamms changed the title update Spring to 3.1.1 Update Spring to 3.1.1 Apr 6, 2023
@Hamms
Hamms marked this pull request as ready for review April 6, 2023 20:26
@Hamms
Hamms requested review from a team April 6, 2023 20:26

@davidsbailey davidsbailey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-04-06 at 1 55 05 PM

any insights into what this changelog entry means? not blocking, just curious since I like to use DISABLE_SPRING=1 when running bin/dashboard-server

@davidsbailey

Copy link
Copy Markdown
Member

apologies, I'm going to attempt to answer my own question, but please feel free to correct me if I am mistaken -- it looks like this means that cache_classes may be required when running with spring 3+: rails/spring#652

this seems fine for the normal developer case, but could possibly be worth keeping in mind if you had to run locally without cache_classes for some reason, in which case you might need to disable spring?

in any case, no concerns with merging.

@Hamms

Hamms commented Apr 6, 2023

Copy link
Copy Markdown
Contributor Author

Oh, good callout, thanks! I had glanced at that change, but only to verify that it specifically wants us to set config.cache_classes = false, which we indeed do in development:

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

However, I failed to realize that we're also using Spring in the test environment, and there we have the value set to true:

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

Tests still passed, but their documentation explicitly calls out that it's important this be false in the test environment, so I think I have some more investigation to do.

@Hamms

Hamms commented Apr 10, 2023

Copy link
Copy Markdown
Contributor Author

Okay, after some investigation it turns out that the reason they recommend cache_classes = false in the test environment is because otherwise, Spring won't run in the test environment. So it's possible that by following their recommendation we could decrease the time it takes our tests to execute, but unfortunately doing so also causes some tests to fail.

Either way, I think the question of whether or not we want to enable the class cache in the test environment can be discussed independently of this version bump, so I'm going to set it down for now (at least, until the time comes to update Rails to 7.0).

@sureshc sureshc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still going to have to manually kill spring a few times a day, right? 😂

@Hamms

Hamms commented Apr 10, 2023

Copy link
Copy Markdown
Contributor Author

Probably, yeah 🙃

@Hamms
Hamms merged commit 7f0046d into staging Apr 10, 2023
@Hamms
Hamms deleted the spring-3.1.1 branch April 10, 2023 21:18
@davidsbailey

Copy link
Copy Markdown
Member

thanks for digging into this, @Hamms! one more question to check my understanding:

the reason they recommend cache_classes = false in the test environment is because otherwise, Spring won't run in the test environment

Can you help me understand what impact this will have on running dashboard unit tests locally -- since we are still going to have cache_classes = true in test, does this mean that bundle exec spring testunit ../path/to/my/test will stop working for developers?

@Hamms

Hamms commented Apr 10, 2023

Copy link
Copy Markdown
Contributor Author

This PR isn't making any changes to our configuration: cache_classes will remain false in test as it has been, and we will continue to not gain any benefits from Spring in that environment until we do change that.

@davidsbailey

Copy link
Copy Markdown
Member

@Hamms I think we may still have a problem here. would you mind double checking what I am seeing?

  1. bundle exec spring testunit no longer working locally after pulling latest staging:
Dave-MBP:~/src/cdo/dashboard (staging)$ bundle exec spring testunit test/models/curriculum_reference_test.rb
/Users/dsb/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/spring-3.1.1/lib/spring/application.rb:101:in `block in preload': Spring reloads, and therefore needs the application to have reloading enabled.
Please, set config.cache_classes to false in config/environments/test.rb.
  1. cache_classes appears to be true in test:
    config.cache_classes = true

    Screenshot 2023-04-10 at 2 23 00 PM

@Hamms

Hamms commented Apr 10, 2023

Copy link
Copy Markdown
Contributor Author

Oh, correct, I had the values backwards in my head when I was writing that comment; I meant cache_classes will remain true in test as it has been. You're right that running local tests individually with sprint testunit is no longer working, though. We could recommend developers run individual tests with ruby -Itest instead, but given that we'll have to update this eventually for Rails 7.0 anyway, perhaps we should just figure out why flipping this value breaks tests and get it working now.

@Hamms Hamms mentioned this pull request Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ruby Update Everything related to work to update the version of Ruby our codebase runs on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants