prima-twig 0.19.2 → 0.20.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/twig-feature +82 -23
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ba9a6d7425f22e393f9d2c78070bb129a54ff21
4
- data.tar.gz: 9cd513a0fde792ec9a35e9a56ac8bf6938fe45cb
3
+ metadata.gz: ffcc05b78f95000670afe0f5ba654ea3698003be
4
+ data.tar.gz: 3d17ffcd0e78764f3bf116c52c42af963ffafc16
5
5
  SHA512:
6
- metadata.gz: cd261a0af311ee25cc8a0a37da4919e1dbe9b892895bde9c6735421fa09a62252d782229400fe0871ddacdfe0461721a4148ea88eb24ef0f368099e6f685a2bf
7
- data.tar.gz: 9b1496d6ab4eb4255b4a9caf00ab301c2e2135e086834acb89fa28a51f8f3c3a0c899bdc226905d4b8d0895993e998d385a115d6fa11bb18ca88db4786b18299
6
+ metadata.gz: d60454ea17bab67ed7579da4180b8ce82ac4583e1cc4f1466ab3dd65aa759f5976118a542e37047ad8664d0575326902c8dad560c2e3d7802f93d2248b2436ed
7
+ data.tar.gz: 6ed10152692d50cdc07d32b4c2430e41ed2aca5821a26905bef5fe2ff2d8e7904aaea76b5acab7b8fe95efeda746b4038432bd2e4e7b2e7d4a59c10fb455dcd8
data/bin/twig-feature CHANGED
@@ -44,15 +44,19 @@ class Release
44
44
  when "deploy"
45
45
  if ['terminate', 'stop', 'shutdown', 'halt', 'destroy'].include? args[1]
46
46
  deploy_shutdown!
47
+ elsif "update" == args[1]
48
+ deploy_update!
47
49
  else
48
50
  if args[1]
49
- deploy_feature! args[1]
51
+ select_branches(args[1])
52
+ deploy_feature!
50
53
  else
54
+ select_branches
51
55
  deploy_feature!
52
56
  end
53
57
  end
54
58
  else
55
- stop_if true, [:wrong_args, ['start', 'finish', 'deploy', 'deploy stop']]
59
+ stop_if true, [:wrong_args, ['start', 'finish', 'deploy', 'deploy stop', 'deploy update']]
56
60
  end
57
61
  end
58
62
 
@@ -89,13 +93,7 @@ class Release
89
93
 
90
94
  def deploy_shutdown!
91
95
  output "Recupero le informazioni sui QA attivi..."
92
- envs = {}
93
- stack_list.each do |stack|
94
- unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
95
- env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
96
- envs[env_hash] = stack.tags unless envs.has_key?(env_hash)
97
- end
98
- end
96
+ stack_list, envs = get_stacks()
99
97
 
100
98
  env_hash = nil
101
99
  unless envs.empty?
@@ -135,12 +133,45 @@ class Release
135
133
  output "Finito!".green
136
134
  end
137
135
 
138
- def deploy_feature!(project_name = nil)
139
- output "Deploy feature menu"
136
+ def deploy_update!
137
+ output "Deploy update menu"
140
138
  `sudo true` # cosi' non chiede la password dopo
141
139
  `git pull && git submodule init && git submodule update`
142
140
 
143
- select_branches(project_name)
141
+ output "Recupero le informazioni sui QA attivi..."
142
+ stack_list, envs = get_stacks()
143
+
144
+ env_hash = nil
145
+ unless envs.empty?
146
+ env_hash = choose do |menu|
147
+ menu.prompt = "Scegli il QA che vuoi aggiornare: ".cyan
148
+ menu.shell = true
149
+ envs.each do |key, env|
150
+ title = ""
151
+ env.each do |e|
152
+ title << "\n#{e.key.upcase}: #{e.value}"
153
+ end
154
+ msg = "#{@prima.reduce_size(title, 1000)}".light_blue
155
+ menu.choice(msg) { key }
156
+ end
157
+ end
158
+ else
159
+ output "Nessun QA trovato".red
160
+ exit
161
+ end
162
+
163
+ envs[env_hash].each do |env|
164
+ @projects[env.key] = select_branch_to_deploy(env.key, env.value)
165
+ end
166
+
167
+ deploy_feature!
168
+
169
+ output "Finito!".green
170
+ end
171
+
172
+ def deploy_feature!
173
+ `sudo true` # cosi' non chiede la password dopo
174
+ `git pull && git submodule init && git submodule update`
144
175
 
145
176
  deploy_id = Digest::MD5.hexdigest(@projects["prima"][:name] + @projects["backoffice"][:name] + @projects["urania"][:name] + @projects["ermes"][:name] + @projects["bburago"][:name] + @projects["hal9000"][:name] + @projects["fidaty"][:name])
146
177
  @dns_record_identifier = deploy_id
@@ -639,7 +670,7 @@ class Release
639
670
 
640
671
  def create_urania_artifact(revision)
641
672
  @urania_built = true
642
- output "Preparo l'artifact .zip\n".yellow
673
+ output "Preparo l'artifact urania .zip\n".yellow
643
674
 
644
675
  git_checkout_version('urania', revision)
645
676
 
