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
Update for new Ruby and Rails versions #499
Conversation
@serene are you still the maintainer? I ran all the tests locally in all version combinations so I could make sure the deprecations were fixed. Once Travis runs, we should be able to see whether the config changes worked. |
02b9d07
to
63f4222
Compare
Since Ruby 3.1.0 is out now, I updated the PR to include it in its tests. The tests pass locally with no warnings. |
I will add this to my list to review, but if others can put some eyes on it as well, I'd really appreciate it! |
@@ -38,11 +42,11 @@ def to_s | |||
private | |||
|
|||
def shell_safe_url | |||
url_needs_escaping? ? URI::escape(@source) : @source | |||
url_needs_escaping? ? URI::DEFAULT_PARSER.escape(@source) : @source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a direct fix of the URI.escape
deprecation, and has the same exact behavior, but my main concern is that I don't think this is the right escaping method.
URI.escape
escapes a string for use in a URI as a query value. However, in this case, the string is being escaped for use in a shell command parameter, which doesn't really have the same requirements. For one thing, the percent-encoding that URI.escape
generates might conflict with the %var
environment variable syntax on Windows. There might be some other issues, but I haven't taken the time to check.
The change here has no effect on the existing behavior (except getting rid of the deprecation message), so it's probably the best to do here. However, in the long run, it's probably best to change to a more appropriate escaping method (in a separate PR).
I notice that the Travis CI tests didn't run. Should we set up Github Actions tests? |
@BrianHawley if that's something you'd like to take on, that would be really great! Maybe as a separate PR? |
@serene yes, preferably as a separate PR. For one thing, I haven't done that before, so I'd have to take time to learn how :) |
I've been using a patched version of pdfkit with these changes for a month (used vendorer to automatically generate the patched version). Are we going to merge this soon and release a new version, so I can switch back to the regular gem? |
@@ -6,13 +8,15 @@ | |||
add_filter 'spec/' | |||
end | |||
|
|||
Warning[:deprecated] = true if defined?(Warning.[]=) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR @BrianHawley
What is the use of this line about deprecated ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes Ruby deprecation warnings show up while running tests. I used those warnings to determine and fix any future compatibility issues, when I was running the tests locally against all supported versions. It's a good trick I use at work as well. The defined?(Warning.[]=)
guard is because it only applies to Ruby 2.7+.
Seems really nice, I did also use this version without any issues ! |
This pull request has been marked as stale and will be automatically closed. |
We are also using this version without any issues. Can't it be merged and released? |
I'm a little concerned that the build didn't run on this branch and merging it could cause issues for others. |
@serene is it possible that this repo had not migrated to travis-ci.com? https://blog.travis-ci.com/2021-05-07-orgshutdown |
@BrianHawley Can you pull in main to get the Github actions changes? |
@serene I pushed up a rebased version with the same test matrix changes applied to the Github Actions tests. The workflow needs approval before the tests will run. |
Cool, looks like the exclusions worked properly. Looks like there was an internal error in one of the 2.5.9 steps that didn't affect the other 2.5.9 steps, and it's GA code that runs before the other parts of the matrix, so it seems to just be flaky. I don't know the GA capabilities well enough, but is there a way to rerun a step? I just pushed up a useless commit to trigger the tests again. |
OK, that's not flaky. Let me check if another exclusion is needed. |
Should we even be supporting 2.5 anymore? |
I don't have a problem with leaving 2.5 support there. I mean, I don't use it, but others might need to. I'd rather keep it there long enough to figure out what the problem was. That failure was uninformative. |
@BrianHawley I sent a PR to your repo with the exclusions. It ran fine on my build. |
@leonyip I already made those exclusions, but I appreciate the PR. Still, it's not working in one case (which your PR also includes) with an uninformative error message, so I'm trying to figure out what's actually failing. |
Might have something to do with the bundler cache, can you omit the |
@serene I updated the default ruby version to the latest 2.6.x, and turned off the bundler cache. The workflow needs approval again. I think that the method of selecting the Rails version isn't working well with the cache, probably because the Gemfile doesn't change even though its meaning does when that env var changes. A lot of other projects use the appraisal gem to resolve this kind of issue. We might consider switching to it here as well. (Not in this PR; possible future reference). Update: Nope, turning off the bundler cache broke everything. What worked was updating rubygems and bundler. |
@serene new workflow attempt needs approving. |
I would like to squash this before merging. Last workflow approval, @serene :) |
- Update default ruby version to latest 2.6 release. - Test Ruby 2.7, 3.0, and 3.1, and Rails 6.1 and 7.0. Use versions as strings to make sure 3.0 tests 3.0. - Use latest rubygems and bundler to fix the bundler cache. - Exclude incompatible test matrix combinations. - Show Ruby deprecation warnings in tests where supported. - File.exists? is deprecated; use File.exist?. - URI.escape and URI.decode are deprecated. - Add frozen string literal comments. - Make sure constants are frozen. - Make sure that the code is frozen-string safe. - Adjust dev dependencies for Ruby 3.0+ compatibility. - Fix Ruby warnings in pdfkit_spec.rb - Comment out bad syntax in release-drafter action. Fixes pdfkit#498
@serene I had to change the Ruby version numbers to strings to make sure 3.0 tests 3.0.x, instead of 3.x (which becomes 3.1, which we already test). Could you approve the workflow again? Once this one passes, it should be good to merge. |
Fixes #498