gantree 0.6.4 → 0.6.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
2
  SHA1:
3
- metadata.gz: c2d4478af044e2d416b405280f08feef34c35ec6
4
- data.tar.gz: 6c221680c7a3dcd83eb81e7d5bdfb1e1da9bb6f1
3
+ metadata.gz: fab5339982cb3099c8b0a393375b0700907f751a
4
+ data.tar.gz: d689ccf77086f35f6bea4cc3a7da1b69535029b8
5
5
  SHA512:
6
- metadata.gz: 178085f479f97562426be69b98a9362dd063b6a9889ac7f733d25a030bb10b13132e9f5f578158cd3c7a39b87469c5f58ad31c05b3e252ddb3a612fa6d4947c0
7
- data.tar.gz: a2dd894648cbe1670c55c74015880790da9040b24a9b5e194045ae03e0907b88ad34cac7cfe5ac1f674ea0486767ad08167c2413944511f0a9200d084eef9772
6
+ metadata.gz: 72ff98c01a21d02a83960a6dbc5d492f1c0b745fdacb3ecdc4c4339237151c1847657c43d44b020c2989d1cc7f57fa847953d50b9c109937dfcf58d15ff03580
7
+ data.tar.gz: e0ea01beb2ef7c3dbd302daf41e3253b54c25802a335afe0d55740fb2cbc5b94bd6160b4a96185ff3b417ce26086d8567cf78a85a4d2ca827f159e138df73fd0
data/lib/gantree/cli.rb CHANGED
@@ -18,6 +18,7 @@ module Gantree
18
18
  option :autodetect_app_role, :desc => "use naming convention to determin role (true|false)", :type => :boolean, :default => true
19
19
  option :eb_bucket, :desc => "bucket to store elastic beanstalk versions"
20
20
  option :auth, :desc => "dockerhub authentation, example: bucket/key"
21
+ option :release_notes_staging, :type => :boolean, :default => false, :desc => "force release notes generation for staging deploys"
21
22
  def deploy name
22
23
  opts = merge_defaults(options)
23
24
  Gantree::Base.check_for_updates(opts)
@@ -100,6 +101,7 @@ module Gantree
100
101
  option :hush, :desc => "quite puts messages", :default => true
101
102
  option :eb_bucket, :desc => "bucket to store elastic beanstalk versions"
102
103
  option :auth, :desc => "dockerhub authentation, example: bucket/key"
104
+ option :release_notes_staging, :type => :boolean, :default => false, :desc => "force release notes generation for staging deploys"
103
105
  def ship server
104
106
  opts = merge_defaults(options)
105
107
  Gantree::Base.check_for_updates(opts)
@@ -64,7 +64,7 @@ module Gantree
64
64
  return if @options[:dry_run]
65
65
  version = DeployVersion.new(@options, envs[0])
66
66
  @packaged_version = version.run
67
- puts @packaged_version
67
+ puts "packaged_version: #{@packaged_version}"
68
68
  upload_to_s3
69
69
  create_eb_version
70
70
  update_application(envs)
@@ -79,8 +79,9 @@ module Gantree
79
79
  Librato::Metrics.annotate :deploys, "deploys",:source => "#{@app}", :start_time => Time.now.to_i
80
80
  puts "Librato metric submitted"
81
81
  end
82
- if @options[:release_notes_wiki] == "enabled" && prod_deploy? && @app.include?("-app-")
83
- ReleaseNotes.new(@options[:release_notes_wiki], @app, new_hash).create
82
+ env = @envs.find {|e| e =~ /-app/ }
83
+ if env && @options[:release_notes_wiki] && (prod_deploy? || @options[:release_notes_staging])
84
+ ReleaseNotes.new(@options[:release_notes_wiki], env, @packaged_version).create
84
85
  `git tag #{tag}`
85
86
  `git push --tags`
86
87
  end
@@ -150,9 +151,6 @@ module Gantree
150
151
  def prod_deploy?
151
152
  @envs.first.split("-").first == "prod"
152
153
  end
153
- def new_hash
154
- @packaged_version.split("-")[2]
155
- end
156
154
  end
157
155
  end
158
156
 
@@ -49,9 +49,13 @@ module Gantree
49
49
  image
50
50
  end
51
51
 
52
+ def version_tag
53
+ @options[:tag] || tag
54
+ end
55
+
52
56
  def create_version_files
53
57
  clean_up
54
- version = "#{tag}-#{Time.now.strftime("%m-%d-%Y-%H-%M-%S")}"
58
+ version = "#{version_tag}-#{Time.now.strftime("%m-%d-%Y-%H-%M-%S")}"
55
59
  puts "version: #{version}"
56
60
  set_auth if @options[:auth]
57
61
  set_image_path if @options[:image_path]
@@ -4,11 +4,15 @@ module Gantree
4
4
  class ReleaseNotes
5
5
  attr_reader :current_sha
6
6
  attr_writer :beanstalk
