Skip to content

Commit

Permalink
[ews-build.webkit.org] Use variable instead of 'origin' in steps
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=242898
<rdar://problem/97259132>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/steps.py:
(ConfigureBuild.add_pr_details):
(FetchBranches.run):
(UpdateWorkingDirectory.run):
(CheckOutPullRequest.run):
(CleanGitRepo.__init__):
(ValidateRemote.start):
(ValidateRemote.evaluateCommand):
(ValidateRemote.doStepIf):
(ValidateSquashed.start):
(AddReviewerToCommitMessage.start):
(ValidateCommitMessage.run):
(Canonicalize.run):

Canonical link: https://commits.webkit.org/254635@main
  • Loading branch information
JonWBedard committed Sep 19, 2022
1 parent a01206b commit 58854f9
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions Tools/CISupport/ews-build/steps.py
Expand Up @@ -61,6 +61,7 @@
GITHUB_PROJECTS = ['WebKit/WebKit', 'apple/WebKit', 'WebKit/WebKit-security']
HASH_LENGTH_TO_DISPLAY = 8
DEFAULT_BRANCH = 'main'
DEFAULT_REMOTE = 'origin'
LAYOUT_TESTS_URL = '{}{}/blob/{}/LayoutTests/'.format(GITHUB_URL, GITHUB_PROJECTS[0], DEFAULT_BRANCH)


Expand Down Expand Up @@ -578,7 +579,7 @@ def add_pr_details(self):

project = self.getProperty('project')
if project == GITHUB_PROJECTS[0]:
self.setProperty('remote', 'origin')
self.setProperty('remote', DEFAULT_REMOTE)
self.setProperty('sensitive', False)
elif project in GITHUB_PROJECTS:
self.setProperty('remote', project.split('-')[-1] if '-' in project else project.split('/')[0])
Expand Down Expand Up @@ -705,11 +706,11 @@ def __init__(self, **kwargs):
super(FetchBranches, self).__init__(timeout=5 * 60, logEnviron=False, **kwargs)

def run(self):
self.commands = [util.ShellArg(command=['git', 'fetch', 'origin', '--prune'], logname='stdio')]
self.commands = [util.ShellArg(command=['git', 'fetch', DEFAULT_REMOTE, '--prune'], logname='stdio')]

