releasecop 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +9 -0
- data/README.md +17 -2
- data/lib/releasecop/checker.rb +4 -4
- data/lib/releasecop/comparison.rb +2 -42
- data/lib/releasecop/manifest_item.rb +28 -0
- data/lib/releasecop/result.rb +9 -1
- data/lib/releasecop/version.rb +1 -1
- data/lib/releasecop.rb +1 -0
- data/releasecop.gemspec +1 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7dd985648928239cfa8aeb5b928a96d45ce23e8664b7b89204966f435cc2be8f
|
4
|
+
data.tar.gz: dd2fae3fdbd696d77cad1dbb144b8808d80828850d722b9302d897e34bc7e1ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26d8e1ff98357d04d30e1c39443aa4dec017c65180f0bbbde4a0fdf0dc3faa52134eecb0d6c07756ba5374a18e2f9f8c8b290cb5724bd3f045b9cee4b2f51a6a
|
7
|
+
data.tar.gz: 1cc9a25fee8f82ee0bdab9e1842cf2fb24bc6cc9d77203a66d93c3e26d57152010f34b0e3b17542f7a1b9c7c8b86ac7086fdd27467bee46e6331a63b5e44a80a
|
data/CHANGELOG.md
ADDED
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
|
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
|
-
|
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
|
data/lib/releasecop/checker.rb
CHANGED
@@ -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
|
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
|
17
|
-
`git fetch #{env
|
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 #{
|
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
|
data/lib/releasecop/result.rb
CHANGED
@@ -31,6 +31,14 @@ class Result
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def comparison_messages
|
34
|
-
@comparisons.map
|
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
|
data/lib/releasecop/version.rb
CHANGED
data/lib/releasecop.rb
CHANGED
data/releasecop.gemspec
CHANGED
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
|
+
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:
|
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.
|
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
|