@@ -673,7 +704,7 @@ class Release
673
704
 
674
705
  def create_ermes_artifact(revision)
675
706
  @ermes_built = true
676
- output "Preparo l'artifact .zip\n".yellow
707
+ output "Preparo l'artifact ermes .zip\n".yellow
677
708
 
678
709
  git_checkout_version('ermes', revision)
679
710
 
@@ -707,7 +738,7 @@ class Release
707
738
 
708
739
  def create_bburago_artifact(revision)
709
740
  @bburago_built = true
710
- output "Preparo l'artifact .zip\n".yellow
741
+ output "Preparo l'artifact bburago .zip\n".yellow
711
742
 
712
743
  git_checkout_version('bburago', revision)
713
744
 
@@ -741,7 +772,7 @@ class Release
741
772
 
742
773
  def create_hal9000_artifact(revision)
743
774
  @hal9000_built = true
744
- output "Preparo l'artifact .zip\n".yellow
775
+ output "Preparo l'artifact hal9000 .zip\n".yellow
745
776
 
746
777
  git_checkout_version('hal9000', revision)
747
778
 
@@ -778,7 +809,7 @@ class Release
778
809
 
779
810
  def create_fidaty_artifact(revision, deploy_id)
780
811
  @fidaty_built = true
781
- output "Preparo l'artifact .zip\n".yellow
812
+ output "Preparo l'artifact fidaty .zip\n".yellow
782
813
 
783
814
  git_checkout_version('fidaty', revision)
784
815
 
@@ -817,7 +848,7 @@ class Release
817
848
 
818
849
  def create_backoffice_artifact(revision, deploy_id)
819
850
  @backoffice_built = true
820
- output "Preparo l'artifact .zip\n".yellow
851
+ output "Preparo l'artifact backoffice .zip\n".yellow
821
852
 
822
853
  git_checkout_version('backoffice', revision)
823
854
 
@@ -861,7 +892,7 @@ class Release
861
892
 
862
893
  def create_prima_artifact(revision, branch_name, deploy_id)
863
894
  @prima_built = true
864
- output "Preparo l'artifact .zip\n".yellow
895
+ output "Preparo l'artifact prima .zip\n".yellow
865
896
 
866
897
  git_checkout_version('prima', revision)
867
898
 
@@ -1106,11 +1137,38 @@ class Release
1106
1137
  { name: name, revision: revision[0..14] }
1107
1138
  end
1108
1139
 
1140
+ def select_branch_to_deploy(project_name, branch_name)
1141
+ Dir.chdir "projects/#{project_name}"
1142
+ output "Recupero il branch #{project_name}:#{branch_name} ..."
1143
+ out = %x[ git fetch ]
1144
+ branch_name = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname)' | sed 's/refs\\/remotes\\/origin\\///g' ]
1145
+ .split("\n").delete_if { |b| !b.include?(branch_name) }[0..49]
1146
+ .first
1147
+
1148
+ Dir.chdir "../../"
1149
+
1150
+ name = branch_name.split(' ').first
1151
+ revision = branch_name.split(' ').last
1152
+ { name: name, revision: revision[0..14] }
1153
+ end
1154
+
1109
1155
  def is_branch_compatible_with_current_twig_version?
1110
1156
  File.readlines("bin/local_build_artifact.sh").grep(/DEPLOY_ID=\$4/).size > 0
1111
1157
  end
1112
1158
 
1159
+ def get_stacks()
1160
+ envs = {}
1161
+ stack_list.each do |stack|
1162
+ unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
1163
+ env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
1164
+ envs[env_hash] = stack.tags unless envs.has_key?(env_hash)
1165
+ end
1166
+ end
1167
+ return stack_list, envs
1168
+ end
1169
+
1113
1170
  def select_branches(project_name = nil)
1171
+ output "Deploy feature menu"
1114
1172
  if project_name.nil?
1115
1173
  @projects["prima"] = choose_branch_to_deploy('prima')
1116
1174
  @projects["backoffice"] = choose_branch_to_deploy('backoffice')
@@ -1148,10 +1206,11 @@ Synopsis
1148
1206
  Description
1149
1207
  -----------
1150
1208
 
1151
- start creates a new feature branch
1152
- finish finishes the feature by merging to dev and master
1153
- deploy deploys the feature branch to a temporary AWS Elastic Beanstalk env
1154
- deploy stop destroys the AWS Elastic Beanstalk env
1209
+ start creates a new feature branch
1210
+ finish finishes the feature by merging to dev and master
1211
+ deploy deploys the feature branch to a temporary AWS Elastic Beanstalk env
1212
+ deploy stop destroys the AWS Elastic Beanstalk env
1213
+ deploy update updates a feature branch with current branches
1155
1214
 
1156
1215
  Subcommand for Twig: <http://rondevera.github.io/twig/>
1157
1216
  Author: Andrea Usuelli <https://github.com/andreausu>
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prima-twig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.2
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Giachino
8
8
  - Antonio Murdaca
9
9
  - Alessandro Nuzzo
10
10
  - Andrea Usuelli
11
+ - Simone Quaini
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2017-04-21 00:00:00.000000000 Z
15
+ date: 2017-04-26 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: twig