Skip to content

Commit

Permalink
Update ruby to 3.0 (#8452)
Browse files Browse the repository at this point in the history
* Update the github deps to ruby 3.0.2

* Fixing some of the decidim core specs

* Fixing Templates specs

* Fixing some of the Decidim Verifications errors

* Fix Assemblies permission related errors

* Fixing premissions related specs

* fix Rectify Command

* Fixing decidim-admin issues

* Display brakeman version

* Fix the Presenters

* Updating rspec-cells

* Fix the publish event specs

* fix subscribers

* Fixing Core specs

* Fix Participatory process

* Fixing Accountability failing specs

* fix admin failing specs

* Bulk fixing failing tests related to events, linting

* Fixing Decidim-Initiatives failing specs

* Fixing Decidim elections failing specs

* Running linters

* Fixing last election failing spec

* Refactor Ruby 3.0.2 actions

* Upgrade brakeman

* Rails attributes compatibility

* Fixing Rails::Engine parameters

* Patch WorkflowManifest Rails::Engine attribute

* Change the ruby-version

* Locking Gemspec ruby version

* Fixing failing specs

* Fixing latest failing tests

* Update file_validators to support Ruby 3

* Remove Rectify Overrides as they are not required anymore

* Update date_validators to support Ruby 3

* Add RUBY_VERSION to all the ci pipelines

* Upgrade election dependencies

* Fixing Command class

* Fix last failing specs

* Fixing Menu move method

* Update the changelog

* Set the generator to use Decidim Official repo

* Running linters
  • Loading branch information
alecslupu committed May 3, 2022
1 parent 0fadda3 commit f402b6e
Show file tree
Hide file tree
Showing 174 changed files with 503 additions and 483 deletions.
2 changes: 1 addition & 1 deletion .github/actions/module-rspec/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
required: true
ruby_version:
description: 'Ruby Version'
default: "2.7.5"
default: "3.0.2"
required: false
node_version:
description: 'Node version'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_accountability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-accountability
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-admin
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_admin_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-admin
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-api
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_assemblies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-assemblies
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_blogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-blogs
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_budgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-budgets
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-comments
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_conferences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-conferences
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_consultations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-consultations
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_core_lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-core
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_core_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-core
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_core_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-core
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_debates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-debates
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_dev_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-dev
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_elections_system_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-elections
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_elections_system_public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-elections
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_elections_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-elections
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-forms
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-generators
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_initiatives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-initiatives
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_initiatives_system_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-initiatives
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_initiatives_system_public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-initiatives
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_meetings_system_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-meetings
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_meetings_system_public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-meetings
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_meetings_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-meetings
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-pages
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_participatory_processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-participatory_processes
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_performance_metrics_monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
RAILS_ENV: development

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_proposals_system_admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-proposals
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_proposals_system_public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-proposals
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_proposals_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-proposals
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_sortitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-sortitions
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_surveys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-surveys
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-system
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-templates
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_verifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
CI: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1
DECIDIM_MODULE: decidim-verifications
PARALLEL_TEST_PROCESSORS: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
CI: "true"
SIMPLECOV: "true"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 3.0.2
NODE_VERSION: 16.9.1

jobs:
Expand Down
3 changes: 2 additions & 1 deletion .rubocop_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AllCops:
- "decidim_app-design/node_modules/**/*"
- "spec/decidim_dummy_app/**/*"
- "node_modules/**/*"
- "decidim-initiatives/lib/gem_overrides/origami/date.rb"
# Default formatter will be used if no -f/--format option is given.
DefaultFormatter: progress
# Cop names are not displayed in offense messages by default. Change behavior
Expand Down Expand Up @@ -68,7 +69,7 @@ AllCops:
# If a value is specified for TargetRubyVersion then it is used.
# Else if .ruby-version exists and it contains an MRI version it is used.
# Otherwise we fallback to the oldest officially supported Ruby version (2.0).
TargetRubyVersion: 2.7
TargetRubyVersion: 3.0

# RSpec:
# Patterns:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
3.0.2
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ In the next version (v0.28.0) it will be fully removed from the database.

### Added

#### Upgrade to Ruby 3.0

PR [\#8452] https://github.com/decidim/decidim/pull/8452 has upgraded the required ruby version to 3.0. Upgrading to this version will require either to install the Ruby Version on your host, or change the decidim docker image to use ruby:3.0.2.

#### Rails Upgrade to 6.1
PR [\#8411] https://github.com/decidim/decidim/pull/8411 changes the following:

Expand Down Expand Up @@ -121,7 +125,7 @@ There are specific things that you need to change regarding your Form or `Virtus
- When calling the `attributes` method of the model/form classes, use strings to refer to the attribute names, not symbols as you might have done with `Virtus` or `Rectify::Form`. Change all `model.attributes[:attr_name]` method calls to `model.attributes["attr_name"]`.
- When calling `model.attributes.slice(...)`, you also need to use strings to refer to the attribute keys. Change all instances of `model.attributes.slice(:attr1, :attr2)` to `model.attributes.slice("attr1", "attr2")`
- If you had overridden any of the [`Rectify::Form` methods](https://github.com/andypike/rectify/blob/v0.13.0/lib/rectify/form.rb) within your form classes, remove those overrides. For example, you might have overridden the `form_attributes_valid?` method which no longer does anything. Instead, define a custom validation in order to add extra validations to your forms.
- Very rarely, when defining a an attribute of type `Rails::Engine`, you need to change `attribute :attr_name, Rails::Engine` to `attribute :attr_name, Rails::Engine, {}`. This is because we want to preserve the method signature against `ActiveModel::Attributes` for the `attribute` class method intead of the legacy `Virtus.model`. There is a limitation in the Ruby language that if the method has default values for the previous arguments and defines keyword arguments, the last argument will always receive a `respond_to?(:to_hash)` call to it which doesn't work for `Rails::Engine` (you can try it out in the Rails console by calling `Rails::Engine.respond_to?(:to_hash)`).
- Very rarely, when defining a an attribute of type `Rails::Engine`, you need to change `attribute :attr_name, Rails::Engine` to `attribute :attr_name, Rails::Engine, **{}`. This is because we want to preserve the method signature against `ActiveModel::Attributes` for the `attribute` class method intead of the legacy `Virtus.model`. There is a limitation in the Ruby language that if the method has default values for the previous arguments and defines keyword arguments, the last argument will always receive a `respond_to?(:to_hash)` call to it which doesn't work for `Rails::Engine` (you can try it out in the Rails console by calling `Rails::Engine.respond_to?(:to_hash)`).
- Test all your form and command classes thoroughly to notice any differences between the two implementations. The new layer is a bit more "robust" with some of the type castings, so some things may break during the migration in case you have relied on some of the oversights within `Virtus`.

#### Custom icons new uploader
Expand Down

0 comments on commit f402b6e

Please sign in to comment.