Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Add Rails master appraisals in preparation for Rails 5 #1976

Merged
merged 5 commits into from
Mar 23, 2016

Conversation

maclover7
Copy link
Contributor

#1973

Also reorganized Appraisals to make it easier to understand

appraise "4.2.awsv1" do
gem "rails", "~> 4.2.0"
appraise "master.awsv1" do
gem 'rails', github: "rails/rails"
gem "aws-sdk", "~> 1.5"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to take this combination into account? When is AWS v1 end of life?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about v1 support (this would be another big breaking change deprecation), but I can look into this.

@tute
Copy link
Contributor

tute commented Sep 9, 2015

Thanks so much @maclover7! Seems like the red CI comes from rails#master? Should I restart the build (or you trigger it rebasing your commit on top of latest master)?

Thanks again!

@tute tute mentioned this pull request Sep 9, 2015
@maclover7
Copy link
Contributor Author

Pushed up change that should fix dependency resolution problems - hopefully we can see whether the test suite passes on master now.

@tute
Copy link
Contributor

tute commented Sep 9, 2015

Not sure about v1 support (this would be another big breaking change deprecation), but I can look into this.

I don't know how AWS works. But if people are moving on to v2, as most Rails apps moved to 4, then it could be plausible to say "paperclip 5 only with AWS v2". But to be fair the code is already written, and I wouldn't expect it to change much, so it might not be worth it if it will bring unhappy users.

@maclover7
Copy link
Contributor Author

If we are going to deprecate AWS v1 support, I'd say we should include deprecation warnings in the next release out the door, to give time to upgrade.

@tute
Copy link
Contributor

tute commented Sep 9, 2015

If we are going to deprecate AWS v1 support, I'd say we should include deprecation warnings in the next release out the door, to give time to upgrade.

👍 👏

@maclover7
Copy link
Contributor Author

Should I open up a ticket on rails/rails for that "syntax error" that's breaking the rails master travis build? https://travis-ci.org/thoughtbot/paperclip/jobs/79552598#L237 @tute

@tute
Copy link
Contributor

tute commented Sep 10, 2015

Should I open up a ticket on rails/rails for that "syntax error" that's breaking the rails master travis build? https://travis-ci.org/thoughtbot/paperclip/jobs/79552598#L237 @tute

It looks like that's Ruby >2 syntax. We should add an exception for Rails master/5 and Ruby 2 CI run (see for example https://github.com/doorkeeper-gem/doorkeeper/blob/master/.travis.yml#L16-L18).

@maclover7
Copy link
Contributor Author

@tute Can you check my .travis.yml syntax - updated it in last commit to try and stop 2.0 and rails master from running


matrix:
fast_finish: true
allow_failures:
- rvm: jruby-19mode
- rvm: rbx-2
exclude:
- gemfile: master.awsv1.gemfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add the gemfiles/ path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, i think that's what the problem is. will squash down all of my commits before merging in :P

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, i think that's what the problem is. will squash down all of my commits before merging in :P

Excellent, and rebase on top of latest master too. Thank you, @maclover7! 👏

@maclover7
Copy link
Contributor Author

Rebased and consolidated --> just for maintenance of the code, is there any way to streamline our gemfiles and appraisals? Getting very cluttered now by testing 4 versions of Rails and 3 versions of aws-sdk. cc @jyurek

@tute
Copy link
Contributor

tute commented Sep 25, 2015

I've been restarting CI but we always get the same timeout. Makes me think there's actually something wrong with either rails or our code?

@tute tute force-pushed the add-rails-master-appraisals branch from ba25c10 to 41a6c8e Compare November 12, 2015 03:25
@tute
Copy link
Contributor

tute commented Nov 12, 2015

Rebased your branch on top of latest master. Right now, master is red for some cucumber steps, so if we get those it's not related with changes in this branch.

That said, latest CI run had the following failure that we'll need to address:

