Skip to content

RUBY-2859 Add GH Actions setup for ruby 3.1 #2398

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

Merged
merged 2 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
ruby: ["2.5", "2.6", "2.7", "3.0"]
ruby: ["2.5", "2.6", "2.7", "3.0", "3.1"]
mongodb: ["3.6", "4.4", "5.0"]
topology: [replica_set, sharded_cluster]
include:
Expand Down Expand Up @@ -40,6 +40,10 @@ jobs:
ruby: "3.0"
mongodb: "5.0"
topology: server
- os: ubuntu-latest
ruby: "3.1"
mongodb: "5.0"
topology: server
- os: ubuntu-18.04
ruby: "2.5"
mongodb: "3.6"
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Spec
attr_reader :tests

def initialize(test_path)
@spec = YAML.load(File.read(test_path))
@spec = ::Utils.load_spec_yaml_file(test_path)
@description = File.basename(test_path)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/runners/change_streams/spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Spec
#
# @since 2.6.0
def initialize(test_path)
@spec = YAML.load(File.read(test_path))
@spec = ::Utils.load_spec_yaml_file(test_path)
@description = File.basename(test_path)
@spec_tests = @spec['tests']
@collection_name = @spec['collection_name']
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/cmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Spec
#
# @param [ String ] test_path The path to the file.
def initialize(test_path)
@test = YAML.load(File.read(test_path))
@test = ::Utils.load_spec_yaml_file(test_path)

@description = @test['description']
@pool_options = ::Utils.snakeize_hash(process_options(@test['poolOptions']))
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/command_monitoring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class Spec
#
# @since 2.1.0
def initialize(test_path)
@spec = YAML.load(File.read(test_path))
@spec = ::Utils.load_spec_yaml_file(test_path)
@data = @spec['data']
@tests = @spec['tests']
end
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/connection_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Spec
#
# @since 2.0.0
def initialize(test_path)
@spec = YAML.load(File.read(test_path))
@spec = ::Utils.load_spec_yaml_file(test_path)
@description = File.basename(test_path)
end

Expand Down
4 changes: 1 addition & 3 deletions spec/runners/crud/spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class Spec
#
# @since 2.0.0
def initialize(test_path)
contents = File.read(test_path)

@spec = YAML.load(contents)
@spec = ::Utils.load_spec_yaml_file(test_path)
@description = File.basename(test_path)
@data = BSON::ExtJSON.parse_obj(@spec['data'])
@tests = @spec['tests']
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/gridfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Spec
#
# @since 2.1.0
def initialize(test_path)
@spec = YAML.load(File.read(test_path))
@spec = ::Utils.load_spec_yaml_file(test_path)
@description = File.basename(test_path)
@data = @spec['data']
end
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/read_write_concern_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Spec
#
# @since 2.0.0
def initialize(test_path)
@spec = YAML.load(File.read(test_path))
@spec = ::Utils.load_spec_yaml_file(test_path)
@description = File.basename(test_path)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/runners/sdam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Spec
#
# @since 2.0.0
def initialize(test_path)
@test = YAML.load(File.read(test_path))
@test = ::Utils.load_spec_yaml_file(test_path)
@description = @test['description']
@uri_string = @test['uri']
@uri = URI.new(uri_string)
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/server_selection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Spec
#
# @since 2.0.0
def initialize(test_path)
@test = YAML.load(File.read(test_path))
@test = ::Utils.load_spec_yaml_file(test_path)
@description = "#{@test['topology_description']['type']}: #{File.basename(test_path)}"
@heartbeat_frequency = @test['heartbeatFrequencyMS'] / 1000 if @test['heartbeatFrequencyMS']
@read_preference = @test['read_preference']
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/server_selection_rtt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Spec
#
# @since 2.0.0
def initialize(test_path)
@test = YAML.load(File.read(test_path))
@test = ::Utils.load_spec_yaml_file(test_path)
@description = "#{File.basename(test_path)}: avg_rtt_ms: #{@test['avg_rtt_ms']}, new_rtt_ms: #{@test['new_rtt_ms']}," +
" new_avg_rtt: #{@test['new_avg_rtt']}"
@average_rtt = @test['avg_rtt_ms'] == 'NULL' ? nil : @test['avg_rtt_ms'].to_f / 1000
Expand Down
2 changes: 1 addition & 1 deletion spec/runners/unified/test_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Unified
class TestGroup
def initialize(path, **opts)
if String === path
data = YAML.load(File.read(path))
data = ::Utils.load_spec_yaml_file(path)
else
data = path
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_tests/seed_list_discovery_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

SEED_LIST_DISCOVERY_TESTS.each do |test_path|

spec = YAML.load(File.read(test_path))
spec = ::Utils.load_spec_yaml_file(test_path)

test = Mongo::ConnectionString::Test.new(spec)

Expand Down
31 changes: 31 additions & 0 deletions spec/support/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -613,4 +613,35 @@ def match_with_type?(expected, actual)
end
end
end

module_function def load_spec_yaml_file(path)
permitted_classes = [
BigDecimal,
Date,
Time,
Range,
Regexp,
Symbol,
BSON::Binary,
BSON::Code,
BSON::CodeWithScope,
BSON::DbPointer,
BSON::Decimal128,
BSON::Int32,
BSON::Int64,
BSON::MaxKey,
BSON::MinKey,
BSON::ObjectId,
BSON::Regexp::Raw,
BSON::Symbol::Raw,
BSON::Timestamp,
BSON::Undefined,
]
if RUBY_VERSION.start_with?("2.5")
YAML.safe_load(File.read(path), permitted_classes, [], true)
else
# Here we have Ruby 2.6+ that supports the new syntax of `safe_load``.
YAML.safe_load(File.read(path), permitted_classes: permitted_classes, aliases: true)
end
end
end