prima-twig 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/twig-deploy +2 -0
- data/bin/twig-feature +116 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8f3302672ccbe55e5f1fd3e321deb2abf1f0b7
|
4
|
+
data.tar.gz: cd6feed732ec5babb3736d7d70b069dfb8fcb348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0578cccec56825b3ad4b7cc45699e2e5d4d6515941216a59b6bb9496167310a45910b528f0315b71d722daf8259063d632459cf020bb68bc9cbac5fa50819424
|
7
|
+
data.tar.gz: 08b3ba21799a78d7b392cc20e5f6c43177f09053ff4d50c0ecbea95504a686906295f0f39030e5d70468dd287a3c97a4ad05fd484c63e09a4d6972c8af6529cd
|
data/bin/twig-deploy
CHANGED
@@ -48,6 +48,8 @@ class Review
|
|
48
48
|
|
49
49
|
def initialize
|
50
50
|
@prima = Prima.new
|
51
|
+
output "Controllo se ci sono aggiornamenti da fare..."
|
52
|
+
stop_unless `gem outdated`.lines.grep(/^prima-twig \(.*\)/).empty?, "Devi aggiornare la gemma prima-twig!".red
|
51
53
|
@cf = Aws::CloudFormation::Client.new
|
52
54
|
@ecs = Aws::ECS::Client.new
|
53
55
|
@s3 = Aws::S3::Client.new
|
data/bin/twig-feature
CHANGED
@@ -11,6 +11,8 @@ class Release
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@prima = Prima.new
|
14
|
+
output "Controllo se ci sono aggiornamenti da fare..."
|
15
|
+
stop_unless `gem outdated`.lines.grep(/^prima-twig \(.*\)/).empty?, "Devi aggiornare la gemma prima-twig!".red
|
14
16
|
@cf = Aws::CloudFormation::Client.new
|
15
17
|
@elb = Aws::ElasticLoadBalancing::Client.new
|
16
18
|
@alb = Aws::ElasticLoadBalancingV2::Client.new
|
@@ -20,12 +22,13 @@ class Release
|
|
20
22
|
@asg = Aws::AutoScaling::Client.new
|
21
23
|
@s3_bucket = 'prima-artifacts'
|
22
24
|
@artifact_path = '/tmp/prima-artifact.zip'
|
23
|
-
@import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore-TaskDefinitionDbRestore-
|
25
|
+
@import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore-TaskDefinitionDbRestore-10FNH25IWN2JY:1'
|
24
26
|
@prima_built = false
|
25
27
|
@urania_built = false
|
26
28
|
@ermes_built = false
|
27
29
|
@bburago_built = false
|
28
30
|
@hal9000_built = false
|
31
|
+
@fidaty_built = false
|
29
32
|
@backoffice_built = false
|
30
33
|
@dns_record_identifier = nil
|
31
34
|
@ecs_cluster_name = nil
|
@@ -80,6 +83,7 @@ class Release
|
|
80
83
|
end
|
81
84
|
|
82
85
|
def deploy_shutdown!
|
86
|
+
output "Recupero le informazioni sui QA attivi..."
|
83
87
|
envs = {}
|
84
88
|
stack_list.each do |stack|
|
85
89
|
unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
|
@@ -95,8 +99,11 @@ class Release
|
|
95
99
|
menu.shell = true
|
96
100
|
|
97
101
|
envs.each do |key, env|
|
98
|
-
title =
|
99
|
-
|
102
|
+
title = ""
|
103
|
+
env.each do |e|
|
104
|
+
title << "#{e.key}: #{e.value} "
|
105
|
+
end
|
106
|
+
msg = "#{@prima.reduce_size(title, 1000)}".light_blue
|
100
107
|
menu.choice(msg) { key }
|
101
108
|
end
|
102
109
|
end
|
@@ -124,6 +131,7 @@ class Release
|
|
124
131
|
end
|
125
132
|
|
126
133
|
def deploy_feature!
|
134
|
+
output "Deploy feature menu"
|
127
135
|
`sudo true` # cosi' non chiede la password dopo
|
128
136
|
`git pull && git submodule init && git submodule update`
|
129
137
|
prima_branch = choose_branch_to_deploy('prima')
|
@@ -132,12 +140,12 @@ class Release
|
|
132
140
|
ermes_branch = choose_branch_to_deploy('ermes')
|
133
141
|
bburago_branch = choose_branch_to_deploy('bburago')
|
134
142
|
hal9000_branch = choose_branch_to_deploy('hal9000')
|
143
|
+
fidaty_branch = choose_branch_to_deploy('fidaty')
|
135
144
|
socket_branch = {name: "master"}
|
136
145
|
pamela_branch = {name: "master"}
|
137
146
|
|
138
|
-
|
139
|
-
@dns_record_identifier =
|
140
|
-
@dns_record_identifier = @dns_record_identifier.gsub(/feature./, '')[0..35].gsub(/(-+$)/, '')
|
147
|
+
deploy_id = Digest::MD5.hexdigest(prima_branch[:name] + backoffice_branch[:name] + urania_branch[:name] + socket_branch[:name] + pamela_branch[:name] + ermes_branch[:name] + bburago_branch[:name] + hal9000_branch[:name] + fidaty_branch[:name])
|
148
|
+
@dns_record_identifier = deploy_id
|
141
149
|
|
142
150
|
tags = [
|
143
151
|
{
|
@@ -163,11 +171,13 @@ class Release
|
|
163
171
|
{
|
164
172
|
key: "hal9000",
|
165
173
|
value: hal9000_branch[:name]
|
174
|
+
},
|
175
|
+
{
|
176
|
+
key: "fidaty",
|
177
|
+
value: fidaty_branch[:name]
|
166
178
|
}
|
167
179
|
]
|
168
180
|
|
169
|
-
deploy_id = Digest::MD5.hexdigest(prima_branch[:name] + backoffice_branch[:name] + urania_branch[:name] + socket_branch[:name] + pamela_branch[:name] + ermes_branch[:name] + bburago_branch[:name] + hal9000_branch[:name])
|
170
|
-
|
171
181
|
cluster_stack_name = "ecs-cluster-qa-#{deploy_id}"
|
172
182
|
create_cluster_stack(cluster_stack_name, tags) unless stack_exists?(cluster_stack_name)
|
173
183
|
wait_for_stack_ready(cluster_stack_name) unless stack_ready?(cluster_stack_name)
|
@@ -192,11 +202,12 @@ class Release
|
|
192
202
|
]
|
193
203
|
create_stack(stack_name_db, stack_body, parameters, tags) unless stack_exists?(stack_name_db)
|
194
204
|
|
195
|
-
create_prima_artifact(prima_branch[:revision], prima_branch[:name]) unless artifact_exists?('prima-artifacts', "prima/#{prima_branch[:revision]}")
|
205
|
+
create_prima_artifact(prima_branch[:revision], prima_branch[:name], deploy_id) unless artifact_exists?('prima-artifacts', "prima/#{prima_branch[:revision]}-#{deploy_id}.tar.gz")
|
196
206
|
create_urania_artifact(urania_branch[:revision]) unless artifact_exists?('prima-artifacts', "microservices/urania/#{urania_branch[:revision]}-qa.tar.gz")
|
197
207
|
create_ermes_artifact(ermes_branch[:revision]) unless artifact_exists?('prima-artifacts', "microservices/ermes/#{ermes_branch[:revision]}-qa.tar.gz")
|
198
208
|
create_bburago_artifact(bburago_branch[:revision]) unless artifact_exists?('prima-artifacts', "microservices/bburago/#{bburago_branch[:revision]}-qa.tar.gz")
|
199
209
|
create_hal9000_artifact(hal9000_branch[:revision]) unless artifact_exists?('prima-artifacts', "microservices/hal9000/#{hal9000_branch[:revision]}-qa.tar.gz")
|
210
|
+
create_fidaty_artifact(fidaty_branch[:revision]) unless artifact_exists?('prima-artifacts', "microservices/fidaty/#{fidaty_branch[:revision]}-qa.tar.gz")
|
200
211
|
create_backoffice_artifact(backoffice_branch[:revision], deploy_id) unless artifact_exists?('prima-artifacts', "backoffice/#{backoffice_branch[:revision]}-#{deploy_id}.zip")
|
201
212
|
|
202
213
|
wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db)
|
@@ -212,7 +223,7 @@ class Release
|
|
212
223
|
},
|
213
224
|
{
|
214
225
|
parameter_key: "ReleaseVersion",
|
215
|
-
parameter_value: prima_branch[:revision]
|
226
|
+
parameter_value: "#{prima_branch[:revision]}-#{deploy_id}"
|
216
227
|
},
|
217
228
|
{
|
218
229
|
parameter_key: "TaskDesiredCount",
|
@@ -247,7 +258,7 @@ class Release
|
|
247
258
|
},
|
248
259
|
{
|
249
260
|
parameter_key: "ReleaseVersion",
|
250
|
-
parameter_value: prima_branch[:revision]
|
261
|
+
parameter_value: "#{prima_branch[:revision]}-#{deploy_id}"
|
251
262
|
},
|
252
263
|
{
|
253
264
|
parameter_key: "ECSClusterName",
|
@@ -376,6 +387,37 @@ class Release
|
|
376
387
|
create_stack(stack_name_hal9000, stack_body, parameters, tags)
|
377
388
|
end
|
378
389
|
|
390
|
+
stack_name_fidaty = "ecs-task-fidaty-qa-#{deploy_id}"
|
391
|
+
git_checkout_version('fidaty', fidaty_branch[:revision])
|
392
|
+
stack_body = IO.read('projects/fidaty/deploy/task.yml')
|
393
|
+
parameters = [
|
394
|
+
{
|
395
|
+
parameter_key: "Environment",
|
396
|
+
parameter_value: "qa"
|
397
|
+
},
|
398
|
+
{
|
399
|
+
parameter_key: "ReleaseVersion",
|
400
|
+
parameter_value: fidaty_branch[:revision]
|
401
|
+
},
|
402
|
+
{
|
403
|
+
parameter_key: "ECSClusterName",
|
404
|
+
parameter_value: @ecs_cluster_name
|
405
|
+
},
|
406
|
+
{
|
407
|
+
parameter_key: "TaskDesiredCount",
|
408
|
+
parameter_value: "1"
|
409
|
+
},
|
410
|
+
{
|
411
|
+
parameter_key: "ALBShortName",
|
412
|
+
parameter_value: "ecs-task-fidaty-qa-#{deploy_id}"[0..31]
|
413
|
+
}
|
414
|
+
]
|
415
|
+
if stack_exists?(stack_name_fidaty)
|
416
|
+
update_stack(stack_name_fidaty, stack_body, parameters) if @fidaty_built
|
417
|
+
else
|
418
|
+
create_stack(stack_name_fidaty, stack_body, parameters, tags)
|
419
|
+
end
|
420
|
+
|
379
421
|
git_checkout_version('backoffice', backoffice_branch[:revision])
|
380
422
|
stack_name_backoffice = "ecs-task-backoffice-qa-#{deploy_id}"
|
381
423
|
stack_body = IO.read('projects/backoffice/deploy/task.yml')
|
@@ -414,6 +456,7 @@ class Release
|
|
414
456
|
wait_for_stack_ready(stack_name_ermes) unless stack_ready?(stack_name_ermes)
|
415
457
|
wait_for_stack_ready(stack_name_bburago) unless stack_ready?(stack_name_bburago)
|
416
458
|
wait_for_stack_ready(stack_name_hal9000) unless stack_ready?(stack_name_hal9000)
|
459
|
+
wait_for_stack_ready(stack_name_fidaty) unless stack_ready?(stack_name_fidaty)
|
417
460
|
|
418
461
|
update_service_defaults(stack_name_web)
|
419
462
|
update_service_defaults(stack_name_consumer)
|
@@ -422,6 +465,7 @@ class Release
|
|
422
465
|
update_service_defaults(stack_name_ermes)
|
423
466
|
update_service_defaults(stack_name_bburago)
|
424
467
|
update_service_defaults(stack_name_hal9000)
|
468
|
+
update_service_defaults(stack_name_fidaty)
|
425
469
|
|
426
470
|
stack_name_route53 = "ecs-route53-qa-#{deploy_id}"
|
427
471
|
stack_body = IO.read('cloudformation/stacks/route53/qa.yml')
|
@@ -449,6 +493,10 @@ class Release
|
|
449
493
|
{
|
450
494
|
parameter_key: "Hal9000ElbHostname",
|
451
495
|
parameter_value: get_alb_host(stack_name_hal9000)
|
496
|
+
},
|
497
|
+
{
|
498
|
+
parameter_key: "FidatyElbHostname",
|
499
|
+
parameter_value: get_alb_host(stack_name_fidaty)
|
452
500
|
}
|
453
501
|
]
|
454
502
|
create_stack(stack_name_route53, stack_body, parameters, tags) unless stack_exists?(stack_name_route53)
|
@@ -457,6 +505,7 @@ class Release
|
|
457
505
|
urania_hostname = get_route53_hostname(stack_name_urania)
|
458
506
|
bburago_hostname = get_route53_hostname(stack_name_bburago)
|
459
507
|
hal9000_hostname = get_route53_hostname(stack_name_hal9000)
|
508
|
+
fidaty_hostname = get_route53_hostname(stack_name_fidaty)
|
460
509
|
backoffice_hostname = get_route53_hostname(stack_name_backoffice)
|
461
510
|
|
462
511
|
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
@@ -467,6 +516,7 @@ class Release
|
|
467
516
|
output "Backoffice url: #{backoffice_hostname}\n".cyan
|
468
517
|
output "Bburago url: #{bburago_hostname}\n".cyan
|
469
518
|
output "Hal9000 url: #{hal9000_hostname}\n".cyan
|
519
|
+
output "Fidaty url: #{fidaty_hostname}\n".cyan
|
470
520
|
output "SSH connection: ssh ec2-user@#{ec2_ip_address(asg_stack_name)} -i ~/.ssh/ecs-cluster-qa.pem".cyan
|
471
521
|
output "Deploy effettuato, everything is awesome!\n".green
|
472
522
|
end
|
@@ -483,6 +533,8 @@ class Release
|
|
483
533
|
host = "bburago-#{@dns_record_identifier}.qa.colaster.com"
|
484
534
|
when stack_name.include?('hal9000')
|
485
535
|
host = "hal9000-#{@dns_record_identifier}.qa.colaster.com"
|
536
|
+
when stack_name.include?('fidaty')
|
537
|
+
host = "fidaty-#{@dns_record_identifier}.qa.colaster.com"
|
486
538
|
end
|
487
539
|
host
|
488
540
|
end
|
@@ -513,6 +565,8 @@ class Release
|
|
513
565
|
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
514
566
|
when stack_name.include?('hal9000')
|
515
567
|
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
568
|
+
when stack_name.include?('fidaty')
|
569
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
516
570
|
end
|
517
571
|
resp = @cf.describe_stack_resource({
|
518
572
|
stack_name: stack_name,
|
@@ -536,6 +590,8 @@ class Release
|
|
536
590
|
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
537
591
|
when stack_name.include?('hal9000')
|
538
592
|
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
593
|
+
when stack_name.include?('fidaty')
|
594
|
+
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
539
595
|
end
|
540
596
|
resp = @cf.describe_stack_resource({
|
541
597
|
stack_name: stack_name,
|
@@ -564,6 +620,8 @@ class Release
|
|
564
620
|
logical_resource_id = 'ECSServiceBburago'
|
565
621
|
when stack_name.include?('hal9000')
|
566
622
|
logical_resource_id = 'ECSServiceHal9000'
|
623
|
+
when stack_name.include?('fidaty')
|
624
|
+
logical_resource_id = 'ECSServiceFidaty'
|
567
625
|
else
|
568
626
|
raise "Service name non gestito per lo stack #{stack_name}"
|
569
627
|
end
|
@@ -720,6 +778,45 @@ class Release
|
|
720
778
|
Dir.chdir '../../'
|
721
779
|
end
|
722
780
|
|
781
|
+
def create_fidaty_artifact(revision)
|
782
|
+
@fidaty_built = true
|
783
|
+
output "Preparo l'artifact .zip\n".yellow
|
784
|
+
|
785
|
+
git_checkout_version('fidaty', revision)
|
786
|
+
|
787
|
+
Dir.chdir 'projects/fidaty'
|
788
|
+
|
789
|
+
stack_name_web = "ecs-task-web-qa-notneeded"
|
790
|
+
web_qa_host = get_route53_hostname(stack_name_web)
|
791
|
+
|
792
|
+
[
|
793
|
+
"docker-compose build web",
|
794
|
+
"docker run -v $PWD:/code -w /code -e MIX_ENV=qa --entrypoint /bin/sh fidaty_web \
|
795
|
+
'-c' 'sed -i \"s/web-qa-host/#{web_qa_host}/g\" config/qa.exs && \
|
796
|
+
mix local.hex --force && mix hex.info && \
|
797
|
+
mix deps.get && mix compile && mix deps.compile && \
|
798
|
+
mix phoenix.digest && \
|
799
|
+
cp rel/vm.args rel/config.exs /tmp/ && mix release.clean --implode --no-confirm && \
|
800
|
+
mkdir -p rel && mv /tmp/vm.args /tmp/config.exs rel/ && mix release --env=qa'",
|
801
|
+
"sudo chown -R `whoami` ."
|
802
|
+
].each do |cmd|
|
803
|
+
output "Eseguo #{cmd}".yellow
|
804
|
+
res = %x[ #{cmd} ]
|
805
|
+
if $?.exitstatus != 0
|
806
|
+
color = 'red'
|
807
|
+
else
|
808
|
+
color = 'green'
|
809
|
+
end
|
810
|
+
output res.send color
|
811
|
+
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
812
|
+
end
|
813
|
+
|
814
|
+
artifact_path = Dir.glob("_build/qa/rel/fidaty/releases/*/fidaty.tar.gz").first
|
815
|
+
upload_artifact(artifact_path, "microservices/fidaty/#{revision}-qa.tar.gz")
|
816
|
+
|
817
|
+
Dir.chdir '../../'
|
818
|
+
end
|
819
|
+
|
723
820
|
def create_backoffice_artifact(revision, deploy_id)
|
724
821
|
@backoffice_built = true
|
725
822
|
output "Preparo l'artifact .zip\n".yellow
|
@@ -764,7 +861,7 @@ class Release
|
|
764
861
|
Dir.chdir '../../'
|
765
862
|
end
|
766
863
|
|
767
|
-
def create_prima_artifact(revision, branch_name)
|
864
|
+
def create_prima_artifact(revision, branch_name, deploy_id)
|
768
865
|
@prima_built = true
|
769
866
|
output "Preparo l'artifact .zip\n".yellow
|
770
867
|
|
@@ -772,6 +869,8 @@ class Release
|
|
772
869
|
|
773
870
|
Dir.chdir 'projects/prima'
|
774
871
|
|
872
|
+
stop_unless is_branch_compatible_with_current_twig_version?, "Il tuo branch non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
|
873
|
+
|
775
874
|
['vendor'].each do |dir|
|
776
875
|
unless File.directory?(dir)
|
777
876
|
if File.directory?("../../../prima/#{dir}")
|
@@ -784,7 +883,7 @@ class Release
|
|
784
883
|
web_qa_host = get_route53_hostname("ecs-task-web-qa-notneeded")
|
785
884
|
|
786
885
|
[
|
787
|
-
"bin/local_build_artifact.sh #{branch_name} #{web_qa_host} #{backoffice_qa_host}"
|
886
|
+
"bin/local_build_artifact.sh #{branch_name} #{web_qa_host} #{backoffice_qa_host} #{deploy_id}"
|
788
887
|
].each do |cmd|
|
789
888
|
output "Eseguo #{cmd}".yellow
|
790
889
|
res = %x[ #{cmd} ]
|
@@ -999,6 +1098,10 @@ class Release
|
|
999
1098
|
{ name: name, revision: revision[0..14] }
|
1000
1099
|
end
|
1001
1100
|
|
1101
|
+
def is_branch_compatible_with_current_twig_version?
|
1102
|
+
File.readlines("bin/local_build_artifact.sh").grep(/DEPLOY_ID=\$4/).size > 0
|
1103
|
+
end
|
1104
|
+
|
1002
1105
|
end
|
1003
1106
|
|
1004
1107
|
def help_content
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prima-twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Giachino
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: twig
|