project = self.getProperty('project', GITHUB_PROJECTS[0])
remote = self.getProperty('remote', 'origin')
if remote != 'origin':
remote = self.getProperty('remote', DEFAULT_REMOTE)
if remote != DEFAULT_REMOTE:
for command in [
['git', 'config', 'credential.helper', '!echo_credentials() { sleep 1; echo "username=${GIT_USER}"; echo "password=${GIT_PASSWORD}"; }; echo_credentials'],
self.shell_command('git remote add {} {}{}.git || {}'.format(remote, GITHUB_URL, project, self.shell_exit_0())),
Expand Down Expand Up @@ -832,7 +833,7 @@ def getResultSummary(self):

@defer.inlineCallbacks
def run(self):
remote = self.getProperty('remote', 'origin')
remote = self.getProperty('remote', DEFAULT_REMOTE)
base = self.getProperty('github.base.ref', DEFAULT_BRANCH)

commands = [
Expand All @@ -842,7 +843,7 @@ def run(self):
]
if base != DEFAULT_BRANCH:
commands.append(self.shell_command('git branch -D {} || {}'.format(DEFAULT_BRANCH, self.shell_exit_0())))
commands.append(['git', 'branch', '--track', DEFAULT_BRANCH, 'remotes/origin/{}'.format(DEFAULT_BRANCH)])
commands.append(['git', 'branch', '--track', DEFAULT_BRANCH, f'remotes/{DEFAULT_REMOTE}/{DEFAULT_BRANCH}'])

self.commands = []
for command in commands:
Expand Down Expand Up @@ -988,7 +989,7 @@ def hideStepIf(self, results, step):
def run(self):
self.commands = []

remote = self.getProperty('github.head.repo.full_name', 'origin').split('/')[0]
remote = self.getProperty('github.head.repo.full_name', DEFAULT_REMOTE).split('/')[0]
project = self.getProperty('github.head.repo.full_name', self.getProperty('project'))
pr_branch = self.getProperty('github.head.ref', DEFAULT_BRANCH)
rebase_target_hash = self.getProperty('ews_revision') or self.getProperty('got_revision')
Expand Down Expand Up @@ -4473,7 +4474,7 @@ class CleanGitRepo(steps.ShellSequence, ShellMixin):
flunkOnFailure = False
logEnviron = False

def __init__(self, default_branch=DEFAULT_BRANCH, remote='origin', **kwargs):
def __init__(self, default_branch=DEFAULT_BRANCH, remote=DEFAULT_REMOTE, **kwargs):
super(CleanGitRepo, self).__init__(timeout=5 * 60, **kwargs)
self.default_branch = default_branch
self.git_remote = remote
Expand Down Expand Up @@ -4759,13 +4760,13 @@ def __init__(self, **kwargs):
super(ValidateRemote, self).__init__(logEnviron=False, **kwargs)

def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
remote = self.getProperty('remote', 'origin')
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
remote = self.getProperty('remote', DEFAULT_REMOTE)

self.command = [
'git', 'merge-base', '--is-ancestor',
f'remotes/{remote}/{base_ref}',
f'remotes/origin/{base_ref}',
f'remotes/{DEFAULT_REMOTE}/{base_ref}',
]

return super(ValidateRemote, self).start()
Expand All @@ -4776,7 +4777,7 @@ def getResultSummary(self):
return super(ValidateRemote, self).getResultSummary()

def evaluateCommand(self, cmd):
base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
rc = super(ValidateRemote, self).evaluateCommand(cmd)

if rc == SUCCESS:
Expand All @@ -4802,7 +4803,7 @@ def doStepIf(self, step):
remote = self.getProperty('remote', None)
if not remote:
return False
return remote != 'origin'
return remote != DEFAULT_REMOTE

def hideStepIf(self, results, step):
return not self.doStepIf(step)
Expand All @@ -4818,7 +4819,7 @@ def __init__(self, **kwargs):
super(ValidateSquashed, self).__init__(logEnviron=False, **kwargs)

def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
head_ref = self.getProperty('github.head.ref', 'HEAD')
self.command = ['git', 'log', '--oneline', head_ref, f'^{base_ref}', '--max-count=2']

Expand Down Expand Up @@ -4910,7 +4911,7 @@ def __init__(self, **kwargs):
super(AddReviewerToCommitMessage, self).__init__(logEnviron=False, timeout=60, **kwargs)

def start(self, BufferLogObserverClass=logobserver.BufferLogObserver):
base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
head_ref = self.getProperty('github.head.ref', 'HEAD')

gmtoffset = int(time.localtime().tm_gmtoff * 100 / (60 * 60))
Expand Down Expand Up @@ -4994,7 +4995,7 @@ def _files(self):

@defer.inlineCallbacks
def run(self, BufferLogObserverClass=logobserver.BufferLogObserver):
base_ref = self.getProperty('github.base.ref', f'origin/{DEFAULT_BRANCH}')
base_ref = self.getProperty('github.base.ref', f'{DEFAULT_REMOTE}/{DEFAULT_BRANCH}')
head_ref = self.getProperty('github.head.ref', 'HEAD')
reviewers = self.getProperty('reviewers_full_names', None)
reviewer_error_msg = '' if reviewers else ' and no reviewer found'
Expand Down Expand Up @@ -5098,8 +5099,6 @@ def run(self):
commands += [['git', 'checkout', base_ref]]
commands.append(['python3', 'Tools/Scripts/git-webkit', 'canonicalize', '-n', '1' if self.rebase_enabled else '3'])



if self.getProperty('github.number', ''):
committer = (self.getProperty('owners', []) or [''])[0]
else:
Expand All @@ -5119,9 +5118,6 @@ def run(self):

for command in commands:
self.commands.append(util.ShellArg(command=command, logname='stdio', haltOnFailure=True))



return super(Canonicalize, self).run()

def getResultSummary(self):
Expand Down

0 comments on commit 58854f9

Please sign in to comment.