[ews-build] Add build step to Transfer archive to S3
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 14:32:17 +0000 (14:32 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 14:32:17 +0000 (14:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197922

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-build/steps.py:
(TransferToS3):
(TransferToS3.finished): Invoke triggers after transfer is successful.
(TransferToS3.getResultSummary): Create more readable failure string.
(UploadBuiltProduct.finished): Deleted. Moved the trigger invocation after TransferToS3.
* BuildSlaveSupport/ews-build/steps_unittest.py: Added unit-tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245461 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-build/steps.py
Tools/BuildSlaveSupport/ews-build/steps_unittest.py
Tools/ChangeLog

index b9930ea..e3d2b7a 100644 (file)
@@ -615,7 +615,7 @@ class CompileWebKit(shell.Compile):
             self.setProperty('patchFailedToBuild', True)
             self.build.addStepsAfterCurrentStep([UnApplyPatchIfRequired(), CompileWebKitToT()])
         else:
-            self.build.addStepsAfterCurrentStep([ArchiveBuiltProduct(), UploadBuiltProduct()])
+            self.build.addStepsAfterCurrentStep([ArchiveBuiltProduct(), UploadBuiltProduct(), TransferToS3()])
 
         return super(CompileWebKit, self).evaluateCommand(cmd)
 
@@ -769,18 +769,39 @@ class UploadBuiltProduct(transfer.FileUpload):
         kwargs['blocksize'] = 1024 * 256
         transfer.FileUpload.__init__(self, **kwargs)
 
+    def getResultSummary(self):
+        if self.results != SUCCESS:
+            return {u'step': u'Failed to upload built product'}
+        return super(UploadBuiltProduct, self).getResultSummary()
+
+
+class TransferToS3(master.MasterShellCommand):
+    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')
+    identifier = WithProperties('%(fullPlatform)s-%(architecture)s-%(configuration)s')
+    patch_id = WithProperties('%(patch_id)s')
+    command = ['python', '../Shared/transfer-archive-to-s3', '--patch_id', patch_id, '--identifier', identifier, '--archive', archive]
+    haltOnFailure = True
+    flunkOnFailure = True
+
+    def __init__(self, **kwargs):
+        kwargs['command'] = self.command
+        master.MasterShellCommand.__init__(self, logEnviron=False, **kwargs)
+
     def finished(self, results):
         if results == SUCCESS:
             triggers = self.getProperty('triggers', None)
             if triggers:
                 self.build.addStepsAfterCurrentStep([Trigger(schedulerNames=triggers)])
 
-        return super(UploadBuiltProduct, self).finished(results)
+        return super(TransferToS3, self).finished(results)
 
     def getResultSummary(self):
         if self.results != SUCCESS:
-            return {u'step': u'Failed to upload built product'}
-        return super(UploadBuiltProduct, self).getResultSummary()
+            return {u'step': u'Failed to transfer archive to S3'}
+        return super(TransferToS3, self).getResultSummary()
 
 
 class DownloadBuiltProduct(shell.ShellCommand):
index f1af68f..c50d21a 100644 (file)
@@ -40,8 +40,8 @@ from steps import (AnalyzeAPITestsResults, ApplyPatch, ArchiveBuiltProduct, Arch
                    DownloadBuiltProduct, ExtractBuiltProduct, ExtractTestResults, KillOldProcesses,
                    PrintConfiguration, ReRunAPITests, ReRunJavaScriptCoreTests, RunAPITests, RunAPITestsWithoutPatch,
                    RunBindingsTests, RunJavaScriptCoreTests, RunJavaScriptCoreTestsToT, RunWebKit1Tests, RunWebKitPerlTests,
-                   RunWebKitPyTests, RunWebKitTests, TestWithFailureCount, Trigger, UnApplyPatchIfRequired, UploadBuiltProduct,
-                   UploadTestResults, ValidatePatch)
+                   RunWebKitPyTests, RunWebKitTests, TestWithFailureCount, Trigger, TransferToS3, UnApplyPatchIfRequired,
+                   UploadBuiltProduct, UploadTestResults, ValidatePatch)
 
 # Workaround for https://github.com/buildbot/buildbot/issues/4669
 from buildbot.test.fake.fakebuild import FakeBuild
@@ -1073,6 +1073,51 @@ class TestExtractBuiltProduct(BuildStepMixinAdditions, unittest.TestCase):
         return self.runStep()
 
 
+class TestTransferToS3(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
+    def test_success(self):
+        self.setupStep(TransferToS3())
+        self.setProperty('fullPlatform', 'mac-highsierra')
+        self.setProperty('configuration', 'release')
+        self.setProperty('architecture', 'x86_64')
+        self.setProperty('patch_id', '1234')
+        self.expectLocalCommands(
+            ExpectMasterShellCommand(command=['python',
+                                              '../Shared/transfer-archive-to-s3',
+                                              '--patch_id', '1234',
+                                              '--identifier', 'mac-highsierra-x86_64-release',
+                                              '--archive', 'public_html/archives/mac-highsierra-x86_64-release/1234.zip',
+                                             ])
+            + 0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Transferred archive to S3')
+        return self.runStep()
+
+    def test_failure(self):
+        self.setupStep(TransferToS3())
+        self.setProperty('fullPlatform', 'ios-simulator-12')
+        self.setProperty('configuration', 'debug')
+        self.setProperty('architecture', 'x86_64')
+        self.setProperty('patch_id', '1234')
+        self.expectLocalCommands(
+            ExpectMasterShellCommand(command=['python',
+                                              '../Shared/transfer-archive-to-s3',
+                                              '--patch_id', '1234',
+                                              '--identifier', 'ios-simulator-12-x86_64-debug',
+                                              '--archive', 'public_html/archives/ios-simulator-12-x86_64-debug/1234.zip',
+                                             ])
+            + 2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Failed to transfer archive to S3')
+        return self.runStep()
+
+
 class TestRunAPITests(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):
         self.longMessage = True
index e5def46..3ae9ef4 100644 (file)
@@ -1,3 +1,17 @@
+2019-05-17  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-build] Add build step to Transfer archive to S3
+        https://bugs.webkit.org/show_bug.cgi?id=197922
+
+        Reviewed by Jonathan Bedard.
+
+        * BuildSlaveSupport/ews-build/steps.py:
+        (TransferToS3):
+        (TransferToS3.finished): Invoke triggers after transfer is successful.
+        (TransferToS3.getResultSummary): Create more readable failure string.
+        (UploadBuiltProduct.finished): Deleted. Moved the trigger invocation after TransferToS3.
+        * BuildSlaveSupport/ews-build/steps_unittest.py: Added unit-tests.
+
 2019-05-16  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Need WebKitContextMenuItemType to open emoji picker