11# frozen_string_literal: true
2- # rubocop:todo all
32
43require 'bundler'
54require 'rspec/core/rake_task'
65
7- if File . exist? ( './spec/shared/lib/tasks/candidate.rake' )
8- load 'spec/shared/lib/tasks/candidate.rake'
9- end
6+ load 'spec/shared/lib/tasks/candidate.rake' if File . exist? ( './spec/shared/lib/tasks/candidate.rake' )
107
118ROOT = File . expand_path ( File . join ( File . dirname ( __FILE__ ) ) )
129
13- $: << File . join ( ROOT , 'spec/shared/lib' )
10+ $LOAD_PATH << File . join ( ROOT , 'spec/shared/lib' )
1411
12+ # rubocop:disable Style/RegexpLiteral
1513CLASSIFIERS = [
16- [ %r,^mongo/server, , :unit_server ] ,
17- [ %r,^mongo, , :unit ] ,
18- [ %r,^kerberos, , :unit ] ,
19- [ %r,^integration/sdam_error_handling, , :sdam_integration ] ,
20- [ %r,^integration/cursor_reaping, , :cursor_reaping ] ,
21- [ %r,^integration/query_cache, , :query_cache ] ,
22- [ %r,^integration/transactions_examples, , :tx_examples ] ,
23- [ %r,^(atlas|integration), , :integration ] ,
24- [ %r,^spec_tests/sdam_integration, , :spec_sdam_integration ] ,
25- [ %r,^spec_tests, , :spec ] ,
26- ]
14+ [ %r{^mongo/server} , :unit_server ] ,
15+ [ %r{^mongo} , :unit ] ,
16+ [ %r{^kerberos} , :unit ] ,
17+ [ %r{^integration/sdam_error_handling} , :sdam_integration ] ,
18+ [ %r{^integration/cursor_reaping} , :cursor_reaping ] ,
19+ [ %r{^integration/query_cache} , :query_cache ] ,
20+ [ %r{^integration/transactions_examples} , :tx_examples ] ,
21+ [ %r{^(atlas|integration)} , :integration ] ,
22+ [ %r{^spec_tests/sdam_integration} , :spec_sdam_integration ] ,
23+ [ %r{^spec_tests} , :spec ] ,
24+ ] . freeze
25+ # rubocop:enable Style/RegexpLiteral
2726
2827RUN_PRIORITY = ( ENV [ 'RUN_PRIORITY' ] || %(
2928 tx_examples
3029 unit unit_server
3130 integration sdam_integration cursor_reaping query_cache
3231 spec spec_sdam_integration
33- ) ) . split . map ( &:to_sym )
32+ ) ) . split . map ( &:to_sym ) . freeze
33+
34+ def spec_organizer
35+ require 'mrss/spec_organizer'
36+
37+ Mrss ::SpecOrganizer . new (
38+ root : ROOT ,
39+ classifiers : CLASSIFIERS ,
40+ priority_order : RUN_PRIORITY
41+ )
42+ end
3443
3544RSpec ::Core ::RakeTask . new ( :spec ) do |t |
36- #t.rspec_opts = " --profile 5" if ENV['CI']
45+ # t.rspec_opts = ' --profile 5' if ENV['CI']
3746end
3847
39- task : default => [ 'spec:prepare' , :spec ]
48+ task default : [ 'spec:prepare' , :spec ]
4049
4150desc 'Build the gem'
4251task :build do
@@ -46,12 +55,12 @@ task :build do
4655 system ( *command )
4756end
4857
49- # `rake version` is used by the deployment system so get the release version
50- # of the product beng deployed. It must do nothing more than just print the
58+ # `rake version` is used by the deployment system to get the release version
59+ # of the product being deployed. It must do nothing more than just print the
5160# product version number.
52- #
53- # See the mongodb-labs/driver-github-tools/ruby/publish Github action.
54- desc " Print the current value of Mongo::VERSION"
61+ #
62+ # See the mongodb-labs/driver-github-tools/ruby/publish GitHub action.
63+ desc ' Print the current value of Mongo::VERSION'
5564task :version do
5665 require 'mongo/version'
5766
6271# builds the gem. Our release process assumes the gem has already
6372# been built (and signed via GPG), so we just need `rake release` to
6473# push the gem to rubygems.
74+ desc 'Push the built gem to RubyGems. This should only be invoked from the Driver Release GitHub action.'
6575task :release do
6676 require 'mongo/version'
6777
@@ -82,14 +92,16 @@ task :release do
8292 system 'gem' , 'push' , "mongo-#{ Mongo ::VERSION } .gem"
8393end
8494
95+ desc 'Load the MongoDB Ruby driver. This is a prerequisite for many other tasks.'
8596task :mongo do
8697 require 'mongo'
8798end
8899
100+ # rubocop:disable Metrics/BlockLength
89101namespace :spec do
90102 desc 'Creates necessary user accounts in the cluster'
91103 task prepare : :mongo do
92- $: << File . join ( File . dirname ( __FILE__ ) , 'spec' )
104+ $LOAD_PATH << File . join ( File . dirname ( __FILE__ ) , 'spec' )
93105
94106 require 'support/utils'
95107 require 'support/spec_setup'
@@ -98,7 +110,7 @@ namespace :spec do
98110
99111 desc 'Waits for sessions to be available in the deployment'
100112 task wait_for_sessions : :mongo do
101- $: << File . join ( File . dirname ( __FILE__ ) , 'spec' )
113+ $LOAD_PATH << File . join ( File . dirname ( __FILE__ ) , 'spec' )
102114
103115 require 'support/utils'
104116 require 'support/spec_config'
@@ -108,21 +120,20 @@ namespace :spec do
108120 client . database . command ( ping : 1 )
109121 deadline = Process . clock_gettime ( Process ::CLOCK_MONOTONIC ) + 300
110122 loop do
111- begin
112- client . cluster . validate_session_support!
113- break
114- rescue Mongo ::Error ::SessionsNotSupported
115- if Process . clock_gettime ( Process ::CLOCK_MONOTONIC ) >= deadline
116- raise "Sessions did not become supported in 300 seconds"
117- end
118- client . cluster . scan!
123+ client . cluster . validate_session_support!
124+ break
125+ rescue Mongo ::Error ::SessionsNotSupported
126+ if Process . clock_gettime ( Process ::CLOCK_MONOTONIC ) >= deadline
127+ raise 'Sessions did not become supported in 300 seconds'
119128 end
129+
130+ client . cluster . scan!
120131 end
121132 end
122133
123134 desc 'Prints configuration used by the test suite'
124135 task config : :mongo do
125- $: << File . join ( File . dirname ( __FILE__ ) , 'spec' )
136+ $LOAD_PATH << File . join ( File . dirname ( __FILE__ ) , 'spec' )
126137
127138 # Since this task is usually used for troubleshooting of test suite
128139 # configuration, leave driver log level at the default of debug to
@@ -133,17 +144,7 @@ namespace :spec do
133144 SpecConfig . instance . print_summary
134145 end
135146
136- def spec_organizer
137- require 'mrss/spec_organizer'
138-
139- Mrss ::SpecOrganizer . new (
140- root : ROOT ,
141- classifiers : CLASSIFIERS ,
142- priority_order : RUN_PRIORITY ,
143- )
144- end
145-
146- task :ci => [ 'spec:prepare' ] do
147+ task ci : [ 'spec:prepare' ] do
147148 spec_organizer . run
148149 end
149150
@@ -154,6 +155,7 @@ namespace :spec do
154155 end
155156 end
156157end
158+ # rubocop:enable Metrics/BlockLength
157159
158160desc 'Build and validate the evergreen config'
159161task eg : %w[ eg:build eg:validate ]
@@ -181,11 +183,11 @@ namespace :eg do
181183 end
182184end
183185
184- desc " Generate all documentation"
185- task : docs => 'docs:yard'
186+ desc ' Generate all documentation'
187+ task docs : 'docs:yard'
186188
187189namespace :docs do
188- desc " Generate yard documention"
190+ desc ' Generate yard documentation'
189191 task :yard do
190192 out = File . join ( 'yard-docs' , Mongo ::VERSION )
191193 FileUtils . rm_rf ( out )
0 commit comments