[EWS] Support pull requests in built product management
https://bugs.webkit.org/show_bug.cgi?id=235589
<rdar://problem/88024098>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/steps.py:
(ConfigureBuild.add_patch_id_url): Set change_id.
(ConfigureBuild.add_pr_details): Ditto.
(Trigger.propertiesToPassToTriggers): Pass change_id.
(UploadBuiltProduct): Use change_id instead of patch_id.
(TransferToS3): Ditto.
(DownloadBuiltProduct): Ditto.
(DownloadBuiltProductFromMaster): Ditto.
* Tools/CISupport/ews-build/steps_unittest.py:

Canonical link: https://commits.webkit.org/246450@main

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/CISupport/ews-build/steps.py b/Tools/CISupport/ews-build/steps.py
index 0b7ff5c..8b571c3 100644
--- a/Tools/CISupport/ews-build/steps.py
+++ b/Tools/CISupport/ews-build/steps.py
@@ -310,17 +310,21 @@
     def add_patch_id_url(self):
         patch_id = self.getProperty('patch_id', '')
         if patch_id:
+            self.setProperty('change_id', patch_id, 'ConfigureBuild')
             self.addURL('Patch {}'.format(patch_id), Bugzilla.patch_url(patch_id))
 
     def add_pr_details(self):
         pr_number = self.getProperty('github.number')
         if not pr_number:
             return
+
         repository_url = self.getProperty('repository', '')
         title = self.getProperty('github.title', '')
         owners = self.getProperty('owners', [])
         revision = self.getProperty('github.head.sha')
 
+        self.setProperty('change_id', revision, 'ConfigureBuild')
+
         if title:
             self.addURL('PR {}: {}'.format(pr_number, title), GitHub.pr_url(pr_number, repository_url))
         if owners:
@@ -1496,11 +1500,11 @@
             ]
         if self.triggers:
             property_names.append('triggers')
-        if self.include_revision and pull_request:
-            properties_to_pass['ews_revision'] = properties.Property('got_revision')
 
         properties_to_pass = {prop: properties.Property(prop) for prop in property_names}
         properties_to_pass['retry_count'] = properties.Property('retry_count', default=0)
+        if self.include_revision and patch:
+            properties_to_pass['ews_revision'] = properties.Property('got_revision')
         return properties_to_pass
 
 
@@ -3351,7 +3355,7 @@
 class UploadBuiltProduct(transfer.FileUpload):
     name = 'upload-built-product'
     workersrc = WithProperties('WebKitBuild/%(configuration)s.zip')
-    masterdest = WithProperties('public_html/archives/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(patch_id)s.zip')
+    masterdest = WithProperties('public_html/archives/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(change_id)s.zip')
     descriptionDone = ['Uploaded built product']
     haltOnFailure = True
 
@@ -3372,10 +3376,10 @@
     name = 'transfer-to-s3'
     description = ['transferring to s3']
     descriptionDone = ['Transferred archive to S3']
-    archive = WithProperties('public_html/archives/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(patch_id)s.zip')
+    archive = WithProperties('public_html/archives/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(change_id)s.zip')
     identifier = WithProperties('%(fullPlatform)s-%(architecture)s-%(configuration)s')
-    patch_id = WithProperties('%(patch_id)s')
-    command = ['python3', '../Shared/transfer-archive-to-s3', '--patch_id', patch_id, '--identifier', identifier, '--archive', archive]
+    change_id = WithProperties('%(change_id)s')
+    command = ['python3', '../Shared/transfer-archive-to-s3', '--patch_id', change_id, '--identifier', identifier, '--archive', archive]
     haltOnFailure = False
     flunkOnFailure = False
 
@@ -3411,7 +3415,7 @@
 class DownloadBuiltProduct(shell.ShellCommand):
     command = ['python3', 'Tools/CISupport/download-built-product',
                WithProperties('--%(configuration)s'),
-               WithProperties(S3URL + 'ews-archives.webkit.org/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(patch_id)s.zip')]
+               WithProperties(S3URL + 'ews-archives.webkit.org/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(change_id)s.zip')]
     name = 'download-built-product'
     description = ['downloading built product']
     descriptionDone = ['Downloaded built product']
@@ -3441,7 +3445,7 @@
 
 
 class DownloadBuiltProductFromMaster(transfer.FileDownload):