/home/travis/build/thoughtbot/paperclip/spec/spec_helper.rb:11:in `require': cannot load such file -- activerecord-import (LoadError)

Thanks!

- gemfiles/4.2.awsv1.gemfile
- gemfiles/4.2.awsv2.0.gemfile
- gemfiles/4.2.awsv2.1.gemfile
- gemfiles/master.awsv1.gemfile
Copy link
Contributor

Choose a reason for hiding this comment

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

I so want to get rid of AWS V1. :|

@tute tute added this to the v5.0.0 milestone Nov 12, 2015
@maclover7 maclover7 mentioned this pull request Nov 12, 2015
9 tasks
@tute tute force-pushed the add-rails-master-appraisals branch from 41a6c8e to 8e4095f Compare November 17, 2015 04:56
@tute
Copy link
Contributor

tute commented Nov 18, 2015

This PR is back to "normal" failures, to be worked on.

@tute
Copy link
Contributor

tute commented Dec 22, 2015

@maclover7 will rebase your branch, and make it point to 5 beta1, à la doorkeeper-gem/doorkeeper#753, unless you'd rather do it yourself, or do it differently. Thanks!

@tute
Copy link
Contributor

tute commented Dec 22, 2015

Will start with smaller PRs removing from master unsupported versions of Rails (3.2 and 4.1), and AWS v1.

@maclover7
Copy link
Contributor Author

Rebased! Going to have a ton of time to work on this after tomorrow (yay school vacation!). Key stuff is to get out a 4.x release with deprecations, and then to move forward with 5.0.0, after Rails 5 is released.

@tute
Copy link
Contributor

tute commented Dec 22, 2015

That is great! You might want to rebase again after #2074, with smaller CI matrix.

I will now work on removing from master AWS v1 support.

- gemfiles/4.2.awsv1.gemfile
- gemfiles/4.2.awsv2.1.gemfile
- gemfiles/master.awsv2.0.gemfile
- gemfiles/master.awsv2.1.gemfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do master or 5.0.0.beta1?

@tute tute force-pushed the add-rails-master-appraisals branch 2 times, most recently from a80fc61 to 8016fcb Compare January 4, 2016 17:59
@tute
Copy link
Contributor

tute commented Jan 4, 2016

Did Rails 5 change Validators API? It looks like AttachmentContentTypeValidator's not option is failing.

Fixing spec/paperclip/validators_spec.rb will fix the others for Rails 5, and we can merge.

@tute
Copy link
Contributor

tute commented Jan 5, 2016

@sgrif: is the behavior described in #1976 (comment) an expected ActiveRecord change? Thank you.

@tute tute force-pushed the add-rails-master-appraisals branch 5 times, most recently from 1c0d262 to 22c522f Compare March 12, 2016 21:41
@tute
Copy link
Contributor

tute commented Mar 12, 2016

The reason specs fail in Rails 5 seem to be that this validation block never runs: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/validators.rb#L67-L69

send(:"before_#{attribute}_post_process", :if => if_clause, :unless => unless_clause) do |*args|
  validator_class.new(options.dup).validate(self)
end

I can't spot why that is.

@tute
Copy link
Contributor

tute commented Mar 12, 2016

@rafaelfranca can you spot if a change in Rails 5 around callbacks (aside from the new option ActiveSupport.halt_callback_chains_on_return_false) might be messing something up here? Thank you!

@rafaelfranca
Copy link
Contributor

Not that I'm aware. The only change I remember is the way we internally execute a callback but that also changes in Rails 4.2 so you would be able to see the same problem in 4.2 if it was caused by that.

@tute tute force-pushed the add-rails-master-appraisals branch 4 times, most recently from 1579de1 to 1c07805 Compare March 23, 2016 03:24
module Reporting
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')

Choose a reason for hiding this comment

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

Line is too long. [86/80]
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@tute
Copy link
Contributor

tute commented Mar 23, 2016

@kitop thank you very much for your help on this! I'd merge it as is, let me know if you'd like to change anything on the code or the commits before doing so.

maclover7 and others added 5 commits March 23, 2016 08:53
- Also bump Travis Ruby 2.2.x version to 2.2.4
`bundle exec rails -v` was taking seconds every time, making the test
suite run very slow. This changes the code to compare the version
against `ActiveRecord::VERSION`, which is going to be the same one as
`rails -v`, making it much, much faster.

Simplifies condition: we no longer support Rails < 4.2, so we test for
`>= "5.0"` or fallback to `4.2` branch.
Ref: rails/rails@2386daa

Specifically:

> Chains of callbacks defined **with** a `:terminator` option will
> maintain their existing behavior of halting as soon as a `before_`
> callback matches the terminator's expectation. For instance,
> ActiveModel's callbacks will still halt the chain when a `before_`
> callback returns `false`.

In terminator callbacks, the `result` value changed to be a lambda now.
This change reflects that, updating the terminator to compare the result
of the block to `false`.

Also:

* Removes Rails 4.1 branch (we don't support it anymore)
* Rewrite for legibility: change `unless` for `if`
Ref: rails/rails@481e49c

`silence_stream` was deprecated in Rails 4.2 and removed in Rails 5
because it was not thread safe. Paperclip is not running the tests in
threaded mode, it's safe to add the method back in a test support
module.
While working on this branch, Kito found that this test fails due to:

rails/rails@6ec8ba1#diff-fdcf8b65b5fb954372c6fe1ddf284c78R76

We are not yet sure if it's a bug in paperclip or in Rails itself. With
current `ActiveModel::Errors` implementation the following happens:

```
record.errors # => @messages = {}
record.errors.include?(:foo) # => false
record.errors # => @messages = { :foo => [] }
```

Which bit us in:
https://github.com/thoughtbot/paperclip/blob/69f18375333234b6f395300266e2612936bd242e/lib/paperclip/validators/attachment_file_name_validator.rb#L23

Another related Rails commit:
rails/rails@b97035d

I worked around the issue by changing what we assert in this spec. I am
still not sure that this is a bug in current Rails master.

cc @kitop for review
@tute tute force-pushed the add-rails-master-appraisals branch from 1c07805 to 799845e Compare March 23, 2016 12:53
@tute tute merged commit d97a6c6 into master Mar 23, 2016
@tute tute deleted the add-rails-master-appraisals branch March 23, 2016 12:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants