Browse Source

Maintenance: Switch to Ruby 3.1.3

Mantas Masalskis 2 years ago
parent
commit
3505024b29

+ 1 - 1
.gitlab/ci/__includes__/job_defaults.yml

@@ -1,5 +1,5 @@
 default:
-  image: $CI_REGISTRY/docker/zammad-ci:3.0.4
+  image: $CI_REGISTRY/docker/zammad-ci:3.1.3
 
   tags:
     - docker

+ 2 - 0
.gitlab/ci/test/migration.yml

@@ -21,11 +21,13 @@
     - git fetch --unshallow
     - git checkout stable
     - !reference [.scripts, source_rvm] # TODO: this will cause issues if we have Ruby version changes.
+    - rvm use 3.0.4
     - !reference [.scripts, bundle_install]
     - !reference [.scripts, configure_environment]
     - !reference [.scripts, zammad_db_init]
     # Then, switch to the current commit, migrate to it and run a few selected tests.
     - git checkout $CI_COMMIT_SHA
+    - rvm use 3.1.3
     - !reference [.scripts, bundle_install]
     - bundle exec rails db:migrate
     - bundle exec rspec --profile 10 spec/db

+ 2 - 1
.gitlab/configure_environment.rb

@@ -57,7 +57,8 @@ class ConfigureEnvironment
       return
     end
 
-    cnf = YAML.load_file(File.join(__dir__, '../config/database/database.yml'))
+    # Ruby 3.1 uses Psych 4 which made aliases support optional
+    cnf = YAML.load_file(File.join(__dir__, '../config/database/database.yml'), aliases: true)
     cnf.delete('default')
 
     database = ENV['ENFORCE_DB_SERVICE'] || %w[postgresql mysql].shuffle.find do |db|

+ 12 - 13
.pkgr.yml

@@ -104,19 +104,18 @@ targets:
       - libimlib2
       - libimlib2-dev
       - shared-mime-info
-# Ubuntu 22 LTS required libssl3 which is a hard dependency for Ruby 3.1+
-#  ubuntu-22.04:
-#    dependencies:
-#      - curl
-#      - elasticsearch|elasticsearch-oss
-#      - nginx|apache2
-#      - postgresql|mysql-server|mariadb-server
-#      - libimlib2
-#      - shared-mime-info
-#    build_dependencies:
-#      - libimlib2
-#      - libimlib2-dev
-#      - shared-mime-info
+  ubuntu-22.04:
+    dependencies:
+      - curl
+      - elasticsearch|elasticsearch-oss
+      - nginx|apache2
+      - postgresql|mysql-server|mariadb-server
+      - libimlib2
+      - shared-mime-info
+    build_dependencies:
+      - libimlib2
+      - libimlib2-dev
+      - shared-mime-info
   sles-12:
     dependencies:
       - curl

+ 3 - 0
.rubocop/default.yml

@@ -105,6 +105,9 @@ Style/DefWithParentheses:
   StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
   Enabled: false
 
+Style/HashSyntax:
+  EnforcedShorthandSyntax: either
+
 Layout/HashAlignment:
   Description: >-
                  Align the elements of a hash literal if they span more than

+ 1 - 1
.ruby-version

@@ -1 +1 @@
-3.0.4
+3.1.3

+ 2 - 2
Dockerfile

@@ -1,7 +1,7 @@
 FROM node:16.18.0-slim as node
 
 
-FROM ruby:3.0.4-slim AS builder
+FROM ruby:3.1.3-slim AS builder
 ARG DEBIAN_FRONTEND=noninteractive
 ARG RAILS_ENV=production
 ARG ZAMMAD_TMP_DIR=/tmp/zammad
@@ -15,7 +15,7 @@ RUN contrib/docker/setup.sh builder
 
 # note: zammad is currently incompatible to alpine because of:
 # https://github.com/docker-library/ruby/issues/113
-FROM ruby:3.0.4-slim
+FROM ruby:3.1.3-slim
 ARG DEBIAN_FRONTEND=noninteractive
 ARG ZAMMAD_USER=zammad
 ENV RAILS_ENV=production

+ 8 - 1
Gemfile

@@ -3,7 +3,7 @@
 source 'https://rubygems.org'
 
 # core - base
-ruby '3.0.4'
+ruby '3.1.3'
 gem 'rails', '~> 6.1.0'
 
 # core - rails additions
@@ -119,6 +119,13 @@ gem 'mail', git: 'https://github.com/zammad-deps/mail', branch: '2-7-stable'
 gem 'mime-types'
 gem 'rchardet', '>= 1.8.0'
 
+# networking libraries were removed from stdlib in ruby 3.1..
+gem 'net-ftp',  require: false
+gem 'net-http', require: false
+gem 'net-imap', require: false
+gem 'net-pop',  require: false
+gem 'net-smtp', require: false
+
 # convert from punycode ACE strings to unicode UTF-8 strings and visa versa
 gem 'simpleidn'
 

+ 26 - 2
Gemfile.lock

@@ -152,6 +152,7 @@ GEM
     csv (3.2.6)
     daemons (1.4.1)
     dalli (3.2.3)
+    date (3.3.3)
     debug_inspector (1.1.0)
     delayed_job (4.1.11)
       activesupport (>= 3.0, < 8.0)
@@ -298,7 +299,21 @@ GEM
     mysql2 (0.5.4)
     naught (1.1.0)
     nestful (1.1.4)
+    net-ftp (0.2.0)
+      net-protocol
+      time
+    net-http (0.3.2)
+      uri
+    net-imap (0.3.4)
+      date
+      net-protocol
     net-ldap (0.17.1)
+    net-pop (0.1.2)
+      net-protocol
+    net-protocol (0.2.1)
+      timeout
+    net-smtp (0.3.3)
+      net-protocol
     nio4r (2.5.8)
     nokogiri (1.13.10)
       mini_portile2 (~> 2.8.0)
@@ -541,6 +556,9 @@ GEM
     thor (1.2.1)
     thread_safe (0.3.6)
     tilt (2.0.11)
+    time (0.2.1)
+      date
+    timeout (0.3.1)
     twilio-ruby (5.74.1)
       faraday (>= 0.9, < 3.0)
       jwt (>= 1.5, <= 2.6)
@@ -567,6 +585,7 @@ GEM
     unicorn (6.1.0)
       kgio (~> 2.6)
       raindrops (~> 0.7)
+    uri (0.12.0)
     vcr (6.1.0)
     version_gem (1.1.1)
     viewpoint (1.1.1)
@@ -658,7 +677,12 @@ DEPENDENCIES
   mime-types
   minitest-profile
   mysql2
+  net-ftp
+  net-http
+  net-imap
   net-ldap
+  net-pop
+  net-smtp
   oauth2
   omniauth-facebook
   omniauth-github
@@ -720,7 +744,7 @@ DEPENDENCIES
   zendesk_api
 
 RUBY VERSION
-   ruby 3.0.4p208
+   ruby 3.1.3p185
 
 BUNDLED WITH
-   2.3.23
+   2.4.1

+ 1 - 6
app/channels/graphql_channel.rb

@@ -18,12 +18,7 @@ class GraphqlChannel < ApplicationCable::Channel
       channel:      self,
     }
 
-    result = Gql::ZammadSchema.execute(
-      query:          query,
-      context:        context,
-      variables:      variables,
-      operation_name: operation_name
-    )
+    result = Gql::ZammadSchema.execute(query:, context:, variables:, operation_name:)
 
     payload = {
       result: result.to_h,

Some files were not shown because too many files changed in this diff