-    mastersrc = WithProperties('public_html/archives/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(patch_id)s.zip')
+    mastersrc = WithProperties('public_html/archives/%(fullPlatform)s-%(architecture)s-%(configuration)s/%(change_id)s.zip')
     workerdest = WithProperties('WebKitBuild/%(configuration)s.zip')
     name = 'download-built-product-from-master'
     description = ['downloading built product from buildbot master']
diff --git a/Tools/CISupport/ews-build/steps_unittest.py b/Tools/CISupport/ews-build/steps_unittest.py
index 353a90b..82d31a7 100644
--- a/Tools/CISupport/ews-build/steps_unittest.py
+++ b/Tools/CISupport/ews-build/steps_unittest.py
@@ -3441,7 +3441,7 @@
         self.setProperty('fullPlatform', 'mac-sierra')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectHidden(False)
         self.expectRemoteCommands(
             Expect('uploadFile', dict(workersrc='WebKitBuild/release.zip', workdir='wkdir',
@@ -3460,7 +3460,7 @@
         self.setProperty('fullPlatform', 'mac-sierra')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectHidden(False)
         self.expectRemoteCommands(
             Expect('uploadFile', dict(workersrc='WebKitBuild/release.zip', workdir='wkdir',
@@ -3488,7 +3488,7 @@
         self.setProperty('fullPlatform', 'ios-simulator-12')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectRemoteCommands(
             ExpectShell(workdir='wkdir',
                         logEnviron=False,
@@ -3505,7 +3505,7 @@
         self.setProperty('fullPlatform', 'mac-sierra')
         self.setProperty('configuration', 'debug')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '123456')
+        self.setProperty('change_id', '123456')
         self.expectRemoteCommands(
             ExpectShell(workdir='wkdir',
                         logEnviron=False,
@@ -3523,7 +3523,7 @@
         self.setProperty('fullPlatform', 'gtk')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '123456')
+        self.setProperty('change_id', '123456')
         self.expectOutcome(result=SKIPPED)
         with current_hostname('test-ews-deployment.igalia.com'):
             return self.runStep()
@@ -3554,7 +3554,7 @@
         self.setProperty('fullPlatform', 'ios-simulator-12')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectHidden(False)
         buf = []
         self.expectRemoteCommands(
@@ -3583,7 +3583,7 @@
         self.setProperty('fullPlatform', 'mac-sierra')
         self.setProperty('configuration', 'debug')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '123456')
+        self.setProperty('change_id', '123456')
         buf = []
         self.expectRemoteCommands(
             Expect('downloadFile', dict(
@@ -3664,7 +3664,7 @@
         self.setProperty('fullPlatform', 'mac-highsierra')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectLocalCommands(
             ExpectMasterShellCommand(command=['python3',
                                               '../Shared/transfer-archive-to-s3',
@@ -3683,7 +3683,7 @@
         self.setProperty('fullPlatform', 'ios-simulator-12')
         self.setProperty('configuration', 'debug')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectLocalCommands(
             ExpectMasterShellCommand(command=['python3',
                                               '../Shared/transfer-archive-to-s3',
@@ -3702,7 +3702,7 @@
         self.setProperty('fullPlatform', 'mac-highsierra')
         self.setProperty('configuration', 'release')
         self.setProperty('architecture', 'x86_64')
-        self.setProperty('patch_id', '1234')
+        self.setProperty('change_id', '1234')
         self.expectOutcome(result=SKIPPED, state_string='Transferred archive to S3 (skipped)')
         with current_hostname('something-other-than-steps.EWS_BUILD_HOSTNAME'):
             return self.runStep()
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 4f4a76b..4601249 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,21 @@
+2022-01-25  Jonathan Bedard  <jbedard@apple.com>
+
+        [EWS] Support pull requests in built product management
+        https://bugs.webkit.org/show_bug.cgi?id=235589
+        <rdar://problem/88024098>
+
+        Reviewed by Aakash Jain.
+
+        * CISupport/ews-build/steps.py:
+        (ConfigureBuild.add_patch_id_url): Set change_id.
+        (ConfigureBuild.add_pr_details): Ditto.
+        (Trigger.propertiesToPassToTriggers): Pass change_id.
+        (UploadBuiltProduct): Use change_id instead of patch_id.
+        (TransferToS3): Ditto.
+        (DownloadBuiltProduct): Ditto.
+        (DownloadBuiltProductFromMaster): Ditto.
+        * CISupport/ews-build/steps_unittest.py:
+
 2022-01-26  Elliott Williams  <emw@apple.com>
 
         Support workspace builds in build-webkit