prima-twig 0.58.3 → 0.58.500

Sign up to get free protection for your applications and to get access to all the features.
data/bin/twig-feature CHANGED
@@ -26,7 +26,7 @@ class Release
26
26
  @s3 = Aws::S3::Client.new
27
27
  @s3_bucket = 'prima-artifacts'
28
28
  @artifact_path = '/tmp/prima-artifact.zip'
29
- @import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore2-TaskDefinitionDbRestore-1BXH13XEVLPP0:1'
29
+ @import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore2-TaskDefinitionDbRestore-4UBHMCZBE5WM:1'
30
30
  @cf_role = 'arn:aws:iam::001575623345:role/qainit-service-role-cloudformat-CloudformationRole-18KBZQIS148R9'
31
31
  @dns_record_identifier = nil
32
32
  @ecs_cluster_name = nil
@@ -59,6 +59,7 @@ class Release
59
59
  @base_stack_name_alb = 'ecs-alb-http-public-qa-'
60
60
  @base_stack_name_alb_ws = 'ecs-alb-ws-public-qa-'
61
61
  @git_branch = ''
62
+ @cloudflare = Rubyflare.connect_with(ENV['CLOUDFLARE_EMAIL'], ENV['CLOUDFLARE_APIKEY'])
62
63
  end
63
64
 
64
65
  def execute!(args)
@@ -139,7 +140,6 @@ class Release
139
140
  output 'Disable aggregator'
140
141
 
141
142
  output "Recupero le informazioni relative al puntamento dei record DNS..."
142
- cloudflare = Rubyflare.connect_with(@prima.config['cloudflare_email'], @prima.config['cloudflare_apikey'])
143
143
  output "Recupero le informazioni sui QA attivi..."
144
144
  stack_list, envs = get_stacks()
145
145
 
@@ -151,7 +151,7 @@ class Release
151
151
  end.is_a?(Aws::CloudFormation::Types::Tag)
152
152
  aggregator_enabled
153
153
  end[0]
154
- dns_records = cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8])})
154
+ dns_records = @cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8])})
155
155
  stop_if dns_records.body[:result].empty?, "I record DNS degli aggregatori non stanno puntando ad un QA".red
156
156
  change_hostname_priority(env_hash, hostname_pattern_priority())
157
157
  dns_to_staging(env_hash)
@@ -167,8 +167,7 @@ class Release
167
167
  output 'Enable aggregator'
168
168
 
169
169
  output 'Recupero le informazioni relative al puntamento dei record DNS...'
170
- cloudflare = Rubyflare.connect_with(@prima.config['cloudflare_email'], @prima.config['cloudflare_apikey'])
171
- dns_records = cloudflare.get('zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records', { per_page: 100, type: 'CNAME', content: 'staging.prima.it' })
170
+ dns_records = @cloudflare.get('zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records', { per_page: 100, type: 'CNAME', content: 'staging.prima.it' })
172
171
  stop_if dns_records.body[:result].empty?, "I record DNS degli aggregatori stanno gia' puntando ad un QA".red
173
172
 
174
173
  output "Recupero le informazioni sui QA attivi..."
@@ -198,7 +197,7 @@ class Release
198
197
  dns_records.body[:result].each do |dns|
199
198
  if dns[:name] =~ /^\w+\-\w+\-staging\.prima\.it$/
200
199
  output "Changing #{dns[:name]} DNS record"
201
- cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: get_alb_host(@base_stack_name_alb + env_hash[3..8]), proxied: true, ttl: 1})
200
+ @cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: get_alb_host(@base_stack_name_alb + env_hash[3..8]), proxied: true, ttl: 1})
202
201
  end
203
202
  end
204
203
 
@@ -257,12 +256,11 @@ class Release
257
256
 
258
257
  def dns_to_staging(env_hash)
259
258
  output "Recupero le informazioni relative al puntamento dei record DNS..."
260
- cloudflare = Rubyflare.connect_with(@prima.config['cloudflare_email'], @prima.config['cloudflare_apikey'])
261
- dns_records = cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8])})
259
+ dns_records = @cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8])})
262
260
  dns_records.body[:result].each do |dns|
