Title: [272743] trunk/Tools
Revision
272743
Author
aakash_j...@apple.com
Date
2021-02-11 11:59:28 -0800 (Thu, 11 Feb 2021)

Log Message

build.webkit.org should display commit identifier in builds
https://bugs.webkit.org/show_bug.cgi?id=221730

Reviewed by Jonathan Bedard.

* CISupport/build-webkit-org/steps.py:
(ExtractTestResults.finished):
(ShowIdentifier): build-step to show commit identifier.
(ShowIdentifier.__init__):
(ShowIdentifier.start):
(ShowIdentifier.evaluateCommand):
(ShowIdentifier.getLastBuildStepByName):
(ShowIdentifier.url_for_identifier):
(ShowIdentifier.getResultSummary): Display custom failure message.
(ShowIdentifier.hideStepIf): Hide this step if successful.
* CISupport/build-webkit-org/steps_unittest.py:
(BuildStepMixinAdditions.executedSteps): filter wasn't working as expected with python 3, replaced
with list comprehension.
(TestShowIdentifier): Added unit-tests.
(TestShowIdentifier.test_success):
(TestShowIdentifier.test_failure):
* CISupport/build-webkit-org/factories.py: Added ShowIdentifier build step.

Modified Paths

Diff

Modified: trunk/Tools/CISupport/build-webkit-org/factories.py (272742 => 272743)


--- trunk/Tools/CISupport/build-webkit-org/factories.py	2021-02-11 19:33:25 UTC (rev 272742)
+++ trunk/Tools/CISupport/build-webkit-org/factories.py	2021-02-11 19:59:28 UTC (rev 272743)
@@ -31,6 +31,7 @@
         factory.BuildFactory.__init__(self)
         self.addStep(ConfigureBuild(platform=platform, configuration=configuration, architecture=" ".join(architectures), buildOnly=buildOnly, additionalArguments=additionalArguments, device_model=device_model))
         self.addStep(CheckOutSource())
+        self.addStep(ShowIdentifier())
         if not (platform == "jsc-only"):
             self.addStep(KillOldProcesses())
         self.addStep(CleanBuildIfScheduled())

Modified: trunk/Tools/CISupport/build-webkit-org/steps.py (272742 => 272743)


--- trunk/Tools/CISupport/build-webkit-org/steps.py	2021-02-11 19:33:25 UTC (rev 272742)
+++ trunk/Tools/CISupport/build-webkit-org/steps.py	2021-02-11 19:59:28 UTC (rev 272743)
@@ -36,6 +36,7 @@
 
 APPLE_WEBKIT_AWS_PROXY = "http://proxy01.webkit.org:3128"
 BUILD_WEBKIT_HOSTNAME = 'build.webkit.org'
+COMMITS_INFO_URL = 'https://commits.webkit.org/'
 CURRENT_HOSTNAME = socket.gethostname().strip()
 RESULTS_WEBKIT_URL = 'https://results.webkit.org'
 RESULTS_SERVER_API_KEY = 'RESULTS_SERVER_API_KEY'
@@ -1124,3 +1125,56 @@
     def finished(self, result):
         self.addCustomURLs()
         return master.MasterShellCommand.finished(self, result)
+
+
+class ShowIdentifier(shell.ShellCommand):
+    name = 'show-identifier'
+    identifier_re = '^Identifier: (.*)$'
+    flunkOnFailure = False
+    haltOnFailure = False
+
+    def __init__(self, **kwargs):
+        shell.ShellCommand.__init__(self, timeout=2 * 60, logEnviron=False, **kwargs)
+
+    def start(self):
+        self.log_observer = logobserver.BufferLogObserver()
+        self.addLogObserver('stdio', self.log_observer)
+        revision = self.getProperty('got_revision')
+        self.setCommand(['python', 'Tools/Scripts/git-webkit', 'find', 'r{}'.format(revision)])
+        return shell.ShellCommand.start(self)
+
+    def evaluateCommand(self, cmd):
+        rc = shell.ShellCommand.evaluateCommand(self, cmd)
+        if rc != SUCCESS:
+            return rc
+
+        log_text = self.log_observer.getStdout()
+        match = re.search(self.identifier_re, log_text, re.MULTILINE)
+        if match:
+            identifier = match.group(1)
+            self.setProperty('identifier', identifier)
+            step = self.getLastBuildStepByName(CheckOutSource.name)
+            if not step:
+                step = self
+            step.addURL('Updated to {}'.format(identifier), self.url_for_identifier(identifier))
+            self.descriptionDone = 'Identifier: {}'.format(identifier)
+        else:
+            self.descriptionDone = 'Failed to find identifier'
+        return rc
+
+    def getLastBuildStepByName(self, name):
+        for step in reversed(self.build.executedSteps):
+            if name in step.name:
+                return step
+        return None
+
+    def url_for_identifier(self, identifier):
+        return '{}{}'.format(COMMITS_INFO_URL, identifier)
+
+    def getResultSummary(self):
+        if self.results != SUCCESS:
+            return {u'step': u'Failed to find identifier'}
+        return shell.ShellCommand.getResultSummary(self)
+
+    def hideStepIf(self, results, step):
+        return results == SUCCESS

