rops 1.0.8 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4aaa2c9386c4426ae0e64d6c9136e208683d396af5175436e29105bd53be14f9
4
- data.tar.gz: 2ca5c4ff6f0ff34ccdadc1a09113a3d5e4ea61d9022bc8476bb37190ccab92ab
3
+ metadata.gz: 5a9aa4788d53d39e653cf9ebe46f3082962b2efecdef76f32fe4ac034fbc5699
4
+ data.tar.gz: b47e1bc75453e0e60e596f33893d651ed080e605135b46c73832ebd38291072a
5
5
  SHA512:
6
- metadata.gz: 4764f72f23aaa3c3a7694328cabfcea48b509fa109ae9af4487dc8b965b6c4060bb7a59d501a31eee9377983a6837da118c7fb75d1a1b497008a16678d72f17d
7
- data.tar.gz: c3249a2060872d2606b4118c8a21b173a5aeec58d19d81d2d38f2d21ce3995280f59e3cf0d23100e470b3facb57a416c343d84cca9f09271a1b768d208ab7828
6
+ metadata.gz: ad8c81d3214a90a5f59cf12cbdfd5457d0bb2a999bd6b6908617a4b881a6baf4f487ccbcec48de9209974f8c5bcda10fc68cfaef4b0321c3148b6cf889995202
7
+ data.tar.gz: a2898286981115871142e4058a04442c79c16dfee9ccb98d2afa49613dca4db4196fdc8e0fa7cef0cbb349b2635632b5ad9e34766de3b046f69f5c68401e1db4
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rops (1.0.8)
5
- activesupport (~> 6.1.4)
4
+ rops (1.2.0)
5
+ activesupport (~> 7.0.3)
6
6
  dry-cli (~> 0.7.0)
7
7
  git (~> 1.9.1)
8
8
  hashdiff (~> 1.0.1)
@@ -12,26 +12,24 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (6.1.4.1)
15
+ activesupport (7.0.3.1)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
21
- concurrent-ruby (1.1.9)
20
+ concurrent-ruby (1.1.10)
22
21
  dry-cli (0.7.0)
23
22
  git (1.9.1)
24
23
  rchardet (~> 1.8)
25
24
  hashdiff (1.0.1)
26
- i18n (1.8.10)
25
+ i18n (1.12.0)
27
26
  concurrent-ruby (~> 1.0)
28
- minitest (5.14.4)
27
+ minitest (5.16.2)
29
28
  net-ssh (6.1.0)
30
29
  ptools (1.4.2)
31
30
  rchardet (1.8.0)
32
- tzinfo (2.0.4)
31
+ tzinfo (2.0.5)
33
32
  concurrent-ruby (~> 1.0)
34
- zeitwerk (2.4.2)
35
33
 
36
34
  PLATFORMS
37
35
  x86_64-linux
data/bin/rops CHANGED
@@ -9,6 +9,7 @@ require 'hashdiff'
9
9
 
10
10
  require 'core_ext'
11
11
  require 'deployer'
12
+ require 'version'
12
13
 
13
14
  module Record360
14
15
  module Operations
@@ -38,6 +39,14 @@ module Record360
38
39
 
39
40
  protected
40
41
 
42
+ def format_commit(commit)
43
+ message = commit.message
44
+ if message.include?("\n")
45
+ message = message.split("\n").first + " ..."
46
+ end
47
+ "#{commit.date} [#{commit.sha[0,8]}] #{message}"
48
+ end
49
+
41
50
  def print_statuses(context, spec_statuses = nil)
42
51
  spec_statuses ||= deployer.specs_running(context)
43
52
  return if spec_statuses.blank?
@@ -139,6 +148,49 @@ module Record360
139
148
  end
140
149
  end
141
150
 
