Class: ReleaseVersions
- Inherits:
-
Object
- Object
- ReleaseVersions
- Defined in:
- lib/releases/release_versions.rb
Overview
Wrapper to interact with GitLab release versions. Versions are fetched from two sources:
-
versions.gitlab.com => Used to interact with previous GitLab versions
-
releases.yml => Used to interact with upcoming GitLab releases
Constant Summary collapse
- RETRY_INTERVAL =
The base interval for retrying operations that failed, in seconds.
5- RELEASES_YAML =
Releases.yml file.
'https://gitlab.com/gitlab-com/www-gitlab-com/-/raw/master/data/releases.yml'
Class Method Summary collapse
-
.active_version ⇒ Object
Returns the active minor GitLab Version.
-
.current_list ⇒ Object
Returns the list of versions from versions.gitlab.com.
-
.current_version ⇒ Object
Returns the current GitLab minor version.
-
.latest(versions, count = 3) ⇒ Object
Given an Array of version strings, find the ‘count` latest by minor number.
-
.next(versions) ⇒ Object
Given an Array of version numbers, return the next patch versions.
-
.next_versions ⇒ Object
Get the next three patch versions.
-
.previous_release_date ⇒ Object
Returns the release date of the current version.
-
.previous_version ⇒ Object
Returns the N-1 version supported based on the current_list.
- .sort(versions) ⇒ Object
-
.version_for_date(date) ⇒ Object
Returns the scheduled major.minor for the given date.
Class Method Details
.active_version ⇒ Object
Returns the active minor GitLab Version
72 73 74 |
# File 'lib/releases/release_versions.rb', line 72 def self.active_version version_for_date(DateTime.now) end |
.current_list ⇒ Object
Returns the list of versions from versions.gitlab.com
21 22 23 |
# File 'lib/releases/release_versions.rb', line 21 def self.current_list raw_versions.collect(&:version) end |
.current_version ⇒ Object
Returns the current GitLab minor version
58 59 60 |
# File 'lib/releases/release_versions.rb', line 58 def self.current_version ReleaseVersion.new(next_versions.first.to_minor) end |
.latest(versions, count = 3) ⇒ Object
Given an Array of version strings, find the ‘count` latest by minor number
versions - Array of version strings count - Number of versions to return (default: 3)
Example:
latest(['1.0.0', '1.1.0', '1.1.1', '1.2.3'], 3)
=> ['1.2.3', '1.1.1', '1.0.0']
51 52 53 54 55 |
# File 'lib/releases/release_versions.rb', line 51 def self.latest(versions, count = 3) ::VersionSorter.rsort(versions).uniq do |version| version.split('.').take(2) end.take(count) end |
.next(versions) ⇒ Object
Given an Array of version numbers, return the next patch versions
Example:
next(['1.0.0', '1.1.0', '1.1.1', '1.2.3'])
=> ['1.0.1', '1.1.1', '1.1.2', '1.2.4']
36 37 38 39 40 |
# File 'lib/releases/release_versions.rb', line 36 def self.next(versions) versions.map do |version| ReleaseVersion.new(version).next_patch end end |
.next_versions ⇒ Object
Get the next three patch versions
26 27 28 |
# File 'lib/releases/release_versions.rb', line 26 def self.next_versions self.next(latest(current_list, 3)) end |
.previous_release_date ⇒ Object
Returns the release date of the current version
63 64 65 66 67 68 69 |
# File 'lib/releases/release_versions.rb', line 63 def self.previous_release_date date = raw_versions .find { |version| version.version == "#{current_version}.0" } .created_at Date.parse(date) end |
.previous_version ⇒ Object
Returns the N-1 version supported based on the current_list
For example:
> current_list
> [“16.3.0”, “16.2.4”, “16.1.4”, “16.2.3”]
> previous_version
> [‘16.2.4’]
109 110 111 |
# File 'lib/releases/release_versions.rb', line 109 def self.previous_version ReleaseVersion.new(sort(current_list).reverse[1]) end |
.sort(versions) ⇒ Object
113 114 115 |
# File 'lib/releases/release_versions.rb', line 113 def self.sort(versions) ::VersionSorter.sort(versions).uniq end |
.version_for_date(date) ⇒ Object
Returns the scheduled major.minor for the given date
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/releases/release_versions.rb', line 77 def self.version_for_date(date) # Returns the release associated with the date by calling `releases_yaml` and fetching the # release whose date is greater than the given date. # # For example: # # | Version | Date | # |:--------|:---------------| # | 16.3 | August 22nd | # | 16.4 | September 22nd | # | 16.5 | October 22nd | # | 16.6 | November 16th | # | 16.7 | December 21st | # # * For August 21st, the release should be 16.3 # * For August 22nd, the release should be 16.4 # * For August 23rd, the release should be 16.4 # * For November 17th, the release should be 16.7 return nil if releases_yaml.empty? row = releases_yaml.find { |release| release['date'] > date } ReleaseVersion.new(row['version']) end |