mongoid 7.5.4 → 7.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/Rakefile +85 -46
- data/lib/mongoid/clients/factory.rb +4 -0
- data/lib/mongoid/contextual/mongo.rb +26 -1
- data/lib/mongoid/extensions/hash.rb +27 -1
- data/lib/mongoid/version.rb +5 -1
- data/spec/mongoid/clients/factory_spec.rb +31 -0
- data/spec/mongoid/config_spec.rb +1 -0
- data/spec/mongoid/contextual/mongo_spec.rb +10 -0
- data/spec/mongoid/copyable_spec.rb +1 -0
- data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +2 -1
- data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +2 -1
- data/spec/mongoid/extensions/hash_spec.rb +236 -0
- data/spec/mongoid/query_cache_spec.rb +2 -1
- data/spec/mongoid/serializable_spec.rb +7 -14
- data/spec/shared/CANDIDATE.md +28 -0
- data/spec/shared/lib/mrss/docker_runner.rb +8 -1
- data/spec/shared/lib/mrss/lite_constraints.rb +2 -2
- data/spec/shared/lib/mrss/release/candidate.rb +281 -0
- data/spec/shared/lib/mrss/release/product_data.rb +144 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +17 -24
- data/spec/shared/lib/mrss/spec_organizer.rb +32 -3
- data/spec/shared/lib/mrss/utils.rb +28 -6
- data/spec/shared/lib/tasks/candidate.rake +64 -0
- data/spec/shared/share/Dockerfile.erb +33 -107
- data/spec/shared/shlib/distro.sh +10 -0
- data/spec/shared/shlib/server.sh +60 -29
- data/spec/shared/shlib/set_env.sh +12 -71
- data/spec/support/expectations.rb +20 -17
- metadata +16 -38
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -3
|
@@ -528,13 +528,11 @@ describe Mongoid::Serializable do
|
|
|
528
528
|
end
|
|
529
529
|
|
|
530
530
|
it "includes the first relation" do
|
|
531
|
-
expect(relation_hash[0]).to include
|
|
532
|
-
{ "_id" => "kudamm", "street" => "Kudamm" }
|
|
531
|
+
expect(relation_hash[0]).to include({ "_id" => "kudamm", "street" => "Kudamm" })
|
|
533
532
|
end
|
|
534
533
|
|
|
535
534
|
it "includes the second relation" do
|
|
536
|
-
expect(relation_hash[1]).to include
|
|
537
|
-
{ "_id" => "tauentzienstr", "street" => "Tauentzienstr" }
|
|
535
|
+
expect(relation_hash[1]).to include( "_id" => "tauentzienstr", "street" => "Tauentzienstr" )
|
|
538
536
|
end
|
|
539
537
|
end
|
|
540
538
|
|
|
@@ -545,13 +543,11 @@ describe Mongoid::Serializable do
|
|
|
545
543
|
end
|
|
546
544
|
|
|
547
545
|
it "includes the first relation" do
|
|
548
|
-
expect(relation_hash[0]).to include
|
|
549
|
-
{ "_id" => "kudamm", "street" => "Kudamm" }
|
|
546
|
+
expect(relation_hash[0]).to include({ "_id" => "kudamm", "street" => "Kudamm" })
|
|
550
547
|
end
|
|
551
548
|
|
|
552
549
|
it "includes the second relation" do
|
|
553
|
-
expect(relation_hash[1]).to include
|
|
554
|
-
{ "_id" => "tauentzienstr", "street" => "Tauentzienstr" }
|
|
550
|
+
expect(relation_hash[1]).to include({ "_id" => "tauentzienstr", "street" => "Tauentzienstr" })
|
|
555
551
|
end
|
|
556
552
|
end
|
|
557
553
|
|
|
@@ -670,8 +666,7 @@ describe Mongoid::Serializable do
|
|
|
670
666
|
end
|
|
671
667
|
|
|
672
668
|
it "includes the specified relation" do
|
|
673
|
-
expect(relation_hash).to include
|
|
674
|
-
{ "_id" => "leo-marvin", "first_name" => "Leo", "last_name" => "Marvin" }
|
|
669
|
+
expect(relation_hash).to include({ "_id" => "Leo-Marvin", "first_name" => "Leo", "last_name" => "Marvin" })
|
|
675
670
|
end
|
|
676
671
|
end
|
|
677
672
|
|
|
@@ -682,8 +677,7 @@ describe Mongoid::Serializable do
|
|
|
682
677
|
end
|
|
683
678
|
|
|
684
679
|
it "includes the specified relation" do
|
|
685
|
-
expect(relation_hash).to include
|
|
686
|
-
{ "_id" => "leo-marvin", "first_name" => "Leo", "last_name" => "Marvin" }
|
|
680
|
+
expect(relation_hash).to include({ "_id" => "Leo-Marvin", "first_name" => "Leo", "last_name" => "Marvin" })
|
|
687
681
|
end
|
|
688
682
|
end
|
|
689
683
|
|
|
@@ -694,8 +688,7 @@ describe Mongoid::Serializable do
|
|
|
694
688
|
end
|
|
695
689
|
|
|
696
690
|
it "includes the specified relation sans exceptions" do
|
|
697
|
-
expect(relation_hash).to include
|
|
698
|
-
{ "first_name" => "Leo", "last_name" => "Marvin" }
|
|
691
|
+
expect(relation_hash).to include({ "first_name" => "Leo", "last_name" => "Marvin" })
|
|
699
692
|
end
|
|
700
693
|
end
|
|
701
694
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Candidate Tasks
|
|
2
|
+
|
|
3
|
+
When using the `candidate` rake tasks, you must make sure:
|
|
4
|
+
|
|
5
|
+
1. You are using at least `git` version 2.49.0.
|
|
6
|
+
2. You have the `gh` CLI tool installed.
|
|
7
|
+
3. You are logged into `gh` with an account that has collaborator access to the repository.
|
|
8
|
+
4. You have run `gh repo set-default` from the root of your local checkout to set the default repository to the canonical MongoDB repo.
|
|
9
|
+
5. The `origin` remote for your local checkout is set to your own fork.
|
|
10
|
+
6. The `upstream` remote for your local checkout is set to the canonical
|
|
11
|
+
MongoDB repo.
|
|
12
|
+
|
|
13
|
+
Once configured, you can use the following commands:
|
|
14
|
+
|
|
15
|
+
1. `rake candidate:prs` - This will list all pull requests that will be included in the next release. Any with `[?]` are unlabelled (or are not labelled with a recognized label). Otherwise, `[b]` means `bug`, `[f]` means `feature`, and `[x]` means `bcbreak`.
|
|
16
|
+
2. `rake candidate:preview` - This will generate and display the release notes for the next release, based on the associated pull requests.
|
|
17
|
+
3. `rake candidate:create` - This will create a new PR against the default repository, using the generated release notes as the description. The new PR will be given the `release-candidate` label.
|
|
18
|
+
|
|
19
|
+
Then, after the release candidate PR is approved and merged, the release process will automatically bundle, sign, and release the new version.
|
|
20
|
+
|
|
21
|
+
Once you've merged the PR, you can switch to the "Actions" tab for the repository on GitHub and look for the "Release" workflow (might be named differently), which should have triggered automatically. You can monitor the progress of the release there. If there are any problems, the workflow is generally safe to re-run after you've addressed them.
|
|
22
|
+
|
|
23
|
+
Things to do after the release succeeds:
|
|
24
|
+
|
|
25
|
+
1. Copy the release notes from the PR and create a new release announcement on the forums (https://www.mongodb.com/community/forums/c/announcements/driver-releases/110).
|
|
26
|
+
2. If the release was not automatically announced in #ruby, copy a link to the GitHub release or MongoDB forum post there.
|
|
27
|
+
3. Close the release in Jira.
|
|
28
|
+
|
|
@@ -195,12 +195,15 @@ module Mrss
|
|
|
195
195
|
'debian81' => 'debian:jessie',
|
|
196
196
|
'debian92' => 'debian:stretch',
|
|
197
197
|
'debian10' => 'debian:buster',
|
|
198
|
+
'debian11' => 'debian:bullseye',
|
|
198
199
|
'ubuntu1404' => 'ubuntu:trusty',
|
|
199
200
|
'ubuntu1604' => 'ubuntu:xenial',
|
|
200
201
|
'ubuntu1804' => 'ubuntu:bionic',
|
|
201
202
|
'ubuntu2004' => 'ubuntu:focal',
|
|
203
|
+
'ubuntu2204' => 'ubuntu:jammy',
|
|
202
204
|
'rhel62' => 'centos:6',
|
|
203
205
|
'rhel70' => 'centos:7',
|
|
206
|
+
'rhel80' => 'rockylinux:8',
|
|
204
207
|
}.freeze
|
|
205
208
|
|
|
206
209
|
def base_image
|
|
@@ -231,6 +234,10 @@ module Mrss
|
|
|
231
234
|
distro =~ /debian|ubuntu/
|
|
232
235
|
end
|
|
233
236
|
|
|
237
|
+
def ubuntu?
|
|
238
|
+
distro=~ /ubuntu/
|
|
239
|
+
end
|
|
240
|
+
|
|
234
241
|
def preload?
|
|
235
242
|
!!@options[:preload]
|
|
236
243
|
end
|
|
@@ -275,7 +282,7 @@ module Mrss
|
|
|
275
282
|
|
|
276
283
|
def num_exposed_ports
|
|
277
284
|
case @env['TOPOLOGY'] || 'standalone'
|
|
278
|
-
when 'standalone'
|
|
285
|
+
when 'standalone', 'replica-set-single-node'
|
|
279
286
|
1
|
|
280
287
|
when 'replica-set'
|
|
281
288
|
3
|
|
@@ -98,8 +98,8 @@ module Mrss
|
|
|
98
98
|
def min_libmongocrypt_version(version)
|
|
99
99
|
require_libmongocrypt
|
|
100
100
|
before(:all) do
|
|
101
|
-
actual_version =
|
|
102
|
-
min_version =
|
|
101
|
+
actual_version = Utils.parse_version(Mongo::Crypt::Binding.mongocrypt_version(nil))
|
|
102
|
+
min_version = Utils.parse_version(version)
|
|
103
103
|
unless actual_version >= min_version
|
|
104
104
|
skip "libmongocrypt version #{min_version} required, but version #{actual_version} is available"
|
|
105
105
|
end
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
require_relative 'product_data'
|
|
6
|
+
|
|
7
|
+
module Mrss
|
|
8
|
+
module Release
|
|
9
|
+
class Candidate
|
|
10
|
+
# Release note section titles, by pr type
|
|
11
|
+
SECTION_TITLE = {
|
|
12
|
+
bcbreak: "Breaking Changes",
|
|
13
|
+
feature: "New Features",
|
|
14
|
+
bug: "Bug Fixes",
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
# GitHub labels
|
|
18
|
+
BCBREAK = 'bcbreak'
|
|
19
|
+
FEATURE = 'feature'
|
|
20
|
+
BUG = 'bug'
|
|
21
|
+
PATCH = 'patch'
|
|
22
|
+
|
|
23
|
+
def self.instance
|
|
24
|
+
@instance ||= new
|
|
25
|
+
|
|
26
|
+
yield @instance if block_given?
|
|
27
|
+
|
|
28
|
+
@instance
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def product
|
|
32
|
+
@product ||= ProductData.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def bump_version
|
|
36
|
+
product.bump_version(release_type)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def bump_version!
|
|
40
|
+
product.bump_version!(release_type)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def branch_name
|
|
44
|
+
@branch_name ||= "rc-#{product.version}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# return a string of commit names since the last release
|
|
48
|
+
def pending_changes
|
|
49
|
+
@changes ||= begin
|
|
50
|
+
range = product.tag_exists? ? "#{product.tag_name}.." : ""
|
|
51
|
+
`git log --pretty=format:"%s" #{range}`
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# return a list of PR numbers since the last release
|
|
56
|
+
def pending_pr_numbers
|
|
57
|
+
@pending_pr_numbers ||= pending_changes.
|
|
58
|
+
lines.
|
|
59
|
+
map { |line| line.match(/\(#(\d+)\)$/).then { |m| m && m[1] } }.
|
|
60
|
+
compact.
|
|
61
|
+
sort.reverse
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# return a JSON string of PR data
|
|
65
|
+
def pending_pr_dump
|
|
66
|
+
@pending_pr_dump ||= `gh pr list --state all --limit 256 --json number,title,labels,url,body --jq 'map(select([.number] | inside([#{pending_pr_numbers.join(',')}]))) | sort_by(.number)'`
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# return a list of PR data since the last release
|
|
70
|
+
def pending_prs
|
|
71
|
+
@pending_prs ||= JSON.parse(pending_pr_dump)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# return a list of pending prs with additional attributes (summary,
|
|
75
|
+
# short title, jira issue number).
|
|
76
|
+
def decorated_prs
|
|
77
|
+
@decorated_prs ||= pending_prs.map do |pr|
|
|
78
|
+
jira_issue, pr_title = split_pr_title(pr)
|
|
79
|
+
summary = extract_summary(pr)
|
|
80
|
+
type = pr_type(pr)
|
|
81
|
+
type_code = pr_type_code(type)
|
|
82
|
+
patch_flag = pr_patch_flag?(pr)
|
|
83
|
+
|
|
84
|
+
pr.merge('jira' => jira_issue,
|
|
85
|
+
'short-title' => pr_title,
|
|
86
|
+
'summary' => summary,
|
|
87
|
+
'type' => type,
|
|
88
|
+
'type-code' => type_code,
|
|
89
|
+
'patch' => patch_flag)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# return a hash of decorated prs grouped by :bcbreak, :feature, or :bug
|
|
94
|
+
def prs_by_type
|
|
95
|
+
@prs_by_type ||= decorated_prs.group_by { |pr| pr['type'] }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# returns 'major', 'minor', or 'patch', depending on the presence of
|
|
99
|
+
# (respectively) :bcbreak, :feature, or :bug labels.
|
|
100
|
+
#
|
|
101
|
+
# If the RELEASE environment variable is set, its value will be used
|
|
102
|
+
# directly, ignoring whatever PR labels might exist.
|
|
103
|
+
def release_type
|
|
104
|
+
@release_type ||= if ENV['RELEASE']
|
|
105
|
+
ENV['RELEASE']
|
|
106
|
+
elsif prs_by_type[:bcbreak]
|
|
107
|
+
'major'
|
|
108
|
+
elsif prs_by_type[:feature] && prs_by_type[:feature].any? { |pr| !pr['patch'] }
|
|
109
|
+
'minor'
|
|
110
|
+
else
|
|
111
|
+
'patch'
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# returns the generated release notes as a string
|
|
116
|
+
def release_notes
|
|
117
|
+
@release_notes ||= release_notes_intro +
|
|
118
|
+
%i[ bcbreak feature bug ].
|
|
119
|
+
flat_map { |type| release_notes_for_type(type) }.join("\n")
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
# returns an array of strings, each string representing a single line
|
|
125
|
+
# in the release notes for the PR's of the given type.
|
|
126
|
+
def release_notes_for_type(type)
|
|
127
|
+
return [] unless prs_by_type[type]
|
|
128
|
+
|
|
129
|
+
[].tap do |lines|
|
|
130
|
+
lines << "\# #{SECTION_TITLE[type]}"
|
|
131
|
+
lines << ''
|
|
132
|
+
|
|
133
|
+
prs = prs_by_type[type]
|
|
134
|
+
summarized, unsummarized = prs.partition { |pr| pr['summary'] }
|
|
135
|
+
|
|
136
|
+
summarized.each do |pr|
|
|
137
|
+
header = [ '### ' ]
|
|
138
|
+
header << "[#{pr['jira']}](#{jira_url(pr['jira'])}) " if pr['jira']
|
|
139
|
+
header << "#{pr['short-title']} ([PR](#{pr['url']}))"
|
|
140
|
+
lines << header.join
|
|
141
|
+
lines << ''
|
|
142
|
+
lines << pr['summary']
|
|
143
|
+
lines << ''
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if summarized.any? && unsummarized.any?
|
|
147
|
+
lines << ''
|
|
148
|
+
lines << [ '### Other ', SECTION_TITLE[type] ].join
|
|
149
|
+
lines << ''
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
unsummarized.each do |pr|
|
|
153
|
+
line = [ '* ' ]
|
|
154
|
+
line << "[#{pr['jira']}](#{jira_url(pr['jira'])}) " if pr['jira']
|
|
155
|
+
line << "#{pr['short-title']} ([PR](#{pr['url']}))"
|
|
156
|
+
|
|
157
|
+
lines << line.join
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
lines << ''
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# returns the URL of for the given jira issue
|
|
165
|
+
def jira_url(issue)
|
|
166
|
+
"https://jira.mongodb.org/browse/#{issue}"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# assumes a pr title in the format of "JIRA-1234 PR Title (#1234)",
|
|
170
|
+
# returns a tuple of [ jira-issue, title ], where jira-issue may be
|
|
171
|
+
# blank (if no jira issue is in the title).
|
|
172
|
+
def split_pr_title(pr)
|
|
173
|
+
title = pr['title'].gsub(/\(#\d+\)/, '').strip
|
|
174
|
+
|
|
175
|
+
if title =~ /^(\w+-\d+) (.*)$/
|
|
176
|
+
[ $1, $2 ]
|
|
177
|
+
else
|
|
178
|
+
[ nil, title ]
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# extracts the summary section from the pr and returns it (or returns nil
|
|
183
|
+
# if no summary section is detected)
|
|
184
|
+
def extract_summary(pr)
|
|
185
|
+
summary = []
|
|
186
|
+
accumulating = false
|
|
187
|
+
level = nil
|
|
188
|
+
|
|
189
|
+
pr['body'].lines.each do |line|
|
|
190
|
+
# a header of any level titled "summary" will begin the summary
|
|
191
|
+
if !accumulating && line =~ /^(\#+)\s+summary\s+$/i
|
|
192
|
+
accumulating = true
|
|
193
|
+
level = $1.length
|
|
194
|
+
|
|
195
|
+
# a header of any level less than or equal to the summary header's
|
|
196
|
+
# level will end the summary
|
|
197
|
+
elsif accumulating && line =~ /^\#{1,#{level}}\s+/
|
|
198
|
+
break
|
|
199
|
+
|
|
200
|
+
# otherwise, the line is part of the summary
|
|
201
|
+
elsif accumulating
|
|
202
|
+
summary << line
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
summary.any? ? summary.join.strip : nil
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Returns a symbol (:bcbreak, :feature, or :bug) that identifies the
|
|
210
|
+
# type of this PR that would most strongly influence what type of release
|
|
211
|
+
# it requires.
|
|
212
|
+
def pr_type(pr)
|
|
213
|
+
if pr['labels'].any? { |l| l['name'] == BCBREAK }
|
|
214
|
+
:bcbreak
|
|
215
|
+
elsif pr['labels'].any? { |l| l['name'] == FEATURE }
|
|
216
|
+
:feature
|
|
217
|
+
elsif pr['labels'].any? { |l| l['name'] == BUG }
|
|
218
|
+
:bug
|
|
219
|
+
else
|
|
220
|
+
nil
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# `true` if the `patch` label is applied to the PR. This is used to
|
|
225
|
+
# indicate that a "feature" PR should be treated as a patch, for
|
|
226
|
+
# determining the release type only.
|
|
227
|
+
def pr_patch_flag?(pr)
|
|
228
|
+
pr['labels'].any? { |l| l['name'] == PATCH }
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def pr_type_code(type)
|
|
232
|
+
case type
|
|
233
|
+
when :bcbreak then 'x'
|
|
234
|
+
when :feature then 'f'
|
|
235
|
+
when :bug then 'b'
|
|
236
|
+
else '?'
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def series
|
|
241
|
+
major, minor, = product.version_parts
|
|
242
|
+
|
|
243
|
+
case release_type
|
|
244
|
+
when 'minor' then
|
|
245
|
+
"#{major}.x"
|
|
246
|
+
when 'patch' then
|
|
247
|
+
"#{major}.#{minor}.x"
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Return a string containing the markdown-formatted intro block for
|
|
252
|
+
# the release notes of this candidate.
|
|
253
|
+
def release_notes_intro
|
|
254
|
+
release_description = case release_type
|
|
255
|
+
when 'major' then 'major release'
|
|
256
|
+
when 'minor' then "minor release in the #{series} series"
|
|
257
|
+
when 'patch' then "patch release in the #{series} series"
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
<<~INTRO
|
|
261
|
+
The MongoDB Ruby team is pleased to announce version #{product.version} of the `#{product.package}` gem - #{product.description}. This is a new #{release_description} of #{product.name}.
|
|
262
|
+
|
|
263
|
+
Install this release using [RubyGems](https://rubygems.org/) via the command line as follows:
|
|
264
|
+
|
|
265
|
+
~~~
|
|
266
|
+
gem install -v #{product.version} #{product.package}
|
|
267
|
+
~~~
|
|
268
|
+
|
|
269
|
+
Or simply add it to your `Gemfile`:
|
|
270
|
+
|
|
271
|
+
~~~
|
|
272
|
+
gem '#{product.package}', '#{product.version}'
|
|
273
|
+
~~~
|
|
274
|
+
|
|
275
|
+
Have any feedback? Click on through to MongoDB's JIRA and [open a new ticket](#{product.jira_project_url}) to let us know what's on your mind 🧠.
|
|
276
|
+
|
|
277
|
+
INTRO
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
module Mrss
|
|
6
|
+
module Release
|
|
7
|
+
class ProductData
|
|
8
|
+
FILE_PATH = 'product.yml'
|
|
9
|
+
|
|
10
|
+
def self.init!
|
|
11
|
+
if File.exist?(FILE_PATH)
|
|
12
|
+
raise "#{FILE_PATH} already exists; refusing to overwrite it"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
initial_data = {
|
|
16
|
+
'name' => 'Product Name',
|
|
17
|
+
'description' => 'a very short description of the product',
|
|
18
|
+
'package' => 'product_package',
|
|
19
|
+
'jira' => 'https://url.to.jira/project',
|
|
20
|
+
'version' => { 'number' => '1.0.0',
|
|
21
|
+
'file' => 'path/to/version.rb' }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
File.write(FILE_PATH, initial_data.to_yaml)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def initialize
|
|
28
|
+
@hash = YAML.load_file(FILE_PATH)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def save_product_file!
|
|
32
|
+
File.write(FILE_PATH, @hash.to_yaml)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def rewrite_version_file!
|
|
36
|
+
version_module = File.read(version_file)
|
|
37
|
+
new_module = version_module.
|
|
38
|
+
sub(/^(\s*)(VERSION\s*=\s*).*$/) { "#{$1}#{$2}#{quoted_version}" }
|
|
39
|
+
File.write(version_file, new_module)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def version
|
|
43
|
+
@hash['version']['number']
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def quoted_version
|
|
47
|
+
if version.include?("'")
|
|
48
|
+
version.inspect
|
|
49
|
+
else
|
|
50
|
+
"'#{version}'"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def version=(number)
|
|
55
|
+
@hash['version']['number'] = number
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# returns an array of [ major, minor, patch, suffix ].
|
|
59
|
+
#
|
|
60
|
+
# each element will be returned as a String.
|
|
61
|
+
def version_parts
|
|
62
|
+
version.split(/\./, 4)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# bump the version according to the given release type:
|
|
66
|
+
#
|
|
67
|
+
# 'major' -> increment major component, zero the others
|
|
68
|
+
# 'minor' -> increment minor component, zero the patch
|
|
69
|
+
# 'patch' -> increment the patch component
|
|
70
|
+
def bump_version(release)
|
|
71
|
+
major, minor, patch, suffix = version_parts
|
|
72
|
+
|
|
73
|
+
case release
|
|
74
|
+
when 'major' then
|
|
75
|
+
major = major.to_i + 1
|
|
76
|
+
minor = patch = 0
|
|
77
|
+
when 'minor'
|
|
78
|
+
minor = minor.to_i + 1
|
|
79
|
+
patch = 0
|
|
80
|
+
when 'patch'
|
|
81
|
+
patch = patch.to_i + 1
|
|
82
|
+
else
|
|
83
|
+
raise ArgumentError, "invalid release type: #{release.inspect}"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
self.version = [ major, minor, patch ].join('.')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Invokes `#bump_version`, and then saves the new version to the
|
|
90
|
+
# product.yml file and to the version.rb file.
|
|
91
|
+
def bump_version!(release)
|
|
92
|
+
bump_version(release)
|
|
93
|
+
save_product_file!
|
|
94
|
+
rewrite_version_file!
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def version_file
|
|
98
|
+
@hash['version']['file']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def name
|
|
102
|
+
@hash['name']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# The description is intended to be used in places where it can be
|
|
106
|
+
# appended to the end of a sentence, e.g.
|
|
107
|
+
#
|
|
108
|
+
# "We just released #{product.name} - #{product.description}!"
|
|
109
|
+
#
|
|
110
|
+
# Markdown formatting is allowed (even expected).
|
|
111
|
+
def description
|
|
112
|
+
@hash['description']
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def package
|
|
116
|
+
@hash['package']
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def jira_project_url
|
|
120
|
+
@hash['jira']
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def tag_name
|
|
124
|
+
"v#{version}"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def tag_exists?(tag = tag_name)
|
|
128
|
+
`git tag -l #{tag}`.strip == tag
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def branch_exists?(branch)
|
|
132
|
+
`git branch -l #{branch}`.strip == branch
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def base_branch
|
|
136
|
+
@base_branch ||= begin
|
|
137
|
+
major, minor, = version_parts
|
|
138
|
+
branch = "#{major}.#{minor}-stable"
|
|
139
|
+
branch_exists?(branch) ? branch : 'master'
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -19,11 +19,26 @@ module Mrss
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def initialize(desired_version, arch)
|
|
22
|
-
@desired_version, @arch = desired_version, arch
|
|
22
|
+
@desired_version, @arch = desired_version, arch.sub(/-arm$/, '')
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
attr_reader :desired_version, :arch
|
|
26
26
|
|
|
27
|
+
def target_arch
|
|
28
|
+
# can't use RbConfig::CONFIG["arch"] because JRuby doesn't
|
|
29
|
+
# return anything meaningful there.
|
|
30
|
+
#
|
|
31
|
+
# also, need to use `uname -a` instead of (e.g.) `uname -p`
|
|
32
|
+
# because debian (at least) does not return anything meaningful
|
|
33
|
+
# for `uname -p`.
|
|
34
|
+
uname = `uname -a`.strip
|
|
35
|
+
@target_arch ||= case uname
|
|
36
|
+
when /aarch/ then "aarch64"
|
|
37
|
+
when /x86/ then "x86_64"
|
|
38
|
+
else raise "unsupported architecture #{uname.inspect}"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
27
42
|
def download_url
|
|
28
43
|
@download_url ||= begin
|
|
29
44
|
version, version_ok = detect_version(current_catalog)
|
|
@@ -40,35 +55,13 @@ module Mrss
|
|
|
40
55
|
end
|
|
41
56
|
dl = version['downloads'].detect do |dl|
|
|
42
57
|
dl['archive']['url'].index("enterprise-#{arch}") &&
|
|
43
|
-
dl['arch'] ==
|
|
58
|
+
dl['arch'] == target_arch
|
|
44
59
|
end
|
|
45
60
|
unless dl
|
|
46
61
|
raise MissingDownloadUrl, "No download for #{arch} for #{version['version']}"
|
|
47
62
|
end
|
|
48
63
|
url = dl['archive']['url']
|
|
49
64
|
end
|
|
50
|
-
rescue MissingDownloadUrl
|
|
51
|
-
if %w(2.6 3.0).include?(desired_version) && arch == 'ubuntu1604'
|
|
52
|
-
# 2.6 and 3.0 are only available for ubuntu1204 and ubuntu1404.
|
|
53
|
-
# Those ubuntus have ancient Pythons that don't work due to not
|
|
54
|
-
# implementing recent TLS protocols.
|
|
55
|
-
# Because of this we test on ubuntu1604 which has a newer Python.
|
|
56
|
-
# But we still need to retrieve ubuntu1404-targeting builds.
|
|
57
|
-
url = self.class.new('3.2', arch).download_url
|
|
58
|
-
unless url.include?('3.2.')
|
|
59
|
-
raise 'URL not in expected format'
|
|
60
|
-
end
|
|
61
|
-
url = case desired_version
|
|
62
|
-
when '2.6'
|
|
63
|
-
url.sub(/\b3\.2\.\d+/, '2.6.12')
|
|
64
|
-
when '3.0'
|
|
65
|
-
url.sub(/\b3\.2\.\d+/, '3.0.15')
|
|
66
|
-
else
|
|
67
|
-
raise NotImplementedError
|
|
68
|
-
end.sub('ubuntu1604', 'ubuntu1404')
|
|
69
|
-
else
|
|
70
|
-
raise
|
|
71
|
-
end
|
|
72
65
|
end
|
|
73
66
|
|
|
74
67
|
private
|