151
+ class ReadyTag < Dry::CLI::Command
152
+ desc "Mark your latest commit that's ready for production"
153
+ argument :commit, desc: "Commit to tag as ready for production"
154
+ include Common
155
+
156
+ def call(commit: nil, **args)
157
+ super(branch: commit, **args)
158
+ repo = deployer.send(:git)
159
+ name, email = repo.config.values_at('user.name', 'user.email')
160
+ if name.blank?
161
+ puts "Unable to find user name in Git config. Run `git config --global user.name \"FIRST_NAME LAST_NAME\"`"
162
+ exit(-1)
163
+ elsif email.blank?
164
+ puts "Unable to find user email in Git config. Run `git config --global user.email \"EMAIL_ADDRESS\"`"
165
+ exit(-1)
166
+ end
167
+ tag = 'ready-' + name.split(' ').first.downcase
168
+
169
+ if commit
170
+ c = repo.object(commit)
171
+ unless c.author.email == email
172
+ puts "Commit author #{c.author.name.inspect} does not match #{name.inspect}, you can only tag your own commit"
173
+ exit(-1)
174
+ end
175
+ repo.tag(tag, c, f: true)
176
+ puts "New tag set to: ", format_commit(c)
177
+
178
+ elsif repo.tags.map(&:name).include?(tag)
179
+ commits = repo.log.author(name).between("#{tag}^", 'master')
180
+ commits[0...-1].each do |c|
181
+ puts " " + format_commit(c)
182
+ end
183
+ puts "=> " + format_commit(commits.last)
184
+ else
185
+ puts "No #{tag.inspect} tag found"
186
+ repo.log.author(name).to_a[0..9].each do |c|
187
+ puts format_commit(c)
188
+ end
189
+ puts "..."
190
+ end
191
+ end
192
+ end
193
+
142
194
  class CurrentStatus < Dry::CLI::Command
143
195
  desc "Display status of all running specs"
144
196
  argument :context, desc: "Kubernetes context"
@@ -235,10 +287,19 @@ module Record360
235
287
  end
236
288
  end
237
289
 
290
+ class Version < Dry::CLI::Command
291
+ desc "output version information and exit"
292
+ def call
293
+ puts VERSION
294
+ end
295
+ end
296
+
297
+ register 'ready', ReadyTag
238
298
  register 'status', CurrentStatus
239
299
  register 'build', BuildImage
240
300
  register 'push', PushImage
241
301
  register 'deploy', DeployImage
302
+ register 'version', Version
242
303
  end
243
304
  end
244
305
 
data/lib/deployer.rb CHANGED
@@ -9,7 +9,7 @@ class Deployer
9
9
  CONFIG_DEFAULTS = {
10
10
  'repository' => nil,
11
11
  'default_branch' => 'master',
12
- 'registry' => 'r360',
12
+ 'registry' => 'docker.io/r360',
13
13
  'default_context' => 'staging',
14
14
  'production_context' => 'production',
15
15
  'images' => []
@@ -43,11 +43,7 @@ class Deployer
43
43
  @branch.delete_prefix!('g') if @branch.match(/^g\h{8}$/)
44
44
  @commit = git.object(@branch).sha
45
45
 
46
- short_id = @commit[0, 8]
47
- @image_tag = "g#{short_id}"
48
- if (@branch != default_branch) && !@branch.start_with?(short_id)
49
- @image_tag += "-#{@branch}"
50
- end
46
+ @image_tag = @commit[0, 8]
51
47
  images.each do |image|
52
48
  image.commit = commit
53
49
  image.tag = image_tag
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Record360
2
+ module Operations
3
+ VERSION = '1.3.0'
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2022-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.1.4
33
+ version: 7.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 6.1.4
40
+ version: 7.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: git
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -113,6 +113,7 @@ files:
113
113
  - lib/git_ext.rb
114
114
  - lib/image.rb
115
115
  - lib/site.rb
116
+ - lib/version.rb
116
117
  homepage: https://github.com/Record360/rops
117
118
  licenses:
118
119
  - MIT
@@ -132,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
133
  - !ruby/object:Gem::Version
133
134
  version: '0'
134
135
  requirements: []
135
- rubygems_version: 3.1.6
136
+ rubygems_version: 3.3.7
136
137
  signing_key:
137
138
  specification_version: 4
138
139
  summary: Record360 Operations tool