Release-tools ruby 3 upgrade
Overview
Ruby 2.7.7 is approaching End Of Life, and release-tools needs to be upgraded to ruby 3.2.
Renovate bot attempted the upgrade in gitlab-org/release-tools!2079 (closed), but as we can see from the CI job the syntax is not compatible with ruby 3
Click to expand
$ bundle exec rspec
Attention: used pure ruby version of MurmurHash3
>> Feature flag status:
An error occurred while loading ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb.
Failure/Error:
shared_examples 'an auto-mergeable MR' do |merge_trains_enabled:|
it 'makes sure the source branch exists, creates the merge request, updates gitaly versions, and auto-merge' do
expect(task).to receive(:changed?).and_return(true)
merge_request = double('merge_request', exists?: false, project: double)
allow(task).to receive(:merge_request).and_return(merge_request)
expect(task).to receive(:ensure_source_branch_exists)
expect(task).to receive(:create_or_show_merge_request).with(merge_request)
allow(ReleaseTools::GitlabClient).to receive(:merge_trains_enabled?).with(merge_request.project).and_return(merge_trains_enabled)
ArgumentError:
missing keyword: :merge_trains_enabled
# ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb:70:in `block (3 levels) in <top (required)>'
# ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb:101:in `block (4 levels) in <top (required)>'
# ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb:100:in `block (3 levels) in <top (required)>'
# ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb:99:in `block (2 levels) in <top (required)>'
# ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb:21:in `block in <top (required)>'
# ./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb:6:in `<top (required)>'
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Randomized with seed 40741
Finished in 0.00358 seconds (files took 3.99 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
Randomized with seed 40741
Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected
Coverage report generated for RSpec to /builds/gitlab-org/release-tools/coverage. 3479 / 7822 LOC (44.48%) covered.
To run tests locally against Ruby 3
- Apply this diff:
diff --git a/.ruby-version b/.ruby-version
index 1f7da99d..e4604e3a 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-2.7.7
+3.2.1
diff --git a/.tool-versions b/.tool-versions
index b430f1c6..004a4efc 100644
--- a/.tool-versions
+++ b/.tool-versions
@@ -1,4 +1,4 @@
golang 1.20.2 # datasource=golang-version depName=golang
golangci-lint 1.51.2 # datasource=github-releases depName=golangci/golangci-lint
-ruby 2.7.7 # datasource=ruby-version depName=ruby
+ruby 3.2.1 # datasource=ruby-version depName=ruby
mockery 2.22.1 # datasource=github-releases depName=vektra/mockery
- Install Ruby 3.2.1 with asdf:
asdf install ruby 3.2.1
- Install gems for Ruby 3:
bundle install
- Run your tests!
Failing tests with Ruby 3.2.1
Here is the initial list of files with failing tests when running against Ruby 3.2.1. We should fix these in chunks to make MRs reasonable in size. Run the file locally to see the specific tests that need to be fixed:
bundle exec rspec <file path>
Most of the updates involve just adding {}
to keyword arguments in specs: https://docs.gitlab.com/ee/development/ruby3_gotchas.html#rspec-with-argument-matcher-fails-for-shorthand-hash-syntax
Once an MR is created for the given file, check it off the list!
File list
-
./spec/lib/release_tools/security/client_spec.rb -
./spec/lib/release_tools/promotion/checks/incident_rollback_spec.rb -
./spec/lib/release_tools/release_metadata_spec.rb -
./spec/lib/release_tools/promotion/manager_spec.rb -
./spec/lib/release_tools/tasks/auto_deploy/check_production_spec.rb -
./spec/lib/release_tools/public_release/gitlab_release_spec.rb -
./spec/lib/release_tools/auto_deploy/post_deploy_migrations/notifier_spec.rb -
./spec/lib/release_tools/commits_spec.rb -
./spec/lib/release_tools/auto_deploy/post_deploy_migrations/merge_request_labeler_spec.rb -
./spec/lib/release_tools/security/merge_requests_merger_spec.rb -
./spec/lib/release_tools/services/approve_service_spec.rb -
./spec/lib/release_tools/pipeline_tracer/process_jobs_spec.rb -
./spec/lib/release_tools/public_release/gitlab_operator_release_spec.rb -
./spec/lib/release_tools/public_release/cng_image_release_spec.rb -
./spec/lib/release_tools/deployments/merge_request_labeler_spec.rb -
./spec/lib/release_tools/auto_deploy/post_deploy_migrations/release_note_spec.rb -
./spec/lib/release_tools/public_release/helm_gitlab_release_spec.rb -
./spec/lib/release_tools/deployments/deployment_tracker_spec.rb -
./spec/lib/release_tools/changelog_compiler_spec.rb -
./spec/lib/release_tools/metadata/comparison_spec.rb -
./spec/lib/release_tools/auto_deploy/post_deploy_migrations/deployment_tracker_spec.rb -
./spec/lib/release_tools/promotion/deployment_check_report_spec.rb -
./spec/lib/release_tools/auto_deploy/post_deploy_migrations/qa/notifier_spec.rb -
./spec/lib/release_tools/slack/post_deploy_migrations_notification_spec.rb -
./spec/lib/release_tools/security/tracking_issue_spec.rb -
./spec/lib/release_tools/services/merge_when_pipeline_succeeds_service_spec.rb -
./spec/lib/release_tools/tasks/auto_deploy/promotion_checks_spec.rb -
./spec/lib/release_tools/rollback/presenter_spec.rb -
./spec/lib/release_tools/slack/qa_notification_spec.rb -
./spec/lib/release_tools/automatic_release_candidate_spec.rb -
./spec/lib/release_tools/metadata/compare_service_spec.rb -
./spec/lib/release_tools/tasks/auto_deploy/rollback_check_spec.rb -
./spec/lib/release_tools/auto_deploy/coordinated_pipeline/notifier_spec.rb -
./spec/lib/release_tools/remote_repository_spec.rb -
./spec/lib/release_tools/slack/coordinated_pipeline_notification_spec.rb -
./spec/lib/release_tools/cherry_pick/stable_service_spec.rb -
./spec/lib/release_tools/auto_deploy/coordinated_pipeline/qa/notifier_spec.rb -
./spec/lib/release_tools/services/sync_refs_helper_spec.rb -
./spec/lib/release_tools/public_release/gitlab_pages_release_spec.rb -
./spec/lib/release_tools/promotion/checks/change_requests_spec.rb -
./spec/lib/release_tools/product_version_spec.rb -
./spec/lib/release_tools/slack/post_deploy_pipeline_initial_notification_spec.rb -
./spec/lib/release_tools/tasks/production_check/chatops_spec.rb -
./spec/lib/release_tools/security/issue_crawler_spec.rb -
./spec/lib/release_tools/services/auto_merge_service_spec.rb -
./spec/lib/release_tools/helm/helm_version_finder_spec.rb -
./spec/lib/release_tools/qa/issue_spec.rb -
./spec/lib/release_tools/metrics/patch_release_pressure_spec.rb [ ] ./spec/lib/release_tools/services/auto_deploy_branch_service_spec.rb-
./spec/lib/release_tools/services/sync_remotes_service_spec.rb -
./spec/lib/release_tools/qa/merge_requests_spec.rb -
./spec/lib/release_tools/public_release/release_spec.rb -
./spec/lib/release_tools/tasks/auto_deploy/check_package_spec.rb -
./spec/lib/release_tools/gitlab_client_spec.rb -
./spec/lib/release_tools/public_release/gitaly_release_spec.rb -
./spec/lib/release_tools/merge_request_spec.rb -
./spec/lib/release_tools/graphql_adapter_spec.rb -
./spec/lib/release_tools/tasks/components/update_gitaly_spec.rb -
./spec/lib/release_tools/auto_deploy/cleanup_spec.rb -
./spec/lib/release_tools/services/add_to_merge_train_service_spec.rb -
./spec/lib/release_tools/pipeline_tracer/service_spec.rb -
./spec/lib/release_tools/patch_release/issue_spec.rb -
./spec/lib/release_tools/deployments/metadata_spec.rb -
./spec/lib/release_tools/services/update_component_service_spec.rb -
./spec/lib/release_tools/sync_remotes_merge_request_spec.rb -
./spec/lib/release_tools/auto_deploy/tagger/release_metadata_tracking_spec.rb -
./spec/lib/release_tools/rollback/compare_service_spec.rb -
./spec/lib/release_tools/promotion/production_status_spec.rb -
./spec/lib/release_tools/passing_build_spec.rb -
./spec/lib/release_tools/security/dev_client_spec.rb -
./spec/lib/release_tools/public_release/omnibus_gitlab_release_spec.rb -
./spec/lib/release_tools/qa/issue_closer_spec.rb -
./spec/lib/release_tools/public_release/gitaly_monthly_release_spec.rb -
./spec/lib/release_tools/metrics/auto_deploy_pressure_spec.rb -
./spec/lib/release_tools/tracker/merge_request_updater_spec.rb -
./spec/lib/release_tools/slack/coordinated_pipeline_tag_notification_spec.rb -
./spec/lib/release_tools/slack/chatops_notification_spec.rb -
./spec/lib/release_tools/slack/coordinated_pipeline_diffs_notification_spec.rb -
./spec/lib/release_tools/patch_release/blog_merge_request_spec.rb