D6673: automation: make Windows base image name configurable

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Jul 24 05:27:42 EDT 2019


Closed by commit rHGd80edcb0b30c: automation: make Windows base image name configurable (authored by indygreg).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6673?vs=16005&id=16030

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6673/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6673

AFFECTED FILES
  contrib/automation/hgautomation/aws.py
  contrib/automation/hgautomation/cli.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/cli.py b/contrib/automation/hgautomation/cli.py
--- a/contrib/automation/hgautomation/cli.py
+++ b/contrib/automation/hgautomation/cli.py
@@ -52,15 +52,16 @@
             aws.ensure_linux_dev_ami(c, distro=distro)
 
 
-def bootstrap_windows_dev(hga: HGAutomation, aws_region):
+def bootstrap_windows_dev(hga: HGAutomation, aws_region, base_image_name):
     c = hga.aws_connection(aws_region)
-    image = aws.ensure_windows_dev_ami(c)
+    image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
     print('Windows development AMI available as %s' % image.id)
 
 
-def build_inno(hga: HGAutomation, aws_region, arch, revision, version):
+def build_inno(hga: HGAutomation, aws_region, arch, revision, version,
+               base_image_name):
     c = hga.aws_connection(aws_region)
-    image = aws.ensure_windows_dev_ami(c)
+    image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
     DIST_PATH.mkdir(exist_ok=True)
 
     with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -74,9 +75,10 @@
                                          version=version)
 
 
-def build_wix(hga: HGAutomation, aws_region, arch, revision, version):
+def build_wix(hga: HGAutomation, aws_region, arch, revision, version,
+              base_image_name):
     c = hga.aws_connection(aws_region)
-    image = aws.ensure_windows_dev_ami(c)
+    image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
     DIST_PATH.mkdir(exist_ok=True)
 
     with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -89,9 +91,10 @@
                                         DIST_PATH, version=version)
 
 
-def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision):
+def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision,
+                        base_image_name):
     c = hga.aws_connection(aws_region)
-    image = aws.ensure_windows_dev_ami(c)
+    image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
     DIST_PATH.mkdir(exist_ok=True)
 
     with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -104,9 +107,9 @@
 
 
 def build_all_windows_packages(hga: HGAutomation, aws_region, revision,
-                               version):
+                               version, base_image_name):
     c = hga.aws_connection(aws_region)
-    image = aws.ensure_windows_dev_ami(c)
+    image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
     DIST_PATH.mkdir(exist_ok=True)
 
     with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
@@ -169,9 +172,9 @@
 
 
 def run_tests_windows(hga: HGAutomation, aws_region, instance_type,
-                      python_version, arch, test_flags):
+                      python_version, arch, test_flags, base_image_name):
     c = hga.aws_connection(aws_region)
-    image = aws.ensure_windows_dev_ami(c)
+    image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
 
     with aws.temporary_windows_dev_instances(c, image, instance_type,
                                              disable_antivirus=True) as insts:
@@ -217,6 +220,11 @@
         'bootstrap-windows-dev',
         help='Bootstrap the Windows development environment',
     )
+    sp.add_argument(
+        '--base-image-name',
+        help='AMI name of base image',
+        default=aws.WINDOWS_BASE_IMAGE_NAME,
+    )
     sp.set_defaults(func=bootstrap_windows_dev)
 
     sp = subparsers.add_parser(
@@ -232,6 +240,11 @@
         '--version',
         help='Mercurial version string to use',
     )
+    sp.add_argument(
+        '--base-image-name',
+        help='AMI name of base image',
+        default=aws.WINDOWS_BASE_IMAGE_NAME,
+    )
     sp.set_defaults(func=build_all_windows_packages)
 
     sp = subparsers.add_parser(
@@ -254,6 +267,11 @@
         '--version',
         help='Mercurial version string to use in installer',
     )
+    sp.add_argument(
+        '--base-image-name',
+        help='AMI name of base image',
+        default=aws.WINDOWS_BASE_IMAGE_NAME,
+    )
     sp.set_defaults(func=build_inno)
 
     sp = subparsers.add_parser(
@@ -272,6 +290,11 @@
         help='Mercurial revision to build',
         default='.',
     )
+    sp.add_argument(
+        '--base-image-name',
+        help='AMI name of base image',
+        default=aws.WINDOWS_BASE_IMAGE_NAME,
+    )
     sp.set_defaults(func=build_windows_wheel)
 
     sp = subparsers.add_parser(
@@ -294,6 +317,11 @@
         '--version',
         help='Mercurial version string to use in installer',
     )
+    sp.add_argument(
+        '--base-image-name',
+        help='AMI name of base image',
+        default=aws.WINDOWS_BASE_IMAGE_NAME,
+    )
     sp.set_defaults(func=build_wix)
 
     sp = subparsers.add_parser(
@@ -368,6 +396,11 @@
         '--test-flags',
         help='Extra command line flags to pass to run-tests.py',
     )
+    sp.add_argument(
+        '--base-image-name',
+        help='AMI name of base image',
+        default=aws.WINDOWS_BASE_IMAGE_NAME,
+    )
     sp.set_defaults(func=run_tests_windows)
 
     return parser
diff --git a/contrib/automation/hgautomation/aws.py b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -1032,7 +1032,8 @@
                 instance.ssh_client.close()
 
 
-def ensure_windows_dev_ami(c: AWSConnection, prefix='hg-'):
+def ensure_windows_dev_ami(c: AWSConnection, prefix='hg-',
+                           base_image_name=WINDOWS_BASE_IMAGE_NAME):
     """Ensure Windows Development AMI is available and up-to-date.
 
     If necessary, a modern AMI will be built by starting a temporary EC2
@@ -1050,7 +1051,7 @@
 
     name = '%s%s' % (prefix, 'windows-dev')
 
-    image = find_image(ec2resource, AMAZON_ACCOUNT_ID, WINDOWS_BASE_IMAGE_NAME)
+    image = find_image(ec2resource, AMAZON_ACCOUNT_ID, base_image_name)
 
     config = {
         'BlockDeviceMappings': [
@@ -1103,6 +1104,7 @@
         'user_data': WINDOWS_USER_DATA,
         'initial_bootstrap': WINDOWS_BOOTSTRAP_POWERSHELL,
         'bootstrap_commands': commands,
+        'base_image_name': base_image_name,
     })
 
     existing_image = find_and_reconcile_image(ec2resource, name, fingerprint)



To: indygreg, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list