263
261
  if dns[:name] =~ /^\w+\-\w+\-staging\.prima\.it$/
264
262
  output "Changing #{dns[:name]} DNS record"
265
- cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: 'staging.prima.it', proxied: true, ttl: 1})
263
+ @cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: 'staging.prima.it', proxied: true, ttl: 1})
266
264
  end
267
265
  end
268
266
  end
@@ -596,6 +594,8 @@ class Release
596
594
  delete_stack(@base_stack_name_alb + env_hash[3..8]) if stack_exists?(@base_stack_name_alb + env_hash[3..8])
597
595
  delete_stack(@base_stack_name_alb_ws + env_hash[3..8]) if stack_exists?(@base_stack_name_alb_ws + env_hash[3..8])
598
596
  `git checkout master && git push origin --delete ${DRONE_BRANCH}`
597
+ output "Cancello il record DNS utilizzato da Lighthouse"
598
+ delete_lighthouse_dns()
599
599
  output "Finito!".green
600
600
 
601
601
  if @qainit
@@ -673,7 +673,7 @@ class Release
673
673
  tags = [
674
674
  {
675
675
  key: "qainit",
676
- value: @git_branch
676
+ value: @git_branch.gsub(/[^a-zA-Z\_\.\/\=\+\-\:\@\.]/, '')
677
677
  },
678
678
  {
679
679
  key: "hostname_pattern_priority",
@@ -683,11 +683,11 @@ class Release
683
683
  @projects.each do |key, value|
684
684
  case key.to_s
685
685
  when 'crash'
686
- tags << { key: 'crash', value: @projects['crash']['name'] } if deploy_crash?
686
+ tags << { key: 'crash', value: @projects['crash']['name'].gsub(/[^a-zA-Z\_\.\/\=\+\-\:\@\.]/, '') } if deploy_crash?
687
687
  when 'starsky', 'hutch'
688
- tags << { key: key.to_s, value: @projects[key.to_s]['name'] } if deploy_starsky_hutch?
688
+ tags << { key: key.to_s, value: @projects[key.to_s]['name'].gsub(/[^a-zA-Z\_\.\/\=\+\-\:\@\.]/, '') } if deploy_starsky_hutch?
689
689
  else
690
- tags << { key: key, value: value['name'] }
690
+ tags << { key: key, value: value['name'].gsub(/[^a-zA-Z\_\.\/\=\+\-\:\@\.]/, '') }
691
691
  end
692
692
  end
693
693
 
@@ -752,7 +752,7 @@ class Release
752
752
  create_skynet_artifact(@projects["skynet"]['revision']) unless artifact_exists?('prima-artifacts-encrypted', "microservices/skynet/#{@projects["skynet"]['revision']}-qa.tar.gz")
753
753
  create_maia_artifact(@projects["maia"]['revision']) unless artifact_exists?('prima-artifacts-encrypted', "microservices/maia/#{@projects["maia"]['revision']}-qa.tar.gz")
754
754
  create_starsky_artifact(@projects["starsky"]['revision']) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/starsky/#{@projects["starsky"]['revision']}-qa.tar.gz")
755
- create_hutch_artifact(@projects["hutch"]['revision']) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/hutch/#{@projects["hutch"]['revision']}-qa.tar.gz")
755
+ create_hutch_artifact(@projects["hutch"]['revision']) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/hutch/#{@projects["hutch"]['revision']}-#{@dns_record_identifier[0..7]}-qa.tar.gz")
756
756
 
757
757
 
758
758
  wait_for_db_import(db_task) unless stack_exists?("ecs-route53-qa-#{deploy_id}") # dovrebbe essere istantaneo
@@ -1326,6 +1326,10 @@ class Release
1326
1326
  parameter_key: "GraphqlEndpoint",
1327
1327
  parameter_value: "https://backoffice-#{@dns_record_identifier}.qa.colaster.com/graphql"
1328
1328
  },
1329
+ {
1330
+ parameter_key: "GraphqlInsuranceEndpoint",
1331
+ parameter_value: "https://backoffice-#{@dns_record_identifier}.qa.colaster.com/graphql/insurance"
1332
+ },
1329
1333
  {
1330
1334
  parameter_key: "AuthEndpoint",
1331
1335
  parameter_value: "https://backoffice-#{@dns_record_identifier}.qa.colaster.com/auth"
@@ -1440,7 +1444,11 @@ class Release
1440
1444
  ]
1441
1445
  if stack_exists?(stack_name_starsky)
1442
1446
  cur_version = get_currently_deployed_version(stack_name_starsky)
1443
- update_stack(stack_name_starsky, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["starsky"]['revision'])
1447
+ unless cur_version.include?(@projects["starsky"]['revision'])
1448
+ delete_stack(stack_name_starsky)
1449
+ wait_for_stack_removal(stack_name_starsky)
1450
+ create_stack(stack_name_starsky, stack_body, parameters, tags, @cf_role)
1451
+ end
1444
1452
  else
1445
1453
  create_stack(stack_name_starsky, stack_body, parameters, tags, @cf_role)
1446
1454
  end
@@ -1528,10 +1536,6 @@ class Release
1528
1536
  parameter_key: "WebQaBaseHostname",
1529
1537
  parameter_value: "#{@dns_record_identifier}.qa.colaster.com"
1530
1538
  },
