[Merge-Queue] Commit directly to GitHub
https://bugs.webkit.org/show_bug.cgi?id=241899
<rdar://93108587>
Reviewed by Aakash Jain.
* Tools/CISupport/ews-build/factories.py:
(CommitQueueFactory.__init__): Remove git-svn steps.
(MergeQueueFactoryBase.__init__): Ditto.
(MergeQueueFactory.__init__): Update pull-request before pushing commit to main.
(UnsafeMergeQueueFactory.__init__): Ditto.
* Tools/CISupport/ews-build/factories_unittest.py:
(TestExpectedBuildSteps):
* Tools/CISupport/ews-build/steps.py:
(PushCommitToWebKitRepo):
(PushCommitToWebKitRepo.__init__):
(PushCommitToWebKitRepo.start): Push commit to 'origin'.
(PushCommitToWebKitRepo.evaluateCommand): Remove git-svn, replace revision with hash.
Pull requests are updated before landing instead of after.
(PushCommitToWebKitRepo.hash_from_commit_text): Extract hash from git command.
(DetermineLandedIdentifier.evaluateCommand): Use hash instead of revision.
(DetermineLandedIdentifier.url_for_hash_details): Ditto.
(DetermineLandedIdentifier.identifier_for_hash): Ditto.
(DetermineLandedIdentifier.comment_text_for_bug): Use hash instead of revision, use
identifier as the default commit format.
(Canonicalize.run): Delete identifiers.json to ensure canonicalization is correct,
reset the commit and author time.
(PushCommitToWebKitRepo.svn_revision_from_commit_text): Deleted.
(DetermineLandedIdentifier.url_for_revision_details): Deleted.
(DetermineLandedIdentifier.identifier_for_revision): Deleted.
(AddAuthorToCommitMessage): Deleted.
(GitSvnFetch): Deleted.
(ResetGitSvn): Deleted.
(DetermineAuthor): Deleted.
* Tools/CISupport/ews-build/steps_unittest.py:
Canonical link: https://commits.webkit.org/251782@main
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295777 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/CISupport/ews-build/factories.py b/Tools/CISupport/ews-build/factories.py
index 5a781ce..9ee50d7 100644
--- a/Tools/CISupport/ews-build/factories.py
+++ b/Tools/CISupport/ews-build/factories.py
@@ -24,15 +24,15 @@
from buildbot.process import factory
from buildbot.steps import trigger
-from steps import (AddAuthorToCommitMessage, AddReviewerToCommitMessage, ApplyPatch, ApplyWatchList, Canonicalize, CommitPatch,
+from steps import (AddReviewerToCommitMessage, ApplyPatch, ApplyWatchList, Canonicalize, CommitPatch,
CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance,
CheckPatchStatusOnEWSQueues, CheckStyle, CleanGitRepo, CompileJSC, CompileWebKit, ConfigureBuild,
- DetermineAuthor, DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedLayoutTests, GitSvnFetch,
- InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo,
+ DownloadBuiltProduct, ExtractBuiltProduct, FetchBranches, FindModifiedLayoutTests,
+ InstallGtkDependencies, InstallWpeDependencies, KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, PushPullRequestBranch,
RunAPITests, RunBindingsTests, RunBuildWebKitOrgUnitTests, RunBuildbotCheckConfigForBuildWebKit, RunBuildbotCheckConfigForEWS,
RunEWSUnitTests, RunResultsdbpyTests, RunJavaScriptCoreTests, RunWebKit1Tests, RunWebKitPerlTests, RunWebKitPyPython2Tests,
RunWebKitPyPython3Tests, RunWebKitTests, RunWebKitTestsRedTree, RunWebKitTestsInStressMode, RunWebKitTestsInStressGuardmallocMode,
- SetBuildSummary, ShowIdentifier, TriggerCrashLogSubmission, UpdateWorkingDirectory,
+ SetBuildSummary, ShowIdentifier, TriggerCrashLogSubmission, UpdateWorkingDirectory, UpdatePullRequest,
ValidateCommitMessage, ValidateChange, ValidateCommitterAndReviewer, WaitForCrashCollection,
InstallBuiltProduct, ValidateSquashed)
@@ -294,7 +294,6 @@
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo())
self.addStep(CheckOutSource())
- self.addStep(GitSvnFetch()) # FIXME: Remove when migrating to pure git
self.addStep(FetchBranches())
self.addStep(ShowIdentifier())
self.addStep(UpdateWorkingDirectory())
@@ -302,8 +301,6 @@
self.addStep(ValidateSquashed())
self.addStep(AddReviewerToCommitMessage())
- self.addStep(DetermineAuthor())
- self.addStep(AddAuthorToCommitMessage())
self.addStep(ValidateCommitMessage())
self.addStep(KillOldProcesses())
@@ -328,15 +325,12 @@
self.addStep(PrintConfiguration())
self.addStep(CleanGitRepo())
self.addStep(CheckOutSource())
- self.addStep(GitSvnFetch()) # FIXME: Remove when migrating to pure git
self.addStep(FetchBranches())
self.addStep(ShowIdentifier())
self.addStep(UpdateWorkingDirectory())
self.addStep(CheckOutPullRequest())
self.addStep(ValidateSquashed())
self.addStep(AddReviewerToCommitMessage())
- self.addStep(DetermineAuthor())
- self.addStep(AddAuthorToCommitMessage())
self.addStep(ValidateCommitMessage())
@@ -350,6 +344,8 @@
self.addStep(ValidateChange(verifyMergeQueue=True, verifyNoDraftForMergeQueue=True))
self.addStep(Canonicalize())
+ self.addStep(PushPullRequestBranch())
+ self.addStep(UpdatePullRequest())
self.addStep(PushCommitToWebKitRepo())
self.addStep(SetBuildSummary())
@@ -360,5 +356,7 @@
self.addStep(ValidateChange(verifyMergeQueue=True, verifyNoDraftForMergeQueue=True))
self.addStep(Canonicalize())
+ self.addStep(PushPullRequestBranch())
+ self.addStep(UpdatePullRequest())
self.addStep(PushCommitToWebKitRepo())
self.addStep(SetBuildSummary())
diff --git a/Tools/CISupport/ews-build/factories_unittest.py b/Tools/CISupport/ews-build/factories_unittest.py
index f0a898e..1d6b32d 100644
--- a/Tools/CISupport/ews-build/factories_unittest.py
+++ b/Tools/CISupport/ews-build/factories_unittest.py
@@ -604,15 +604,12 @@
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
- 'git-svn-fetch',
'fetch-branch-references',
'show-identifier',
'update-working-directory',
'commit-patch',
'validate-squashed',
'add-reviewer-to-commit-message',
- 'determine-author',
- 'add-author-to-commit-message',
'validate-commit-message',
'kill-old-processes',
'compile-webkit',
@@ -632,21 +629,20 @@
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
- 'git-svn-fetch',
'fetch-branch-references',
'show-identifier',
'update-working-directory',
'checkout-pull-request',
'validate-squashed',
'add-reviewer-to-commit-message',
- 'determine-author',
- 'add-author-to-commit-message',
'validate-commit-message',
'kill-old-processes',
'compile-webkit',
'kill-old-processes',
'validate-change',
'canonicalize-commit',
+ 'push-pull-request-branch',
+ 'update-pull-request',
'push-commit-to-webkit-repo',
'set-build-summary'
],
@@ -657,18 +653,17 @@
'configuration',
'clean-up-git-repo',
'clean-and-update-working-directory',
- 'git-svn-fetch',
'fetch-branch-references',
'show-identifier',
'update-working-directory',
'checkout-pull-request',
'validate-squashed',
'add-reviewer-to-commit-message',
- 'determine-author',
- 'add-author-to-commit-message',
'validate-commit-message',
'validate-change',
'canonicalize-commit',
+ 'push-pull-request-branch',
+ 'update-pull-request',
'push-commit-to-webkit-repo',
'set-build-summary'
],
diff --git a/Tools/CISupport/ews-build/steps.py b/Tools/CISupport/ews-build/steps.py
index f184977..c0b7867 100644
--- a/Tools/CISupport/ews-build/steps.py
+++ b/Tools/CISupport/ews-build/steps.py
@@ -4498,36 +4498,34 @@
class PushCommitToWebKitRepo(shell.ShellCommand):
name = 'push-commit-to-webkit-repo'
descriptionDone = ['Pushed commit to WebKit repository']
- command = ['git', 'svn', 'dcommit', '--rmdir']
- commit_success_regexp = r'^Committed r(?P<svn_revision>\d+)$'
haltOnFailure = False
MAX_RETRY = 2
+ HASH_RE = re.compile(r'\s+[0-9a-f]+\.\.+(?P<hash>[0-9a-f]+)\s+')
def __init__(self, **kwargs):
- shell.ShellCommand.__init__(self, timeout=5 * 60, logEnviron=False, **kwargs)
+ super(PushCommitToWebKitRepo, self).__init__(logEnviron=False, timeout=300, **kwargs)
- def start(self):
+ def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
+ head_ref = self.getProperty('github.base.ref', 'main')
+ self.command = ['git', 'push', 'origin', f'HEAD:{head_ref}'] # FIXME: Support secret remotes
+
+ username, access_token = GitHub.credentials(user=GitHub.user_for_queue(self.getProperty('buildername', '')))
+ self.workerEnvironment['GIT_USER'] = username
+ self.workerEnvironment['GIT_PASSWORD'] = access_token
+
self.log_observer = logobserver.BufferLogObserver(wantStderr=True)
self.addLogObserver('stdio', self.log_observer)
- return shell.ShellCommand.start(self)
+ return super(PushCommitToWebKitRepo, self).start()
def evaluateCommand(self, cmd):
rc = shell.ShellCommand.evaluateCommand(self, cmd)
if rc == SUCCESS:
log_text = self.log_observer.getStdout() + self.log_observer.getStderr()
- svn_revision = self.svn_revision_from_commit_text(log_text)
- if svn_revision:
- self.setProperty('svn_revision', svn_revision)
+ landed_hash = self.hash_from_commit_text(log_text)
+ if landed_hash:
+ self.setProperty('landed_hash', landed_hash)
- steps_to_add = []
- if self.getProperty('github.number', ''):
- steps_to_add += [
- Canonicalize(rebase_enabled=False),
- PushPullRequestBranch(),
- UpdatePullRequest(),
- GitSvnFetch(),
- ]
- steps_to_add += [
+ steps_to_add = [
DetermineLandedIdentifier(),
LeaveComment(),
RemoveFlagsOnPatch(), RemoveLabelsFromPullRequest(),
@@ -4541,32 +4539,28 @@
self.setProperty('retry_count', retry_count + 1)
if self.getProperty('github.number', ''):
self.build.addStepsAfterCurrentStep([
- ResetGitSvn(),
CleanGitRepo(),
CheckOutSource(),
- GitSvnFetch(),
ShowIdentifier(),
UpdateWorkingDirectory(),
CheckOutPullRequest(),
AddReviewerToCommitMessage(),
- AddAuthorToCommitMessage(),
ValidateChange(verifyMergeQueue=True, verifyNoDraftForMergeQueue=True),
Canonicalize(),
PushCommitToWebKitRepo(),
])
else:
self.build.addStepsAfterCurrentStep([
- ResetGitSvn(),
CleanGitRepo(),
CheckOutSource(),
- GitSvnFetch(),
ShowIdentifier(),
UpdateWorkingDirectory(),
CommitPatch(),
AddReviewerToCommitMessage(),
- AddAuthorToCommitMessage(),
ValidateChange(addURLs=False, verifycqplus=True),
Canonicalize(),
+ PushPullRequestBranch(),
+ UpdatePullRequest(),
PushCommitToWebKitRepo(),
])
return rc
@@ -4589,9 +4583,11 @@
def doStepIf(self, step):
return CURRENT_HOSTNAME == EWS_BUILD_HOSTNAME
- def svn_revision_from_commit_text(self, commit_text):
- match = re.search(self.commit_success_regexp, commit_text, re.MULTILINE)
- return match.group('svn_revision')
+ def hash_from_commit_text(self, commit_text):
+ match = self.HASH_RE.search(commit_text)
+ if match:
+ return match.group('hash')
+ return None
class DetermineLandedIdentifier(shell.ShellCommand):
@@ -4628,44 +4624,44 @@
self.identifier = match.group('identifier')
break
- svn_revision = self.getProperty('svn_revision')
+ landed_hash = self.getProperty('landed_hash')
if not self.identifier:
time.sleep(60) # It takes time for commits.webkit.org to digest commits
- self.identifier = self.identifier_for_revision(svn_revision)
+ self.identifier = self.identifier_for_hash(landed_hash)
if '@' not in self.identifier:
rc = FAILURE
- self.setProperty('comment_text', self.comment_text_for_bug(svn_revision, self.identifier))
- commit_summary = f'Committed {self.identifier or svn_revision}'
+ self.setProperty('comment_text', self.comment_text_for_bug(landed_hash, self.identifier))
+ commit_summary = f'Committed {self.identifier or landed_hash}'
self.descriptionDone = commit_summary
self.setProperty('build_summary', commit_summary)
self.addURL(self.identifier, self.url_for_identifier(self.identifier))
return rc
- def url_for_revision_details(self, revision):
- return '{}r{}/json'.format(COMMITS_INFO_URL, revision)
+ def url_for_hash_details(self, hash):
+ return '{}{}/json'.format(COMMITS_INFO_URL, hash)
def url_for_identifier(self, identifier):
return '{}{}'.format(COMMITS_INFO_URL, identifier)
- def identifier_for_revision(self, revision):
+ def identifier_for_hash(self, hash):
try:
- response = requests.get(self.url_for_revision_details(revision), timeout=60)
+ response = requests.get(self.url_for_hash_details(hash), timeout=60)
if response and response.status_code == 200:
- return response.json().get('identifier', 'r{}'.format(revision)).replace('@trunk', '@main')
+ return response.json().get('identifier', '{}'.format(hash)).replace('@trunk', '@main')
else:
print('Non-200 status code received from {}: {}'.format(COMMITS_INFO_URL, response.status_code))
print(response.text)
except Exception as e:
print(e)
- return 'r{}'.format(revision)
+ return hash
- def comment_text_for_bug(self, svn_revision=None, identifier=None):
+ def comment_text_for_bug(self, hash=None, identifier=None):
identifier_str = identifier if identifier and '@' in identifier else '?'
- comment = '{} r{} ({}): <{}>'.format(
+ comment = '{} {} ({}): <{}>'.format(
'Test gardening commit' if self.getProperty('is_test_gardening') else 'Committed',
- svn_revision, identifier_str, self.url_for_identifier(identifier),
+ identifier_str, hash, self.url_for_identifier(identifier),
)
patch_id = self.getProperty('patch_id', '')
@@ -4810,89 +4806,6 @@
return not self.doStepIf(step)
-class DetermineAuthor(shell.ShellCommand, ShellMixin):
- name = 'determine-author'
- haltOnFailure = True
- AUTHOR_RE = re.compile(r'Author:\s+(.+ <.+>)')
-
- def __init__(self, **kwargs):
- super(DetermineAuthor, self).__init__(logEnviron=False, timeout=60, **kwargs)
-
- def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
- self.command = self.shell_command("git log -1 | grep '^Author:'")
-
- self.log_observer = BufferLogObserverClass(wantStderr=True)
- self.addLogObserver('stdio', self.log_observer)
-
- return super(DetermineAuthor, self).start()
-
- def getResultSummary(self):
- name = self.getProperty('author')
- if not name or self.results == FAILURE:
- return {'step': 'Failed to find author'}
- elif self.results == SUCCESS:
- return {'step': f"Author is {name}"}
- return super(DetermineAuthor, self).getResultSummary()
-
- def evaluateCommand(self, cmd):
- rc = super(DetermineAuthor, self).evaluateCommand(cmd)
- if rc != SUCCESS:
- return rc
-
- log_text = self.log_observer.getStdout()
- lines = log_text.splitlines()
- if len(lines) != 1:
- return FAILURE
- match = self.AUTHOR_RE.match(lines[0])
- if match:
- self.setProperty('author', match.group(1))
- return SUCCESS
- return FAILURE
-
-class AddAuthorToCommitMessage(shell.ShellCommand, AddReviewerMixin):
- name = 'add-author-to-commit-message'
- haltOnFailure = True
-
- def __init__(self, **kwargs):
- super(AddAuthorToCommitMessage, self).__init__(logEnviron=False, timeout=60, **kwargs)
-
- def start(self):
- base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
- head_ref = self.getProperty('github.head.ref', 'HEAD')
-
- gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
- timestamp = f'{int(time.time())} {gmtoffset}'
-
- author = self.getProperty('author')
- patch_by = f"Patch by {author} on {date.today().strftime('%Y-%m-%d')}"
-
- self.command = [
- 'git', 'filter-branch', '-f',
- '--env-filter', f"GIT_AUTHOR_DATE='{timestamp}';GIT_COMMITTER_DATE='{timestamp}'",
- '--msg-filter', f'sed "1,/^$/ s/^$/\\n{patch_by}/g"',
- f'{head_ref}...{base_ref}',
- ]
-
- for key, value in self.gitCommitEnvironment().items():
- self.workerEnvironment[key] = value
-
- return super(AddAuthorToCommitMessage, self).start()
-
- def getResultSummary(self):
- if self.results == FAILURE:
- return {'step': 'Failed to add author to commit message'}
- elif self.results == SUCCESS:
- author = self.getProperty('author')
- return {'step': f"Added {author} as author"}
- return super(AddAuthorToCommitMessage, self).getResultSummary()
-
- def doStepIf(self, step):
- return self.getProperty('author')
-
- def hideStepIf(self, results, step):
- return not self.doStepIf(step)
-
-
class ValidateCommitMessage(steps.ShellSequence, ShellMixin, AddToLogMixin):
name = 'validate-commit-message'
haltOnFailure = False
@@ -5023,6 +4936,7 @@
description = ['canonicalize-commit']
descriptionDone = ['Canonicalize Commit']
haltOnFailure = True
+ env = dict(FILTER_BRANCH_SQUELCH_WARNING='1')
def __init__(self, rebase_enabled=True, **kwargs):
super(Canonicalize, self).__init__(logEnviron=False, timeout=300, **kwargs)
@@ -5034,14 +4948,22 @@
base_ref = self.getProperty('github.base.ref', DEFAULT_BRANCH)
head_ref = self.getProperty('github.head.ref', None)
- commands = []
+ commands = [self.shell_command('rm .git/identifiers.json || {}'.format(self.shell_exit_0()))]
if self.rebase_enabled:
- commands = [['git', 'pull', 'origin', base_ref, '--rebase']]
+ commands += [['git', 'pull', 'origin', base_ref, '--rebase']]
if head_ref:
commands += [['git', 'branch', '-f', base_ref, head_ref]]
commands += [['git', 'checkout', base_ref]]
commands.append(['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1' if self.rebase_enabled else '3'])
+ gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
+ date = f'{int(time.time())} {gmtoffset}'
+ commands.append([
+ 'git', 'filter-branch', '-f',
+ '--env-filter', f"GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'",
+ f'HEAD...HEAD~1',
+ ])
+
for command in commands:
self.commands.append(util.ShellArg(command=command, logname='stdio', haltOnFailure=True))
@@ -5181,37 +5103,3 @@
def hideStepIf(self, results, step):
return not self.doStepIf(step)
-
-
-class GitSvnFetch(shell.ShellCommand):
- name = 'git-svn-fetch'
- haltOnFailure = False
- flunkOnFailure = False
- command = ['git', 'svn', 'fetch']
-
- def __init__(self, **kwargs):
- super(GitSvnFetch, self).__init__(logEnviron=False, timeout=600, **kwargs)
-
- def getResultSummary(self):
- if self.results == SUCCESS:
- return {'step': 'Paired recent SVN commits with GitHub record'}
- if self.results == FAILURE:
- return {'step': 'Recent SVN commits did not match GitHub record'}
- return super(GitSvnFetch, self).getResultSummary()
-
-
-class ResetGitSvn(shell.ShellCommand):
- name = 'reset-git-svn'
- haltOnFailure = False
- flunkOnFailure = False
- command = ['rm', '-rf', '.git/svn']
-
- def __init__(self, **kwargs):
- super(ResetGitSvn, self).__init__(logEnviron=False, timeout=300, **kwargs)
-
- def getResultSummary(self):
- if self.results == SUCCESS:
- return {'step': 'Removed git-svn references'}
- if self.results == FAILURE:
- return {'step': 'Failed to remove git-svn references'}
- return super(GitSvnFetch, self).getResultSummary()
diff --git a/Tools/CISupport/ews-build/steps_unittest.py b/Tools/CISupport/ews-build/steps_unittest.py
index e10eddc..eeb1857 100644
--- a/Tools/CISupport/ews-build/steps_unittest.py
+++ b/Tools/CISupport/ews-build/steps_unittest.py
@@ -42,16 +42,16 @@
from twisted.trial import unittest
import send_email
-from steps import (AddAuthorToCommitMessage, AddReviewerToCommitMessage, AnalyzeAPITestsResults, AnalyzeCompileWebKitResults,
+from steps import (AddReviewerToCommitMessage, AnalyzeAPITestsResults, AnalyzeCompileWebKitResults,
AnalyzeJSCTestsResults, AnalyzeLayoutTestsResults, ApplyPatch, ApplyWatchList, ArchiveBuiltProduct, ArchiveTestResults, BugzillaMixin,
Canonicalize, CheckOutPullRequest, CheckOutSource, CheckOutSpecificRevision, CheckChangeRelevance, CheckPatchStatusOnEWSQueues, CheckStyle,
CleanBuild, CleanUpGitIndexLock, CleanGitRepo, CleanWorkingDirectory, ClosePullRequest, CompileJSC, CommitPatch, CompileJSCWithoutChange,
CompileWebKit, CompileWebKitWithoutChange, ConfigureBuild, ConfigureBuild, Contributors,
- DetermineAuthor, DetermineLandedIdentifier, DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
- FetchBranches, FindModifiedLayoutTests, GitHub, GitResetHard, GitSvnFetch,
+ DetermineLandedIdentifier, DownloadBuiltProduct, DownloadBuiltProductFromMaster, EWS_BUILD_HOSTNAME, ExtractBuiltProduct, ExtractTestResults,
+ FetchBranches, FindModifiedLayoutTests, GitHub, GitResetHard,
InstallBuiltProduct, InstallGtkDependencies, InstallWpeDependencies,
KillOldProcesses, PrintConfiguration, PushCommitToWebKitRepo, PushPullRequestBranch, ReRunAPITests, ReRunWebKitPerlTests,
- ReRunWebKitTests, ResetGitSvn, RevertPullRequestChanges, RunAPITests, RunAPITestsWithoutChange, RunBindingsTests, RunBuildWebKitOrgUnitTests,
+ ReRunWebKitTests, RevertPullRequestChanges, RunAPITests, RunAPITestsWithoutChange, RunBindingsTests, RunBuildWebKitOrgUnitTests,
RunBuildbotCheckConfigForBuildWebKit, RunBuildbotCheckConfigForEWS, RunEWSUnitTests, RunResultsdbpyTests,
RunJavaScriptCoreTests, RunJSCTestsWithoutChange, RunWebKit1Tests, RunWebKitPerlTests, RunWebKitPyPython2Tests,
RunWebKitPyPython3Tests, RunWebKitTests, RunWebKitTestsInStressMode, RunWebKitTestsInStressGuardmallocMode,
@@ -5226,6 +5226,7 @@
class TestPushCommitToWebKitRepo(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
self.longMessage = True
+ GitHub.credentials = lambda user=None: ('webkit-commit-queue', 'password')
return self.setUpBuildStep()
def tearDown(self):
@@ -5238,14 +5239,15 @@
ExpectShell(workdir='wkdir',
timeout=300,
logEnviron=False,
- command=['git', 'svn', 'dcommit', '--rmdir']) +
- ExpectShell.log('stdio', stdout='Committed r256729') +
+ env=dict(GIT_USER='webkit-commit-queue', GIT_PASSWORD='password'),
+ command=['git', 'push', 'origin', 'HEAD:main']) +
+ ExpectShell.log('stdio', stdout=' 4c3bac1de151...b94dc426b331 ') +
0,
)
self.expectOutcome(result=SUCCESS, state_string='')
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('svn_revision'), '256729')
+ self.assertEqual(self.getProperty('landed_hash'), 'b94dc426b331')
return rc
def test_failure_retry(self):
@@ -5255,7 +5257,8 @@
ExpectShell(workdir='wkdir',
timeout=300,
logEnviron=False,
- command=['git', 'svn', 'dcommit', '--rmdir']) +
+ env=dict(GIT_USER='webkit-commit-queue', GIT_PASSWORD='password'),
+ command=['git', 'push', 'origin', 'HEAD:main']) +
ExpectShell.log('stdio', stdout='Unexpected failure') +
2,
)
@@ -5263,7 +5266,7 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
self.assertEqual(self.getProperty('retry_count'), 1)
- self.assertEqual(self.getProperty('svn_revision'), None)
+ self.assertEqual(self.getProperty('landed_hash'), None)
return rc
def test_failure_patch(self):
@@ -5274,7 +5277,8 @@
ExpectShell(workdir='wkdir',
timeout=300,
logEnviron=False,
- command=['git', 'svn', 'dcommit', '--rmdir']) +
+ env=dict(GIT_USER='webkit-commit-queue', GIT_PASSWORD='password'),
+ command=['git', 'push', 'origin', 'HEAD:main']) +
ExpectShell.log('stdio', stdout='Unexpected failure') +
2,
)
@@ -5293,7 +5297,8 @@
ExpectShell(workdir='wkdir',
timeout=300,
logEnviron=False,
- command=['git', 'svn', 'dcommit', '--rmdir']) +
+ env=dict(GIT_USER='webkit-commit-queue', GIT_PASSWORD='password'),
+ command=['git', 'push', 'origin', 'HEAD:main']) +
ExpectShell.log('stdio', stdout='Unexpected failure') +
2,
)
@@ -5338,7 +5343,7 @@
def test_success_pr(self):
with self.mock_commits_webkit_org(), self.mock_sleep():
self.setupStep(DetermineLandedIdentifier())
- self.setProperty('svn_revision', '256729')
+ self.setProperty('landed_hash', '14dbf1155cf5')
self.setProperty('github.number', '1234')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
@@ -5369,14 +5374,14 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+ self.assertEqual(self.getProperty('comment_text'), 'Committed 220797@main (14dbf1155cf5): <https://commits.webkit.org/220797@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
return rc
def test_success_gardening_pr(self):
with self.mock_commits_webkit_org(), self.mock_sleep():
self.setupStep(DetermineLandedIdentifier())
- self.setProperty('svn_revision', '293254')
+ self.setProperty('landed_hash', '5dc27962b4c5')
self.setProperty('github.number', '1234')
self.setProperty('is_test_gardening', True)
self.expectRemoteCommands(
@@ -5405,14 +5410,14 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('comment_text'), 'Test gardening commit r293254 (249903@main): <https://commits.webkit.org/249903@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+ self.assertEqual(self.getProperty('comment_text'), 'Test gardening commit 249903@main (5dc27962b4c5): <https://commits.webkit.org/249903@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
self.assertEqual(self.getProperty('build_summary'), 'Committed 249903@main')
return rc
def test_success_pr_fallback(self):
with self.mock_commits_webkit_org(identifier='220797@main'), self.mock_sleep():
self.setupStep(DetermineLandedIdentifier())
- self.setProperty('svn_revision', '256729')
+ self.setProperty('landed_hash', '5dc27962b4c5')
self.setProperty('github.number', '1234')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
@@ -5426,14 +5431,14 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+ self.assertEqual(self.getProperty('comment_text'), 'Committed 220797@main (5dc27962b4c5): <https://commits.webkit.org/220797@main>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
return rc
def test_pr_no_identifier(self):
with self.mock_commits_webkit_org(), self.mock_sleep():
self.setupStep(DetermineLandedIdentifier())
- self.setProperty('svn_revision', '256729')
+ self.setProperty('landed_hash', '5dc27962b4c5')
self.setProperty('github.number', '1234')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
@@ -5447,14 +5452,14 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (?): <https://commits.webkit.org/r256729>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
- self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
+ self.assertEqual(self.getProperty('comment_text'), 'Committed ? (5dc27962b4c5): <https://commits.webkit.org/5dc27962b4c5>\n\nReviewed commits have been landed. Closing PR #1234 and removing active labels.')
+ self.assertEqual(self.getProperty('build_summary'), 'Committed 5dc27962b4c5')
return rc
def test_success_patch(self):
with self.mock_commits_webkit_org(identifier='220797@main'), self.mock_sleep():
self.setupStep(DetermineLandedIdentifier())
- self.setProperty('svn_revision', '256729')
+ self.setProperty('landed_hash', '5dc27962b4c5')
self.setProperty('patch_id', '1234')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
@@ -5468,14 +5473,14 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
+ self.assertEqual(self.getProperty('comment_text'), 'Committed 220797@main (5dc27962b4c5): <https://commits.webkit.org/220797@main>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
return rc
def test_patch_no_identifier(self):
with self.mock_commits_webkit_org(), self.mock_sleep():
self.setupStep(DetermineLandedIdentifier())
- self.setProperty('svn_revision', '256729')
+ self.setProperty('landed_hash', '5dc27962b4c5')
self.setProperty('patch_id', '1234')
self.expectRemoteCommands(
ExpectShell(workdir='wkdir',
@@ -5489,8 +5494,8 @@
with current_hostname(EWS_BUILD_HOSTNAME):
rc = self.runStep()
- self.assertEqual(self.getProperty('comment_text'), 'Committed r256729 (?): <https://commits.webkit.org/r256729>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
- self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
+ self.assertEqual(self.getProperty('comment_text'), 'Committed ? (5dc27962b4c5): <https://commits.webkit.org/5dc27962b4c5>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
+ self.assertEqual(self.getProperty('build_summary'), 'Committed 5dc27962b4c5')
return rc
class TestShowIdentifier(BuildStepMixinAdditions, unittest.TestCase):
@@ -5802,111 +5807,6 @@
return self.runStep()
-class TestAddAuthorToCommitMessage(BuildStepMixinAdditions, unittest.TestCase):
- ENV = dict(
- GIT_COMMITTER_NAME='WebKit Committer',
- GIT_COMMITTER_EMAIL='committer@webkit.org',
- FILTER_BRANCH_SQUELCH_WARNING='1',
- )
-
- def setUp(self):
- self.longMessage = True
- Contributors.load = mock_load_contributors
- return self.setUpBuildStep()
-
- def tearDown(self):
- return self.tearDownBuildStep()
-
- def test_skipped_no_author(self):
- self.setupStep(AddAuthorToCommitMessage())
- self.expectOutcome(result=SKIPPED, state_string='finished (skipped)')
- return self.runStep()
-
- def test_success(self):
- gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
- fixed_time = int(time.time())
- timestamp = f'{int(time.time())} {gmtoffset}'
- time.time = lambda: fixed_time
-
- self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('github.base.ref', 'main')
- self.setProperty('github.head.ref', 'eng/pull-request-branch')
- self.setProperty('owners', ['webkit-commit-queue'])
- self.setProperty('author', 'WebKit Reviewer <reviewer@apple.com>')
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- env=self.ENV,
- timeout=60,
- command=[
- 'git', 'filter-branch', '-f',
- '--env-filter', f"GIT_AUTHOR_DATE='{timestamp}';GIT_COMMITTER_DATE='{timestamp}'",
- '--msg-filter', f'sed "1,/^$/ s/^$/\\nPatch by WebKit Reviewer <reviewer@apple.com> on {date.today().strftime("%Y-%m-%d")}/g"',
- 'eng/pull-request-branch...main',
- ])
- + 0
- + ExpectShell.log('stdio', stdout="Ref 'refs/heads/eng/pull-request-branch' was rewritten\n"),
- )
- self.expectOutcome(result=SUCCESS, state_string='Added WebKit Reviewer <reviewer@apple.com> as author')
- return self.runStep()
-
- def test_success_patch(self):
- gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
- fixed_time = int(time.time())
- timestamp = f'{int(time.time())} {gmtoffset}'
- time.time = lambda: fixed_time
-
- self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('author', 'WebKit Reviewer <reviewer@apple.com>')
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- env=dict(
- GIT_COMMITTER_EMAIL='ews@webkit.org',
- GIT_COMMITTER_NAME='EWS',
- FILTER_BRANCH_SQUELCH_WARNING='1',
- ), timeout=60,
- command=[
- 'git', 'filter-branch', '-f',
- '--env-filter', f"GIT_AUTHOR_DATE='{timestamp}';GIT_COMMITTER_DATE='{timestamp}'",
- '--msg-filter', f'sed "1,/^$/ s/^$/\\nPatch by WebKit Reviewer <reviewer@apple.com> on {date.today().strftime("%Y-%m-%d")}/g"',
- 'HEAD...origin/main',
- ])
- + 0
- + ExpectShell.log('stdio', stdout="Ref 'main' was rewritten\n"),
- )
- self.expectOutcome(result=SUCCESS, state_string='Added WebKit Reviewer <reviewer@apple.com> as author')
- return self.runStep()
-
- def test_failure(self):
- gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
- fixed_time = int(time.time())
- timestamp = f'{int(time.time())} {gmtoffset}'
- time.time = lambda: fixed_time
-
- self.setupStep(AddAuthorToCommitMessage())
- self.setProperty('github.base.ref', 'main')
- self.setProperty('github.head.ref', 'eng/pull-request-branch')
- self.setProperty('owners', ['webkit-commit-queue'])
- self.setProperty('author', 'WebKit Committer <committer@webkit.org>')
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- env=self.ENV,
- timeout=60,
- command=[
- 'git', 'filter-branch', '-f',
- '--env-filter', f"GIT_AUTHOR_DATE='{timestamp}';GIT_COMMITTER_DATE='{timestamp}'",
- '--msg-filter', f'sed "1,/^$/ s/^$/\\nPatch by WebKit Committer <committer@webkit.org> on {date.today().strftime("%Y-%m-%d")}/g"',
- 'eng/pull-request-branch...main',
- ])
- + 2
- + ExpectShell.log('stdio', stdout="Failed to rewrite 'refs/heads/eng/pull-request-branch'\n"),
- )
- self.expectOutcome(result=FAILURE, state_string='Failed to add author to commit message')
- return self.runStep()
-
-
class TestValidateCommitMessage(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
self.longMessage = True
@@ -6112,6 +6012,8 @@
class TestCanonicalize(BuildStepMixinAdditions, unittest.TestCase):
+ ENV = dict(FILTER_BRANCH_SQUELCH_WARNING='1')
+
def setUp(self):
self.longMessage = True
return self.setUpBuildStep()
@@ -6123,22 +6025,45 @@
self.setupStep(Canonicalize())
self.setProperty('patch_id', '1234')
+ gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
+ fixed_time = int(time.time())
+ date = f'{int(time.time())} {gmtoffset}'
+ time.time = lambda: fixed_time
+
self.expectRemoteCommands(
ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
+ command=['/bin/sh', '-c', 'rm .git/identifiers.json || true'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ env=self.ENV,
command=['git', 'pull', 'origin', 'main', '--rebase'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['git', 'checkout', 'main'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1'],
+ ) + 0, ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ env=self.ENV,
+ timeout=300,
+ command=[
+ 'git', 'filter-branch', '-f',
+ '--env-filter', "GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'".format(date=date),
+ 'HEAD...HEAD~1',
+ ],
) + 0,
)
self.expectOutcome(result=SUCCESS, state_string='Canonicalized commit')
@@ -6150,27 +6075,51 @@
self.setProperty('github.base.ref', 'main')
self.setProperty('github.head.ref', 'eng/pull-request-branch')
+ gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
+ fixed_time = int(time.time())
+ date = f'{int(time.time())} {gmtoffset}'
+ time.time = lambda: fixed_time
+
self.expectRemoteCommands(
ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
+ command=['/bin/sh', '-c', 'rm .git/identifiers.json || true'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ env=self.ENV,
command=['git', 'pull', 'origin', 'main', '--rebase'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['git', 'branch', '-f', 'main', 'eng/pull-request-branch'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['git', 'checkout', 'main'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1'],
+ ) + 0, ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ env=self.ENV,
+ timeout=300,
+ command=[
+ 'git', 'filter-branch', '-f',
+ '--env-filter', "GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'".format(date=date),
+ 'HEAD...HEAD~1',
+ ],
) + 0,
)
self.expectOutcome(result=SUCCESS, state_string='Canonicalized commit')
@@ -6182,12 +6131,33 @@
self.setProperty('github.base.ref', 'main')
self.setProperty('github.head.ref', 'eng/pull-request-branch')
+ gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
+ fixed_time = int(time.time())
+ date = f'{int(time.time())} {gmtoffset}'
+ time.time = lambda: fixed_time
+
self.expectRemoteCommands(
ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
+ command=['/bin/sh', '-c', 'rm .git/identifiers.json || true'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ env=self.ENV,
command=['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '3'],
+ ) + 0, ExpectShell(workdir='wkdir',
+ logEnviron=False,
+ env=self.ENV,
+ timeout=300,
+ command=[
+ 'git', 'filter-branch', '-f',
+ '--env-filter', "GIT_AUTHOR_DATE='{date}';GIT_COMMITTER_DATE='{date}'".format(date=date),
+ 'HEAD...HEAD~1',
+ ],
) + 0,
)
self.expectOutcome(result=SUCCESS, state_string='Canonicalized commits')
@@ -6204,21 +6174,31 @@
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
+ command=['/bin/sh', '-c', 'rm .git/identifiers.json || true'],
+ ) + 0, ExpectShell(
+ workdir='wkdir',
+ timeout=300,
+ logEnviron=False,
+ env=self.ENV,
command=['git', 'pull', 'origin', 'main', '--rebase'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['git', 'branch', '-f', 'main', 'eng/pull-request-branch'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['git', 'checkout', 'main'],
) + 0, ExpectShell(
workdir='wkdir',
timeout=300,
logEnviron=False,
+ env=self.ENV,
command=['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1'],
) + 1,
)
@@ -6459,41 +6439,6 @@
return rc
-class TestGitSvnFetch(BuildStepMixinAdditions, unittest.TestCase):
- def setUp(self):
- self.longMessage = True
- return self.setUpBuildStep()
-
- def tearDown(self):
- return self.tearDownBuildStep()
-
- def test_success(self):
- self.setupStep(GitSvnFetch())
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- timeout=600,
- command=['git', 'svn', 'fetch'])
- + 0
- + ExpectShell.log('stdio', stdout=''),
- )
- self.expectOutcome(result=SUCCESS, state_string='Paired recent SVN commits with GitHub record')
- return self.runStep()
-
- def test_failure(self):
- self.setupStep(GitSvnFetch())
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- timeout=600,
- command=['git', 'svn', 'fetch'])
- + 1
- + ExpectShell.log('stdio', stdout=''),
- )
- self.expectOutcome(result=FAILURE, state_string='Recent SVN commits did not match GitHub record')
- return self.runStep()
-
-
class TestClosePullRequest(BuildStepMixinAdditions, unittest.TestCase):
def setUp(self):
self.longMessage = True
@@ -6522,79 +6467,5 @@
return self.runStep()
-class TestResetGitSvn(BuildStepMixinAdditions, unittest.TestCase):
- def setUp(self):
- self.longMessage = True
- return self.setUpBuildStep()
-
- def tearDown(self):
- return self.tearDownBuildStep()
-
- def test_success(self):
- self.setupStep(ResetGitSvn())
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- timeout=300,
- command=['rm', '-rf', '.git/svn'])
- + 0
- + ExpectShell.log('stdio', stdout=''),
- )
- self.expectOutcome(result=SUCCESS, state_string='Removed git-svn references')
- return self.runStep()
-
- def test_failure(self):
- self.setupStep(ResetGitSvn())
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- timeout=300,
- command=['rm', '-rf', '.git/svn'])
- + 1
- + ExpectShell.log('stdio', stdout=''),
- )
- self.expectOutcome(result=FAILURE, state_string='Failed to remove git-svn references')
- return self.runStep()
-
-
-class TestDetermineAuthor(BuildStepMixinAdditions, unittest.TestCase):
- def setUp(self):
- self.longMessage = True
- return self.setUpBuildStep()
-
- def tearDown(self):
- return self.tearDownBuildStep()
-
- def test_success(self):
- self.setupStep(DetermineAuthor())
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- timeout=60,
- command=['/bin/sh', '-c', "git log -1 | grep '^Author:'"])
- + 0
- + ExpectShell.log('stdio', stdout='Author: WebKit Reviewer <reviewer@apple.com>'),
- )
- self.expectOutcome(result=SUCCESS, state_string='Author is WebKit Reviewer <reviewer@apple.com>')
- rc = self.runStep()
- self.assertEqual(self.getProperty('author'), 'WebKit Reviewer <reviewer@apple.com>')
- return rc
-
- def test_failure(self):
- self.setupStep(DetermineAuthor())
- self.expectRemoteCommands(
- ExpectShell(workdir='wkdir',
- logEnviron=False,
- timeout=60,
- command=['/bin/sh', '-c', "git log -1 | grep '^Author:'"])
- + 1
- + ExpectShell.log('stdio', stdout=''),
- )
- self.expectOutcome(result=FAILURE, state_string='Failed to find author')
- rc = self.runStep()
- self.assertEqual(self.getProperty('author'), None)
- return rc
-
-
if __name__ == '__main__':
unittest.main()