Modified: trunk/Tools/CISupport/build-webkit-org/steps_unittest.py (272742 => 272743)


--- trunk/Tools/CISupport/build-webkit-org/steps_unittest.py	2021-02-11 19:33:25 UTC (rev 272742)
+++ trunk/Tools/CISupport/build-webkit-org/steps_unittest.py	2021-02-11 19:59:28 UTC (rev 272743)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020-2021 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -106,7 +106,7 @@
 
     @property
     def executedSteps(self):
-        return filter(lambda step: not step.stopped, self.previous_steps)
+        return [step for step in self.previous_steps if not step.stopped]
 
     def setProperty(self, name, value, source='Unknown'):
         self.properties.setProperty(name, value, source)
@@ -496,3 +496,42 @@
         )
         self.expectOutcome(result=FAILURE, state_string='compiled (failure)')
         return self.runStep()
+
+
+class TestShowIdentifier(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
+    def test_success(self):
+        self.setupStep(ShowIdentifier())
+        self.setProperty('got_revision', '272692')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=120,
+                        logEnviron=False,
+                        command=['python', 'Tools/Scripts/git-webkit', 'find', 'r272692']) +
+            ExpectShell.log('stdio', stdout='Identifier: 233939@trunk') +
+            0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Identifier: 233939@trunk')
+        rc = self.runStep()
+        self.assertEqual(self.getProperty('identifier'), '233939@trunk')
+        return rc
+
+    def test_failure(self):
+        self.setupStep(ShowIdentifier())
+        self.setProperty('got_revision', '272692')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=120,
+                        logEnviron=False,
+                        command=['python', 'Tools/Scripts/git-webkit', 'find', 'r272692']) +
+            ExpectShell.log('stdio', stdout='Unexpected failure') +
+            2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Failed to find identifier')
+        return self.runStep()

Modified: trunk/Tools/ChangeLog (272742 => 272743)


--- trunk/Tools/ChangeLog	2021-02-11 19:33:25 UTC (rev 272742)
+++ trunk/Tools/ChangeLog	2021-02-11 19:59:28 UTC (rev 272743)
@@ -1,5 +1,30 @@
 2021-02-11  Aakash Jain  <aakash_j...@apple.com>
 
+        build.webkit.org should display commit identifier in builds
+        https://bugs.webkit.org/show_bug.cgi?id=221730
+
+        Reviewed by Jonathan Bedard.
+
+        * CISupport/build-webkit-org/steps.py:
+        (ExtractTestResults.finished):
+        (ShowIdentifier): build-step to show commit identifier.
+        (ShowIdentifier.__init__):
+        (ShowIdentifier.start):
+        (ShowIdentifier.evaluateCommand):
+        (ShowIdentifier.getLastBuildStepByName):
+        (ShowIdentifier.url_for_identifier):
+        (ShowIdentifier.getResultSummary): Display custom failure message.
+        (ShowIdentifier.hideStepIf): Hide this step if successful.
+        * CISupport/build-webkit-org/steps_unittest.py:
+        (BuildStepMixinAdditions.executedSteps): filter wasn't working as expected with python 3, replaced 
+        with list comprehension.
+        (TestShowIdentifier): Added unit-tests.
+        (TestShowIdentifier.test_success):
+        (TestShowIdentifier.test_failure):
+        * CISupport/build-webkit-org/factories.py: Added ShowIdentifier build step.
+
+2021-02-11  Aakash Jain  <aakash_j...@apple.com>
+
         JSC EWSes should be triggered by change in any jsc file
         https://bugs.webkit.org/show_bug.cgi?id=221756
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to