1531
- {
1532
- parameter_key: "HostnamePattern",
1533
- parameter_value: "ww*-#{@dns_record_identifier}.qa.colaster.com"
1534
- },
1535
1539
  {
1536
1540
  parameter_key: "HostnamePatternPriority",
1537
1541
  parameter_value: hostname_pattern_priority
@@ -1562,7 +1566,7 @@ class Release
1562
1566
  },
1563
1567
  {
1564
1568
  parameter_key: "HostnamePattern",
1565
- parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
1569
+ parameter_value: "www-#{@dns_record_identifier}.*"
1566
1570
  }
1567
1571
  ]
1568
1572
  if stack_exists?(stack_name_web)
@@ -1611,6 +1615,10 @@ class Release
1611
1615
  {
1612
1616
  parameter_key: "HostnamePattern",
1613
1617
  parameter_value: "consumer-#{@dns_record_identifier}.qa.colaster.com"
1618
+ },
1619
+ {
1620
+ parameter_key: "WebQaBaseHostname",
1621
+ parameter_value: "#{@dns_record_identifier}.qa.colaster.com"
1614
1622
  }
1615
1623
  ]
1616
1624
  if stack_exists?(stack_name_consumer)
@@ -1670,7 +1678,7 @@ class Release
1670
1678
  },
1671
1679
  {
1672
1680
  parameter_key: "ReleaseVersion",
1673
- parameter_value: "#{@projects["hutch"]['revision']}"
1681
+ parameter_value: "#{@projects["hutch"]['revision']}-#{@dns_record_identifier[0..7]}"
1674
1682
  },