7
- def initialize wiki, env_name, current_sha
7
+ def initialize(wiki, env_name, packaged_version)
8
8
  @env_name = env_name
9
9
  @wiki = wiki
10
10
  @org = wiki.split("/")[0..-2].join("/")
11
- @current_sha = current_sha
11
+ @packaged_version = packaged_version
12
+ end
13
+
14
+ def current_sha
15
+ @packaged_version.split("-")[2]
12
16
  end
13
17
 
14
18
  def beanstalk
@@ -35,8 +39,8 @@ module Gantree
35
39
  name.include?("-") ? name.split("-")[1] : name # TODO: business logic
36
40
  end
37
41
 
38
- def now
39
- @now ||= Time.now.strftime("%a, %e %b %Y %H:%M:%S %z")
42
+ def pacific_time
43
+ Time.now.strftime '%Y-%m-%d %a %I:%M%p PDT'
40
44
  end
41
45
 
42
46
  def commits
@@ -58,8 +62,12 @@ module Gantree
58
62
  @commits = commits.uniq.sort
59
63
  end
60
64
 
65
+ def commits_list
66
+ commits.collect{|x| "* #{x}" }.join("\n")
67
+ end
68
+
61
69
  def git_log
62
- execute("git log --no-merges --pretty=format:'%B COMMIT_SEPARATOR' #{@left}..#{@right}").strip
70
+ execute("git log --no-merges --pretty=format:'%B COMMIT_SEPARATOR' #{previous_sha}..#{current_sha}").strip
63
71
  end
64
72
 
65
73
  def execute(cmd)
@@ -69,9 +77,8 @@ module Gantree
69
77
  def notes
70
78
  compare = "#{previous_sha}...#{current_sha}"
71
79
  notes = <<-EOL
72
- "#{@env_name} #{now} [compare](#{@org}/#{app_name}/compare/#{compare})"
73
-
74
- #{commits.collect{|x| "* #{x}" }.join("\n")}
80
+ #{@env_name} #{pacific_time} [#{compare}](#{@org}/#{app_name}/compare/#{compare}) by #{ENV['USER']} (#{@packaged_version})
81
+ #{commits_list}
75
82
  EOL
76
83
  end
77
84
 
@@ -1,3 +1,3 @@
1
1
  module Gantree
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
data/lib/gantree/wiki.rb CHANGED
@@ -35,7 +35,7 @@ module Gantree
35
35
  data = IO.read(@file_path) if File.exist?(@file_path)
36
36
  File.open(@file_path, "w") do |file|
37
37
  file.write(@notes)
38
- file.write("\n\n")
38
+ file.write("\n")
39
39
  file.write(data) if data
40
40
  end
41
41
  true
@@ -4,8 +4,8 @@ describe Gantree::ReleaseNotes do
4
4
  before(:all) do
5
5
  @wiki = "https://github.com/br/dev.wiki.git"
6
6
  @env_name = "stag-rails-app-s1"
7
- @current_sha = "d961c96"
8
- @rn = Gantree::ReleaseNotes.new(@wiki, @env_name, @current_sha)
7
+ @packaged_version = "br-master-d961c96-06-17-2015-23-33-25.zip"
8
+ @rn = Gantree::ReleaseNotes.new(@wiki, @env_name, @packaged_version)
9
9
  @rn.beanstalk = Aws::ElasticBeanstalk::Client.new(stub_responses: true)
10
10
  end
11
11
 
@@ -27,7 +27,7 @@ describe Gantree::ReleaseNotes do
27
27
  end
28
28
 
29
29
  it "can retrieve the current sha" do
30
- expect(@rn.current_sha).to eq @current_sha
30
+ expect(@rn.current_sha).to eq "d961c96"
31
31
  end
32
32
 
33
33
  it "should generate notes" do
@@ -36,7 +36,7 @@ describe Gantree::ReleaseNotes do
36
36
  notes = @rn.notes
37
37
  puts notes if ENV['DEBUG']
38
38
  expect(notes).to include(@env_name)
39
- expect(notes).to include(@rn.now)
39
+ expect(notes).to include(@rn.pacific_time)
40
40
  expect(notes).to include("compare")
41
41
  expect(notes).to include("test up controller")
42
42
  end
@@ -28,11 +28,11 @@ describe Gantree::Wiki do
28
28
  FileUtils.rm_f(@wiki.file_path)
29
29
  @wiki.add_to_top
30
30
  notes = IO.read(@wiki.file_path)
31
- expect(notes).to eq "#{@notes}\n\n"
31
+ expect(notes).to eq "#{@notes}\n"
32
32
 
33
33
  @wiki.add_to_top
34
34
  notes = IO.read(@wiki.file_path)
35
- expect(notes).to eq "#{@notes}\n\n#{@notes}\n\n"
35
+ expect(notes).to eq "#{@notes}\n#{@notes}\n"
36
36
  end
37
37
 
38
38
  it "should push" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gantree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix