releasecop 0.0.4 → 0.0.5

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
- SHA1:
3
- metadata.gz: c52b5d851e1d82c6581b8639b55f0b091abc7053
4
- data.tar.gz: 9d5cfdebc66eb5e3465d74fbc33c11ab79b90026
2
+ SHA256:
3
+ metadata.gz: 7dd985648928239cfa8aeb5b928a96d45ce23e8664b7b89204966f435cc2be8f
4
+ data.tar.gz: dd2fae3fdbd696d77cad1dbb144b8808d80828850d722b9302d897e34bc7e1ff
5
5
  SHA512:
6
- metadata.gz: 82cd9904b61996b94b6e2840a8fe5055ac4798554e05cb858da4457d46e84d0e27a52f118f524d07ac71d3a19caef0153c126b58997ea56e7e3d432312f1a05b
7
- data.tar.gz: daf19f8bba5a58b9894391267f4a69e63c4d10c9ff9f62bd0826ad7765b282210159f018d0084a0bc67d57ae3f5af8ad1dc4d054d7139f208885329c5004ed75
6
+ metadata.gz: 26d8e1ff98357d04d30e1c39443aa4dec017c65180f0bbbde4a0fdf0dc3faa52134eecb0d6c07756ba5374a18e2f9f8c8b290cb5724bd3f045b9cee4b2f51a6a
7
+ data.tar.gz: 1cc9a25fee8f82ee0bdab9e1842cf2fb24bc6cc9d77203a66d93c3e26d57152010f34b0e3b17542f7a1b9c7c8b86ac7086fdd27467bee46e6331a63b5e44a80a
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ (Next)
2
+ ------------
3
+
4
+ * Your contribution here.
5
+
6
+ 0.0.5 (2018-04-24)
7
+ ------------------
8
+
9
+ * [#5](https://github.com/joeyAghion/releasecop/pull/5): Add support for Hokusai ([@ashkan18](https://github.com/ashkan18))
data/README.md CHANGED
@@ -12,7 +12,7 @@ Open the manifest file, which defines projects to monitor:
12
12
 
13
13
  releasecop edit
14
14
 
15
- In the manifest, each project lists the environments to which code is deployed _in order of promotion_. Environments are defined by a `name` and `git` remote. E.g., a github repo for development and heroku apps for staging and production. Optionally, an environment can include a `branch`. E.g.:
15
+ In the manifest, each project lists the environments to which code is deployed _in order of promotion_. Environments are defined by a `name` and `git` remote. E.g., a github repo for development and heroku apps for staging and production. Optionally, an environment can include `branch` or `hokusai` properties. E.g.:
16
16
 
17
17
  {
18
18
  "projects": {
@@ -53,5 +53,20 @@ To check all projects:
53
53
 
54
54
  At this time releasecop is not compatible with projects using [Heroku Pipelines](https://devcenter.heroku.com/articles/pipelines) to promote apps. For these apps, promoting a staging app to production simply copies the slug to the production app, so no git remote is updated.
55
55
 
56
+ ### Hokusai Pipelines
56
57
 
57
- Copyright (c) 2015 Joey Aghion, Artsy
58
+ [Hokusai](https://github.com/artsy/hokusai) is a tool developed by Artsy for managing apps on [Kubernetes](https://kubernetes.io/). Releasecop's manifest can include environments with a `hokusai` property containing a docker image tag corresponding to the pipeline stage. (The `hokusai` executable and access to the image repository must be available locally.) E.g.:
59
+
60
+ ```json
61
+ {
62
+ "test-api": [
63
+ {"name": "master", "git": "git@github.com:artsy/test-api.git" },
64
+ {"name": "staging", "git": "git@github.com:artsy/test-api.git", "hokusai": "staging"},
65
+ {"name": "production", "git": "git@github.com:artsy/test-api.git", "hokusai": "production"}
66
+ ]
67
+ }
68
+ ```
69
+
70
+ Releasecop will determine the git SHAs corresponding with each pipeline stage via the `hokusai registry images` command.
71
+
72
+ Copyright (c) 2015-2018 Joey Aghion, Artsy
@@ -4,17 +4,17 @@ module Releasecop
4
4
 
5
5
  def initialize(name, envs)
6
6
  self.name = name
7
- self.envs = envs
7
+ self.envs = envs.map { |e| ManifestItem.new(name, e) }
8
8
  end
9
9
 
10
10
  def check
11
11
  Dir.chdir(CONFIG_DIR) do
12
- `git clone #{envs.first['git']} --bare #{name} > /dev/null 2>&1`
12
+ `git clone #{envs.first.git} #{'--bare' if envs.none?{|e| e.hokusai_tag }} #{name} > /dev/null 2>&1`
13
13
 
14
14
  Dir.chdir(name) do
15
15
  envs.each do |env|
16
- `git remote add #{env['name']} #{env['git']} > /dev/null 2>&1`
17
- `git fetch #{env['name']} > /dev/null 2>&1`
16
+ `git remote add #{env.name} #{env.git} > /dev/null 2>&1`
17
+ `git fetch #{env.name} > /dev/null 2>&1`
18
18
  end
19
19
 
20
20
  comparisons = []
@@ -1,5 +1,5 @@
1
1
  class Comparison
2
- attr_accessor :lines
2
+ attr_accessor :lines, :behind, :ahead
3
3
 
4
4
  def initialize(ahead, behind)
5
5
  @ahead = ahead
@@ -10,10 +10,6 @@ class Comparison
10
10
  @lines = log.lines
11
11
  end
12
12
 
13
- def message
14
- [summary_message, *detail_messages].join
15
- end
16
-
17
13
  def unreleased?
18
14
  !lines.empty?
19
15
  end
@@ -21,42 +17,6 @@ class Comparison
21
17
  private
22
18
 
23
19
  def log
24
- `git log #{from_rev}..#{to_rev} --pretty=format:"%h %ad %s (%an)" --date=short --no-merges`
25
- end
26
-
27
- def from_rev
28
- [behind_name, behind_branch].join '/'
29
- end
30
-
31
- def to_rev
32
- [ahead_name, ahead_branch].join '/'
33
- end
34
-
35
- def behind_name
36
- @behind['name']
37
- end
38
-
39
- def behind_branch
40
- @behind['branch'] || 'master'
41
- end
42
-
43
- def ahead_name
44
- @ahead['name']
45
- end
46
-
47
- def ahead_branch
48
- @ahead['branch'] || 'master'
49
- end
50
-
51
- def summary_message
52
- if unreleased?
53
- " #{behind_name} is behind #{ahead_name} by:\n"
54
- else
55
- " #{behind_name} is up-to-date with #{ahead_name}"
56
- end
57
- end
58
-
59
- def detail_messages
60
- lines.map { |l| " #{l}" }
20
+ `git log #{@ahead.for_rev_range}..#{@behind.for_rev_range} --pretty=format:"%h %ad %s (%an)" --date=short --no-merges`
61
21
  end
62
22
  end
@@ -0,0 +1,28 @@
1
+ class ManifestItem
2
+ attr_reader :git, :branch, :name, :hokusai_tag
3
+
4
+ def initialize(repo_name, item)
5
+ @repo_name = repo_name
6
+ @git = item['git']
7
+ @name = item['name']
8
+ @branch = item['branch'] || 'master'
9
+ @hokusai_tag = item['hokusai']
10
+ end
11
+
12
+ def for_rev_range
13
+ @sha ||= find_hokusai_sha if @hokusai_tag
14
+ @sha || [@name, @branch].join('/')
15
+ end
16
+
17
+ private
18
+
19
+ def working_dir
20
+ "#{@repo_name}-#{@name}-working"
21
+ end
22
+
23
+ def find_hokusai_sha
24
+ images_output = `hokusai registry images`
25
+ tags = images_output.lines.grep(/\d{4}.* | .* | .*/).map{|l| l.split(' | ').last.split(',').map(&:strip)}
26
+ tags.detect{|t| t.include?(@hokusai_tag) }.detect{|t| t[/^[0-9a-f]{40}$/]}
27
+ end
28
+ end
@@ -31,6 +31,14 @@ class Result
31
31
  end
32
32
 
33
33
  def comparison_messages
34
- @comparisons.map &:message
34
+ @comparisons.map do |comparison|
35
+ summary = if comparison.unreleased?
36
+ " #{comparison.behind.name} is behind #{comparison.ahead.name} by:\n"
37
+ else
38
+ " #{comparison.behind.name} is up-to-date with #{comparison.ahead.name}"
39
+ end
40
+ detailed_messages = comparison.lines.map { |l| " #{l}" }
41
+ [summary, *detailed_messages].join
42
+ end
35
43
  end
36
44
  end
@@ -1,3 +1,3 @@
1
1
  module Releasecop
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/releasecop.rb CHANGED
@@ -2,6 +2,7 @@ require "releasecop/version"
2
2
  require 'thor'
3
3
  require 'shellwords'
4
4
  require 'json'
5
+ require 'releasecop/manifest_item'
5
6
  require "releasecop/comparison"
6
7
  require "releasecop/result"
7
8
  require "releasecop/checker"
data/releasecop.gemspec CHANGED
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.7"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "byebug"
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releasecop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Aghion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description:
56
70
  email:
57
71
  - joey@aghion.com
@@ -61,6 +75,7 @@ extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - ".gitignore"
78
+ - CHANGELOG.md
64
79
  - Gemfile
65
80
  - LICENSE.txt
66
81
  - README.md
@@ -70,6 +85,7 @@ files:
70
85
  - lib/releasecop/checker.rb
71
86
  - lib/releasecop/cli.rb
72
87
  - lib/releasecop/comparison.rb
88
+ - lib/releasecop/manifest_item.rb
73
89
  - lib/releasecop/result.rb
74
90
  - lib/releasecop/version.rb
75
91
  - releasecop.gemspec
@@ -93,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
109
  version: '0'
94
110
  requirements: []
95
111
  rubyforge_project:
96
- rubygems_version: 2.6.8
112
+ rubygems_version: 2.7.3
97
113
  signing_key:
98
114
  specification_version: 4
99
115
  summary: Given a list of projects and environments pipelines, report which environments