1675
1683
  {
1676
1684
  parameter_key: "ALBShortName",
@@ -1806,8 +1814,7 @@ class Release
1806
1814
  starsky_hostname = get_route53_hostname("starsky") unless !deploy_starsky_hutch?
1807
1815
  hutch_hostname = get_route53_hostname("hutch") unless !deploy_starsky_hutch?
1808
1816
 
1809
-
1810
- # launch_marley ec2_ip_address(asg_stack_name), prima_hostname, borat_hostname
1817
+ launch_mimo(deploy_id) if deploy_starsky_hutch?
1811
1818
 
1812
1819
  projects_text = "
1813
1820
  > Prima url: https://#{prima_hostname}
@@ -1840,34 +1847,14 @@ class Release
1840
1847
  output "Deploy effettuato, everything is awesome!\n".green
1841
1848
 
1842
1849
  if @projects['prima']['name'] != 'master' then
1843
- output "Lancio il batch job per la visual regression..."
1844
- @batch.submit_job({
1845
- job_name: "bocelli-test-#{@dns_record_identifier}",
1846
- job_queue: "tools-production",
1847
- job_definition: describe_stack_resource('batch-job-bocelli-production', 'JobDefinition').stack_resource_detail.physical_resource_id,
1848
- container_overrides: {
1849
- environment: [
1850
- {
1851
- name: "BATCH_COMMAND",
1852
- value: "test"
1853
- },
1854
- {
1855
- name: "QA_HOSTNAME",
1856
- value: prima_hostname
1857
- },
1858
- {
1859
- name: "BRANCH_NAME",
1860
- value: @projects['prima']['name']
1861
- },
1862
- {
1863
- name: "COMMITTER_EMAIL",
1864
- value: @projects['prima']['committer']
1865
- }
1866
- ]
1867
- }
1868
- })
1850
+ # output "Lancio il batch job per la visual regression..."
1851
+ # launch_bocelli_test(prima_hostname)
1852
+ # output "Visual regression lanciata con successo!"
1869
1853
 
1870
- output "Visual regression lanciata con successo!"
1854
+ output "Lancio i test con Lighthouse..."
1855
+ launch_lighthouse_test(prima_hostname, "mobile")
1856
+ launch_lighthouse_test(prima_hostname, "desktop")
1857
+ output "Test con Lighthouse lanciati con successo..."
1871
1858
  end
1872
1859
 
1873
1860
  qainit_write_output(projects_text, 'Indirizzi scritti su ')
@@ -1978,7 +1965,7 @@ class Release
1978
1965
  when stack_name.include?('web')
1979
1966
  logical_resource_id = 'ECSServiceWebQA'
1980
1967
  when stack_name.include?('consumer')
1981
- logical_resource_id = 'ECSServiceConsumerQa'
1968
+ logical_resource_id = 'ECSServiceConsumerApiQa'
1982
1969
  when stack_name.include?('urania')
1983
1970
  logical_resource_id = 'ECSServiceUraniaQA'
1984
1971
  when stack_name.include?('backoffice')
@@ -2024,6 +2011,77 @@ class Release
2024
2011
  update_ecs_service(@ecs_cluster_name, resp.stack_resource_detail.physical_resource_id, {minimum_healthy_percent: 0, maximum_percent: 100})
2025
2012
  end
2026
2013
 
2014
+ def launch_lighthouse_test(url, device)
2015
+ @cloudflare.post("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {type: 'CNAME', name: "www-#{@dns_record_identifier}", content: url, proxied: true, ttl: 1}) unless get_lighthouse_dns()
2016
+
2017
+ @batch.submit_job({
2018
+ job_name: "lighthouse-#{device}-#{@dns_record_identifier}",
2019
+ job_queue: "tools-production",
2020
+ job_definition: describe_stack_resource('batch-job-lighthouse-production', 'JobDefinition').stack_resource_detail.physical_resource_id,
2021
+ container_overrides: {
2022
+ environment: [
2023
+ {
2024
+ name: "URL_TO_TEST",
2025
+ value: "https://www-#{@dns_record_identifier}.prima.it/?superprima"
2026
+ },
2027
+ {
2028
+ name: "DEVICE",
2029
+ value: device
2030
+ },
2031
+ {
2032
+ name: "BRANCH_NAME",
2033
+ value: @projects['prima']['name']
2034
+ },
2035
+ {
2036
+ name: "COMMITTER_EMAIL",
2037
+ value: @projects['prima']['committer']
2038
+ }
2039
+ ]
2040
+ }
2041
+ })
2042
+ end
2043
+
2044
+ def get_lighthouse_dns()
2045
+ dns_records = @cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', name: "www-#{@dns_record_identifier}.prima.it"})
2046
+ if dns_records.body[:result_info][:count] > 0
2047
+ return dns_records.body[:result][0][:id]
2048
+ end
2049
+ false
2050
+ end
2051
+
2052
+ def delete_lighthouse_dns()
2053
+ dns_id = get_lighthouse_dns()
2054
+ @cloudflare.delete("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns_id}") if dns_id
2055
+ end
2056
+
2057
+ def launch_bocelli_test(url)
2058
+ @batch.submit_job({
2059
+ job_name: "bocelli-test-#{@dns_record_identifier}",
2060
+ job_queue: "tools-production",
2061
+ job_definition: describe_stack_resource('batch-job-bocelli-production', 'JobDefinition').stack_resource_detail.physical_resource_id,
2062
+ container_overrides: {
2063
+ environment: [
2064
+ {
2065
+ name: "BATCH_COMMAND",
2066
+ value: "test"
2067
+ },
2068
+ {
2069
+ name: "QA_HOSTNAME",
2070
+ value: url
2071
+ },
2072
+ {
2073
+ name: "BRANCH_NAME",
2074
+ value: @projects['prima']['name']
2075
+ },
2076
+ {
2077
+ name: "COMMITTER_EMAIL",
2078
+ value: @projects['prima']['committer']
2079
+ }
2080
+ ]
2081
+ }
2082
+ })
2083
+ end
2084
+
2027
2085
  def create_activia_artifact(revision)
2028
2086
  output "Preparo l'artifact activia .zip\n".yellow
2029
2087
 
@@ -2036,10 +2094,9 @@ class Release
2036
2094
  exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2037
2095
  exec_step 'prepare-docker-compose --directory activia && cp docker-compose-qainit.yml docker-compose.yml'
2038
2096
 
2039
- if File.exists? 'deploy/build_qa_artifact'
2040
- execute_command "deploy/build_qa_artifact"
2041
- else
2042
- [
2097
+ # execute_command "deploy/build_qa_artifact"
2098
+
2099
+ [
2043
2100
  "docker-compose build web",
2044
2101
  "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2045
2102
  '-c' 'mix local.hex --force && mix hex.info && \
@@ -2051,11 +2108,10 @@ class Release
2051
2108
  cd .. && \
2052
2109
  mix phx.digest && \
2053
2110
  rm -rf _build/qa/rel/ && \
2054
- mix release --env=qa'"
2111
+ mix distillery.release --env=qa'"
2055
2112
  ].each do |cmd|
2056
2113
  execute_command cmd
2057
2114
  end
2058
- end
2059
2115
 
2060
2116
  cleanup_containers
2061
2117
 
@@ -2125,27 +2181,7 @@ class Release
2125
2181
  exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2126
2182
  exec_step 'prepare-docker-compose --directory borat && cp docker-compose-qainit.yml docker-compose.yml'
2127
2183
 
2128
- if File.exists? 'deploy/build_qa_artifact'
2129
- execute_command "deploy/build_qa_artifact"
2130
- else
2131
- [
2132
- "docker network create borat_network || true",
2133
- "docker-compose build web",
2134
- "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2135
- '-c' 'mix local.hex --force && mix hex.info && \
2136
- mix deps.get && \
2137
- cd assets && \
2138
- yarn --cache-folder ~/.cache/yarn && \
2139
- sysconfcpus -n 2 ./node_modules/.bin/webpack -p --config config/webpack.config.prod.js && \
2140
- cd ../ && \
2141
- mix phx.digest && \
2142
- mix compile && mix deps.compile && \
2143
- rm -rf _build/qa/rel/ && \
2144
- mix distillery.release --env=qa'"
2145
- ].each do |cmd|
2146
- execute_command cmd
2147
- end
2148
- end
2184
+ execute_command "deploy/build_qa_artifact"
2149
2185
 
2150
2186
  cleanup_containers
2151
2187
 
@@ -2191,27 +2227,26 @@ class Release
2191
2227
  exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2192
2228
  exec_step 'prepare-docker-compose --directory ermes && cp docker-compose-qainit.yml docker-compose.yml'
2193
2229
 
2194
- [
2195
- "if echo `docker network ls` | grep crash_default; \
2196
- then echo 'crash_default network already existing'; \
2197
- else docker network create crash_default; fi",
2198
- 'docker-compose build web'
2199
- ].each do |cmd|
2200
- execute_command cmd
2201
- end
2202
-
2203
- [ "docker-compose run --rm -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2204
- '-c' 'mix local.hex --force && mix hex.info && \
2205
- mix deps.get && mix compile && mix deps.compile && \
2206
- mix phx.digest && \
2207
- MIX_ENV=dev mix compile.sms && \
2208
- MIX_ENV=dev mix compile.html && \
2209
- MIX_ENV=dev mix compile.heml && \
2210
- MIX_ENV=dev mix compile.app_notification && \
2211
- rm -rf _build/qa/rel/ && \
2212
- mix release --env=qa'"
2213
- ].each do |cmd|
2214
- execute_command cmd
2230
+ if File.exists? 'deploy/build_qa_artifact'
2231
+ execute_command "deploy/build_qa_artifact"
2232
+ else
2233
+ [
2234
+ "if echo `docker network ls` | grep crash_default; \
2235
+ then echo 'crash_default network already existing'; \
2236
+ else docker network create crash_default; fi",
2237
+ 'docker-compose build web',"docker-compose run --rm -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2238
+ '-c' 'mix local.hex --force && mix hex.info && \
2239
+ mix deps.get && mix compile && mix deps.compile && \
2240
+ mix phx.digest && \
2241
+ MIX_ENV=dev mix compile.sms && \
2242
+ MIX_ENV=dev mix compile.html && \
2243
+ MIX_ENV=dev mix compile.heml && \
2244
+ MIX_ENV=dev mix compile.app_notification && \
2245
+ rm -rf _build/qa/rel/ && \
2246
+ mix release --env=qa'"
2247
+ ].each do |cmd|
2248
+ execute_command cmd
2249
+ end
2215
2250
  end
2216
2251
 
2217
2252
  cleanup_containers
@@ -2233,16 +2268,21 @@ class Release
2233
2268
 
2234
2269
  exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2235
2270
  exec_step 'prepare-docker-compose --directory fidaty && cp docker-compose-qainit.yml docker-compose.yml'
2236
- [
2237
- "docker-compose build web",
2238
- "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2239
- '-c' 'mix local.hex --force && mix hex.info && \
2240
- mix deps.get && mix compile && mix deps.compile && \
2241
- mix phx.digest && \
2242
- rm -rf _build/qa/rel/ && \
2243
- mix release --env=qa'"
2244
- ].each do |cmd|
2245
- execute_command cmd
2271
+
2272
+ if File.exists? 'deploy/build_qa_artifact'
2273
+ execute_command "deploy/build_qa_artifact"
2274
+ else
2275
+ [
2276
+ "docker-compose build web",
2277
+ "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2278
+ '-c' 'mix local.hex --force && mix hex.info && \
2279
+ mix deps.get && mix compile && mix deps.compile && \
2280
+ mix phx.digest && \
2281
+ rm -rf _build/qa/rel/ && \
2282
+ mix release --env=qa'"
2283
+ ].each do |cmd|
2284
+ execute_command cmd
2285
+ end
2246
2286
  end
2247
2287
 
2248
2288
  cleanup_containers
@@ -2264,17 +2304,19 @@ class Release
2264
2304
 
2265
2305
  exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2266
2306
  exec_step 'prepare-docker-compose --directory hal9000 && cp docker-compose-qainit.yml docker-compose.yml'
2267
- [
2268
- "docker-compose build web",
2269
- "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2270
- '-c' 'mix local.hex --force && mix hex.info && \
2271
- mix deps.get && mix compile && mix deps.compile && \
2272
- mix phx.digest assets -o priv/static && \
2273
- rm -rf _build/qa/rel/ && \
2274
- mix release --env=qa'"
2275
- ].each do |cmd|
2276
- execute_command cmd
2277
- end
2307
+ # [
2308
+ # # "docker-compose build web",
2309
+ # # "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2310
+ # # '-c' 'mix local.hex --force && mix hex.info && \
2311
+ # # mix deps.get && mix compile && mix deps.compile && \
2312
+ # # mix phx.digest assets -o priv/static && \
2313
+ # # rm -rf _build/qa/rel/ && \
2314
+ # # mix release --env=qa'"
2315
+ # ].each do |cmd|
2316
+ # execute_command cmd
2317
+ # end
2318
+
2319
+ execute_command "deploy/build_qa_artifact"
2278
2320
 
2279
2321
  cleanup_containers
2280
2322
 
@@ -2301,7 +2343,7 @@ class Release
2301
2343
  cleanup_containers
2302
2344
 
2303
2345
  artifact_path = "./hutch.tar.gz"
2304
- upload_artifact(artifact_path, "microservices/hutch/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
2346
+ upload_artifact(artifact_path, "microservices/hutch/#{revision}-#{@dns_record_identifier[0..7]}-qa.tar.gz", "#{@s3_bucket}-encrypted")
2305
2347
 
2306
2348
  Dir.chdir '../../'
2307
2349
  end
@@ -2572,7 +2614,7 @@ class Release
2572
2614
 
2573
2615
  `mv docker-compose-ci.yml docker-compose.yml`
2574
2616
  exec_step 'prepare-docker-compose --directory starsky && cp docker-compose-qainit.yml docker-compose.yml'
2575
- exec_step "sed s/qa_deploy_id/#{get_deploy_id}/ .env.dist.qa"
2617
+ exec_step "sed -i s/qa_deploy_id/#{get_deploy_id}/g .env.dist.qa"
2576
2618
  exec_step "cp .env.dist.qa .env"
2577
2619
 
2578
2620
  [
@@ -2612,15 +2654,19 @@ class Release
2612
2654
  exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2613
2655
  exec_step 'prepare-docker-compose --directory urania && cp docker-compose-qainit.yml docker-compose.yml'
2614
2656
 
2615
- execute_command "docker-compose build web"
2616
-
2617
- [ "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2618
- '-c' 'mix local.hex --force && mix hex.info && \
2619
- mix deps.get && mix compile && mix deps.compile && \
2620
- rm -rf _build/qa/rel/ && \
2621
- mix release --env=qa'"
2622
- ].each do |cmd|
2623
- execute_command cmd
2657
+ if File.exists? 'deploy/build_qa_artifact'
2658
+ execute_command "deploy/build_qa_artifact"
2659
+ else
2660
+ [
2661
+ "docker-compose build web",
2662
+ "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
2663
+ '-c' 'mix local.hex --force && mix hex.info && \
2664
+ mix deps.get && mix compile && mix deps.compile && \
2665
+ rm -rf _build/qa/rel/ && \
2666
+ mix release --env=qa'"
2667
+ ].each do |cmd|
2668
+ execute_command cmd
2669
+ end
2624
2670
  end
2625
2671
 
2626
2672
  cleanup_containers
@@ -2645,15 +2691,17 @@ class Release
2645
2691
  end
2646
2692
 
2647
2693
  def deploy_crash?
2648
- crash_present = !@projects['crash'].empty? && @projects['crash']['name'] != 'master' && !@projects['crash']['default_branch']
2649
- leftorium_present = !@projects['leftorium'].empty? && @projects['leftorium']['name'] != 'master' && !@projects['leftorium']['default_branch']
2650
- crash_present || leftorium_present
2694
+ true # fino a che non ci mettiamo d'accordo su come gestire il fatto che leftorium ha bisogno di comunicare con crash
2695
+ # crash_present = !@projects['crash'].empty? && @projects['crash']['name'] != 'master' && !@projects['crash']['default_branch']
2696
+ # leftorium_present = !@projects['leftorium'].empty? && @projects['leftorium']['name'] != 'master' && !@projects['leftorium']['default_branch']
2697
+ # crash_present || leftorium_present
2651
2698
  end
2652
2699
 
2653
2700
  def deploy_starsky_hutch?
2654
- starsky_present = !@projects['starsky'].nil? && !@projects['starsky'].empty? && @projects['starsky']['name'] != 'master' && !@projects['starsky']['default_branch']
2655
- hutch_present = !@projects['hutch'].nil? && !@projects['hutch'].empty? && @projects['hutch']['name'] != 'master' && !@projects['hutch']['default_branch']
2656
- starsky_present || hutch_present
2701
+ true
2702
+ #starsky_present = !@projects['starsky'].nil? && !@projects['starsky'].empty? && @projects['starsky']['name'] != 'master' && !@projects['starsky']['default_branch']
2703
+ #hutch_present = !@projects['hutch'].nil? && !@projects['hutch'].empty? && @projects['hutch']['name'] != 'master' && !@projects['hutch']['default_branch']
2704
+ #starsky_present || hutch_present
2657
2705
  end
2658
2706
 
2659
2707
  def get_pyxis_version(deploy_id)
@@ -2680,7 +2728,7 @@ class Release
2680
2728
  },
2681
2729
  {
2682
2730
  parameter_key: "InstanceType",
2683
- parameter_value: "t3.large"
2731
+ parameter_value: "t3a.xlarge"
2684
2732
  },
2685
2733
  {
2686
2734
  parameter_key: "ECSClusterName",
@@ -2783,7 +2831,6 @@ class Release
2783
2831
  end
2784
2832
 
2785
2833
  def choose_branch_to_deploy(project_name, select_master = false)
2786
- return {'name' => 'master', 'revision' => '399653d555b8864', 'committer' => 'crash@prima.it', 'default_branch' => true} if project_name == 'crash' && select_master
2787
2834
  Dir.chdir "projects/#{project_name}"
2788
2835
  output "Recupero la lista dei branch del progetto #{project_name}..."
2789
2836
  `git remote prune origin`
@@ -2823,7 +2870,6 @@ class Release
2823
2870
  name = branch_name.split(' ')[0]
2824
2871
  revision = branch_name.split(' ')[1]
2825
2872
  committer_email = branch_name.split(' ')[2].tr('<>', '')
2826
- return { 'name' => 'crash', 'default_branch' => true } if project_name == 'crash' && branch_name == 'master' #rimuovere questa riga se mai nei qa servirà crash con un branch diverso da master
2827
2873
  { 'name' => name, 'revision' => revision[0..14], 'committer' => committer_email, 'default_branch' => select_master }
2828
2874
  end
2829
2875
 
@@ -2871,36 +2917,44 @@ class Release
2871
2917
  (Time.now.to_i.to_s[-4..-1].to_i + Random.rand(40000)).to_s
2872
2918
  end
2873
2919
 
2874
- def launch_marley(ip_address, prima_hostname, borat_hostname)
2875
- resp = describe_stack_resource('batch-job-marley', 'JobDefinition')
2920
+ def launch_mimo(env_hash)
2921
+ resp = describe_stack_resource('batch-job-mimo', 'JobDefinition')
2876
2922
 
2877
2923
  @batch.submit_job({
2878
- job_name: "marley-#{@dns_record_identifier}", # required
2924
+ job_name: "mimo-#{@dns_record_identifier}", # required
2879
2925
  job_queue: "tools-production", # required
2880
2926
  job_definition: resp.stack_resource_detail.physical_resource_id, # required
2881
2927
  container_overrides: {
2882
2928
  environment: [
2883
2929
  {
2884
- name: 'PRIMA_URL',
2885
- value: "https://#{prima_hostname}/?superprima"
2930
+ name: 'ENV_HASH',
2931
+ value: env_hash
2886
2932
  },
2887
2933
  {
2888
- name: 'PRIMA_IP',
2889
- value: ip_address
2934
+ name: 'APP_ENV',
2935
+ value: 'qa'
2936
+ },
2937
+ {
2938
+ name: 'CYPRESS_BASE_URL',
2939
+ value: "https://hutch-#{env_hash}.qa.colaster.com"
2940
+ },
2941
+ {
2942
+ name: 'CYPRESS_PEANO_BASE_URL',
2943
+ value: "http://peano-#{env_hash}.qa.colaster.com:10039/quotation"
2890
2944
  },
2891
2945
  {
2892
- name: 'PROJECTS_JSON',
2893
- value: @projects.to_json
2946
+ name: 'CYPRESS_API_BASE_URL',
2947
+ value: "https://#{get_route53_hostname("starsky")}/graphql"
2894
2948
  },
2895
2949
  {
2896
- name: 'BACKOFFICE_URL',
2897
- value: "https://#{borat_hostname}"
2950
+ name: 'QA_NAME',
2951
+ value: @git_branch
2898
2952
  }
2899
2953
  ]
2900
2954
  }
2901
2955
  })
2902
2956
 
2903
- output "Marley lanciato con successo!\n".green
2957
+ output "Mimo lanciato con successo!\n".green
2904
2958
  end
2905
2959
 
2906
2960
  def get_currently_deployed_version(stack_name)