Skip to content
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

Migrate to Credentials + Remove Other Deprecation Warnings #1326

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

kartiki975
Copy link
Contributor

@kartiki975 kartiki975 commented Jan 30, 2024

In attempts to use the recent shipit-engine release, I noticed the following exception being thrown in CI checks:

ActiveSupport::DeprecationException: DEPRECATION WARNING: `Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2. (called from block in <class:Engine> at /tmp/bundle/ruby/3.2.0/bundler/gems/shipit-engine-03a10e90a389/[redacted]) (ActiveSupport::DeprecationException)

This PR seeks to avoid this exception by migrating to credentials as instructed here: https://github.com/Shopify/ejson-rails?tab=readme-ov-file#migrating-to-credentials.

There were 3 other deprecation warnings that were being reported during unit tests. Those have been addressed as well.

@kartiki975 kartiki975 changed the title Remove deprecation warning Remove deprecation warnings Jan 30, 2024
@kartiki975 kartiki975 changed the title Remove deprecation warnings Migrate to Credentials + Remove Other Deprecation Warnings Jan 30, 2024
@kartiki975 kartiki975 requested a review from a team January 30, 2024 21:22
@kartiki975 kartiki975 marked this pull request as ready for review January 30, 2024 21:22
@kwboyd-shopify
Copy link
Contributor

Just to check - were we able to test these changes in our Shipit instance?

@kartiki975
Copy link
Contributor Author

@kwboyd-shopify I didn't do a tophat but the CI checks were passing when I temporarily integrated this branch's changes here: https://github.com/Shopify/shipit/pull/2589/commits/bd719ee152153205b97bdd1d47279ef7a9a7c124

@kwboyd-shopify
Copy link
Contributor

Gotcha! I'll pull these changes and do a quick test today before approving.

@kartiki975
Copy link
Contributor Author

With a recent tophat on internal Shipit with these changes, a 500 error is preventing batched changes to start deploying. No longer looking for reviews until I fix that issue 😞

Copy link

@emmabukacek emmabukacek left a comment

Choose a reason for hiding this comment

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

I'd feel better if we had at least one more review on this, but I read through the migration guide and this, and nothing stood out to me as incorrect! Thanks for taking on this massive effort. 🙏🏻

@@ -8,7 +8,7 @@ class ApiClient < Record

validates :creator, :name, presence: true

serialize :permissions, Shipit.serialized_column(:permissions, type: Array)
serialize :permissions, coder: Shipit.serialized_column(:permissions, type: Array)

Choose a reason for hiding this comment

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

I'm not sure what the coder key does; could you explain it for me? 😅 My gut says this overrides default YAML behavior with whatever method you pass, but I wanted to make sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Thank you!

@kartiki975
Copy link
Contributor Author

Thanks for tophatting as well, @erik-shopify!
In regards to indefinite soaking, I am not seeing that on my end... that may be flakiness 🤔 let me know if you see anything unusual on any of your recent tophat attempts.

@kartiki975 kartiki975 requested review from a team and casperisfine February 7, 2024 16:16
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -1,4 +1,7 @@
# Unreleased
* Migrate secrets from credentials
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a migration path we can suggest to folks?

Suggested change
* Migrate secrets from credentials
* Migrate from legacy Rails secrets to credentials
- Rails secrets were [deprecated in Rails 7.1](https://github.com/rails/rails/pull/48472)

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a bunch of blog posts out there, I haven't checked how good they were but at least linking to the guide on credential would be a good start: https://guides.rubyonrails.org/security.html#custom-credentials

Copy link
Member

Choose a reason for hiding this comment

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

I was looking at that one, and that'd definitely be useful to link, but I was thinking specifically along the lines of a page that gives the steps to migrate from one to the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the one that was recommended in discourse: https://github.com/Shopify/ejson-rails?tab=readme-ov-file#migrating-to-credentials.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions! I have incorporated it all. Let me know if there are any other tweaks needed.

Copy link
Contributor

@ruionweb ruionweb left a comment

Choose a reason for hiding this comment

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

If you also don't mind including the octokit bump in the changelog! #1327

CHANGELOG.md Outdated
* Migrate from legacy Rails secrets to credentials (#1326)
* Rails secrets were [deprecated in Rails 7.1](https://github.com/rails/rails/pull/48472)
* [Guide on credentials](https://guides.rubyonrails.org/security.html#custom-credentials)
* Migrated using the ejson-rails gem and [these migration instructions](https://github.com/Shopify/ejson-rails?tab=readme-ov-file#migrating-to-credentials)
Copy link
Contributor

Choose a reason for hiding this comment

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

ejson-rails only concerns Shopify. It's a public gem so people can use it if they way, but as far as shipit-engine (the open source project) is concerned, it only migrated to Rails credentials, not to ejson-rails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure if this implied rewording this or removing the line completely. I assumed the latter and removed it in the recent commit.

Create secrets.test.json

Replace deprecated Rails.application.secrets

Add ejson-rails gem

Remove deprecation warning

Passing the coder as positional argument is deprecated and will be removed in Rails 7.2

Remove deprecated TestFixtures.fixture_path=

Remove deprecated check_pending!
@kartiki975 kartiki975 merged commit d5cf443 into main Feb 7, 2024
17 checks passed
@kartiki975 kartiki975 deleted the remove-deprecation-warning branch February 7, 2024 21:01
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.

None yet

7 participants