Skip to content

Commit

Permalink
Add Ruby 3.1 to Circle tests (#2129)
Browse files Browse the repository at this point in the history
Remove Aliases in "config/secrets.yml" to support Ruby 3.1 + Rails 6.1

Ruby 3.1 ships with Psych 4. Psych 4 switched it's default YAML parsing mode to
a safer mode, including not allowing aliases. This broke parsing of
"secrets.yml" in Rails, if the secrets file contains any aliases.

Some discussion: https://bugs.ruby-lang.org/issues/17866

Rails PR 42687 implemented a fix, and that fix was included in Rails 7 here:
rails/rails@0ebb708

It was also included in the Rails 6-1-stable branch here:
rails/rails@aac3edb

But that commit happened after Rails 6.1.4 was published, and no patch-level
releases have been made for Rails 6.1 since that commit. Only security-level
releases have been published. I assume if Rails 6.1.5 is released it will
contain the fix.

Until Rails 6.1.5 is released, the best option to be able to test Ruby 3.1
against Rails 6.1 apps is probably to just eliminate any aliases in yaml files
that Rails uses.

Using new CircleCI image "cimg/ruby"
  • Loading branch information
jordan-brough authored Jan 25, 2022
1 parent 441337f commit e997c09
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
24 changes: 22 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: 2.1

orbs:
browser-tools: circleci/browser-tools@1.2.3
browser-tools: circleci/browser-tools@1.2.4

commands:
shared_steps:
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
<<: *default_job
steps:
- shared_steps
# Run the tests against the versions of Rails that support Ruby 3
# Run the tests against the versions of Rails that support Ruby 3.0
- run: bundle exec appraisal install
- run: bundle exec appraisal rails60 rspec
- run: bundle exec appraisal rails61 rspec
Expand All @@ -102,10 +102,30 @@ jobs:
POSTGRES_DB: ruby30
POSTGRES_PASSWORD: ""

ruby-31:
<<: *default_job
steps:
- shared_steps
# Run the tests against the versions of Rails that support Ruby 3.1
- run: bundle exec appraisal install
- run: bundle exec appraisal rails61 rspec
docker:
- image: cimg/ruby:3.1-browsers
environment:
PGHOST: localhost
PGUSER: administrate
RAILS_ENV: test
- image: postgres:10.1-alpine
environment:
POSTGRES_USER: administrate
POSTGRES_DB: ruby31
POSTGRES_PASSWORD: ""

workflows:
version: 2
multiple-rubies:
jobs:
- ruby-31
- ruby-30
- ruby-27
- ruby-26
8 changes: 2 additions & 6 deletions spec/example_app/config/secrets.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
default: &default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

development:
<<: *default
secret_key_base: 1a022e4f335d24af3d6bd622b9daef5a44808afbe16d4f1c8bed03675ab91ecd9c76ddc1a30f3fbb668b02c00abcba2ecc3714c95943b8f4af86289a2a46d5e1

test:
secret_key_base: test_secret

staging:
<<: *default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

production:
<<: *default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

0 comments on commit e997c09

Please sign in to comment.