Mercurial > public > mercurial-scm > hg-stable
comparison contrib/automation/hgautomation/cli.py @ 42648:d80edcb0b30c stable
automation: make Windows base image name configurable
Since automation broke in the middle of the 5.0 release cycle,
there's a good chance it will break again in the future. While
a robust solution might be to search for all available images and
choose the newest one, it does seem useful to be able to explicitly
choose the name of the image to find and use so users can opt in
to using a different image.
This commit implements that functionality.
Differential Revision: https://phab.mercurial-scm.org/D6673
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 22 Jul 2019 19:06:20 -0700 |
parents | 65b3ef162b39 |
children | 92593d72e10b |
comparison
equal
deleted
inserted
replaced
42647:8804aa6c07a0 | 42648:d80edcb0b30c |
---|---|
50 else: | 50 else: |
51 for distro in distros: | 51 for distro in distros: |
52 aws.ensure_linux_dev_ami(c, distro=distro) | 52 aws.ensure_linux_dev_ami(c, distro=distro) |
53 | 53 |
54 | 54 |
55 def bootstrap_windows_dev(hga: HGAutomation, aws_region): | 55 def bootstrap_windows_dev(hga: HGAutomation, aws_region, base_image_name): |
56 c = hga.aws_connection(aws_region) | 56 c = hga.aws_connection(aws_region) |
57 image = aws.ensure_windows_dev_ami(c) | 57 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) |
58 print('Windows development AMI available as %s' % image.id) | 58 print('Windows development AMI available as %s' % image.id) |
59 | 59 |
60 | 60 |
61 def build_inno(hga: HGAutomation, aws_region, arch, revision, version): | 61 def build_inno(hga: HGAutomation, aws_region, arch, revision, version, |
62 c = hga.aws_connection(aws_region) | 62 base_image_name): |
63 image = aws.ensure_windows_dev_ami(c) | 63 c = hga.aws_connection(aws_region) |
64 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) | |
64 DIST_PATH.mkdir(exist_ok=True) | 65 DIST_PATH.mkdir(exist_ok=True) |
65 | 66 |
66 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: | 67 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: |
67 instance = insts[0] | 68 instance = insts[0] |
68 | 69 |
72 windows.build_inno_installer(instance.winrm_client, a, | 73 windows.build_inno_installer(instance.winrm_client, a, |
73 DIST_PATH, | 74 DIST_PATH, |
74 version=version) | 75 version=version) |
75 | 76 |
76 | 77 |
77 def build_wix(hga: HGAutomation, aws_region, arch, revision, version): | 78 def build_wix(hga: HGAutomation, aws_region, arch, revision, version, |
78 c = hga.aws_connection(aws_region) | 79 base_image_name): |
79 image = aws.ensure_windows_dev_ami(c) | 80 c = hga.aws_connection(aws_region) |
81 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) | |
80 DIST_PATH.mkdir(exist_ok=True) | 82 DIST_PATH.mkdir(exist_ok=True) |
81 | 83 |
82 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: | 84 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: |
83 instance = insts[0] | 85 instance = insts[0] |
84 | 86 |
87 for a in arch: | 89 for a in arch: |
88 windows.build_wix_installer(instance.winrm_client, a, | 90 windows.build_wix_installer(instance.winrm_client, a, |
89 DIST_PATH, version=version) | 91 DIST_PATH, version=version) |
90 | 92 |
91 | 93 |
92 def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision): | 94 def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision, |
93 c = hga.aws_connection(aws_region) | 95 base_image_name): |
94 image = aws.ensure_windows_dev_ami(c) | 96 c = hga.aws_connection(aws_region) |
97 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) | |
95 DIST_PATH.mkdir(exist_ok=True) | 98 DIST_PATH.mkdir(exist_ok=True) |
96 | 99 |
97 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: | 100 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: |
98 instance = insts[0] | 101 instance = insts[0] |
99 | 102 |
102 for a in arch: | 105 for a in arch: |
103 windows.build_wheel(instance.winrm_client, a, DIST_PATH) | 106 windows.build_wheel(instance.winrm_client, a, DIST_PATH) |
104 | 107 |
105 | 108 |
106 def build_all_windows_packages(hga: HGAutomation, aws_region, revision, | 109 def build_all_windows_packages(hga: HGAutomation, aws_region, revision, |
107 version): | 110 version, base_image_name): |
108 c = hga.aws_connection(aws_region) | 111 c = hga.aws_connection(aws_region) |
109 image = aws.ensure_windows_dev_ami(c) | 112 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) |
110 DIST_PATH.mkdir(exist_ok=True) | 113 DIST_PATH.mkdir(exist_ok=True) |
111 | 114 |
112 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: | 115 with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts: |
113 instance = insts[0] | 116 instance = insts[0] |
114 | 117 |
167 'total time: %.1fs; setup: %.1fs; tests: %.1fs; setup overhead: %.1f%%' | 170 'total time: %.1fs; setup: %.1fs; tests: %.1fs; setup overhead: %.1f%%' |
168 % (t_all, t_setup, t_done - t_prepared, t_setup / t_all * 100.0)) | 171 % (t_all, t_setup, t_done - t_prepared, t_setup / t_all * 100.0)) |
169 | 172 |
170 | 173 |
171 def run_tests_windows(hga: HGAutomation, aws_region, instance_type, | 174 def run_tests_windows(hga: HGAutomation, aws_region, instance_type, |
172 python_version, arch, test_flags): | 175 python_version, arch, test_flags, base_image_name): |
173 c = hga.aws_connection(aws_region) | 176 c = hga.aws_connection(aws_region) |
174 image = aws.ensure_windows_dev_ami(c) | 177 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) |
175 | 178 |
176 with aws.temporary_windows_dev_instances(c, image, instance_type, | 179 with aws.temporary_windows_dev_instances(c, image, instance_type, |
177 disable_antivirus=True) as insts: | 180 disable_antivirus=True) as insts: |
178 instance = insts[0] | 181 instance = insts[0] |
179 | 182 |
215 | 218 |
216 sp = subparsers.add_parser( | 219 sp = subparsers.add_parser( |
217 'bootstrap-windows-dev', | 220 'bootstrap-windows-dev', |
218 help='Bootstrap the Windows development environment', | 221 help='Bootstrap the Windows development environment', |
219 ) | 222 ) |
223 sp.add_argument( | |
224 '--base-image-name', | |
225 help='AMI name of base image', | |
226 default=aws.WINDOWS_BASE_IMAGE_NAME, | |
227 ) | |
220 sp.set_defaults(func=bootstrap_windows_dev) | 228 sp.set_defaults(func=bootstrap_windows_dev) |
221 | 229 |
222 sp = subparsers.add_parser( | 230 sp = subparsers.add_parser( |
223 'build-all-windows-packages', | 231 'build-all-windows-packages', |
224 help='Build all Windows packages', | 232 help='Build all Windows packages', |
229 default='.', | 237 default='.', |
230 ) | 238 ) |
231 sp.add_argument( | 239 sp.add_argument( |
232 '--version', | 240 '--version', |
233 help='Mercurial version string to use', | 241 help='Mercurial version string to use', |
242 ) | |
243 sp.add_argument( | |
244 '--base-image-name', | |
245 help='AMI name of base image', | |
246 default=aws.WINDOWS_BASE_IMAGE_NAME, | |
234 ) | 247 ) |
235 sp.set_defaults(func=build_all_windows_packages) | 248 sp.set_defaults(func=build_all_windows_packages) |
236 | 249 |
237 sp = subparsers.add_parser( | 250 sp = subparsers.add_parser( |
238 'build-inno', | 251 'build-inno', |
252 ) | 265 ) |
253 sp.add_argument( | 266 sp.add_argument( |
254 '--version', | 267 '--version', |
255 help='Mercurial version string to use in installer', | 268 help='Mercurial version string to use in installer', |
256 ) | 269 ) |
270 sp.add_argument( | |
271 '--base-image-name', | |
272 help='AMI name of base image', | |
273 default=aws.WINDOWS_BASE_IMAGE_NAME, | |
274 ) | |
257 sp.set_defaults(func=build_inno) | 275 sp.set_defaults(func=build_inno) |
258 | 276 |
259 sp = subparsers.add_parser( | 277 sp = subparsers.add_parser( |
260 'build-windows-wheel', | 278 'build-windows-wheel', |
261 help='Build Windows wheel(s)', | 279 help='Build Windows wheel(s)', |
270 sp.add_argument( | 288 sp.add_argument( |
271 '--revision', | 289 '--revision', |
272 help='Mercurial revision to build', | 290 help='Mercurial revision to build', |
273 default='.', | 291 default='.', |
274 ) | 292 ) |
293 sp.add_argument( | |
294 '--base-image-name', | |
295 help='AMI name of base image', | |
296 default=aws.WINDOWS_BASE_IMAGE_NAME, | |
297 ) | |
275 sp.set_defaults(func=build_windows_wheel) | 298 sp.set_defaults(func=build_windows_wheel) |
276 | 299 |
277 sp = subparsers.add_parser( | 300 sp = subparsers.add_parser( |
278 'build-wix', | 301 'build-wix', |
279 help='Build WiX installer(s)' | 302 help='Build WiX installer(s)' |
292 ) | 315 ) |
293 sp.add_argument( | 316 sp.add_argument( |
294 '--version', | 317 '--version', |
295 help='Mercurial version string to use in installer', | 318 help='Mercurial version string to use in installer', |
296 ) | 319 ) |
320 sp.add_argument( | |
321 '--base-image-name', | |
322 help='AMI name of base image', | |
323 default=aws.WINDOWS_BASE_IMAGE_NAME, | |
324 ) | |
297 sp.set_defaults(func=build_wix) | 325 sp.set_defaults(func=build_wix) |
298 | 326 |
299 sp = subparsers.add_parser( | 327 sp = subparsers.add_parser( |
300 'terminate-ec2-instances', | 328 'terminate-ec2-instances', |
301 help='Terminate all active EC2 instances managed by us', | 329 help='Terminate all active EC2 instances managed by us', |
366 ) | 394 ) |
367 sp.add_argument( | 395 sp.add_argument( |
368 '--test-flags', | 396 '--test-flags', |
369 help='Extra command line flags to pass to run-tests.py', | 397 help='Extra command line flags to pass to run-tests.py', |
370 ) | 398 ) |
399 sp.add_argument( | |
400 '--base-image-name', | |
401 help='AMI name of base image', | |
402 default=aws.WINDOWS_BASE_IMAGE_NAME, | |
403 ) | |
371 sp.set_defaults(func=run_tests_windows) | 404 sp.set_defaults(func=run_tests_windows) |
372 | 405 |
373 return parser | 406 return parser |
374 | 407 |
375 | 408 |