Skip to content

Commit

Permalink
[ews-build.webkit.org] Aggressively prune when cleaning
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=248895
rdar://103082277

Reviewed by Ryan Haddad.

* Tools/CISupport/ews-build/steps.py:
(CleanGitRepo.run): Delete .git/gc.log and run `git prune`.
* Tools/CISupport/ews-build/steps_unittest.py:

Canonical link: https://commits.webkit.org/257496@main
  • Loading branch information
JonWBedard committed Dec 7, 2022
1 parent 407bf5b commit 0284a8c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Tools/CISupport/ews-build/steps.py
Expand Up @@ -4662,6 +4662,17 @@ def __init__(self, default_branch=DEFAULT_BRANCH, remote=DEFAULT_REMOTE, **kwarg

def run(self):
self.commands = []
if self.getProperty('platform', '*') == 'wincairo':
self.commands.append(util.ShellArg(
command=self.shell_command(r'del .git\gc.log || {}'.format(self.shell_exit_0())),
logname='stdio',
))
else:
self.commands.append(util.ShellArg(
command=self.shell_command('rm -f .git/gc.log || {}'.format(self.shell_exit_0())),
logname='stdio',
))

for command in [
self.shell_command('git rebase --abort || {}'.format(self.shell_exit_0())),
self.shell_command('git am --abort || {}'.format(self.shell_exit_0())),
Expand All @@ -4672,6 +4683,7 @@ def run(self):
['git', 'checkout', '-b', '{}'.format(self.default_branch)], # Checkout local instance of branch from remote
self.shell_command('git branch | grep -v {} | xargs git branch -D || {}'.format(self.default_branch, self.shell_exit_0())),
self.shell_command('git remote | grep -v {} | xargs -L 1 git remote rm || {}'.format(self.git_remote, self.shell_exit_0())),
['git', 'prune'],
]:
self.commands.append(util.ShellArg(command=command, logname='stdio'))
return super(CleanGitRepo, self).run()
Expand Down
20 changes: 20 additions & 0 deletions Tools/CISupport/ews-build/steps_unittest.py
Expand Up @@ -5001,6 +5001,8 @@ def test_success(self):
self.setProperty('buildername', 'Style-EWS')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'rm -f .git/gc.log || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git am --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
Expand All @@ -5019,6 +5021,8 @@ def test_success(self):
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'prune'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
)
self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
return self.runStep()
Expand All @@ -5029,6 +5033,8 @@ def test_success_wincairo(self):
self.setProperty('platform', 'wincairo')

self.expectRemoteCommands(
ExpectShell(command=['sh', '-c', r'del .git\gc.log || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['sh', '-c', 'git rebase --abort || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['sh', '-c', 'git am --abort || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
Expand All @@ -5047,6 +5053,8 @@ def test_success_wincairo(self):
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || exit 0'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'prune'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
)
self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
return self.runStep()
Expand All @@ -5056,6 +5064,8 @@ def test_success_master(self):
self.setProperty('buildername', 'Commit-Queue')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'rm -f .git/gc.log || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git am --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
Expand All @@ -5074,6 +5084,8 @@ def test_success_master(self):
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'prune'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
)
self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
return self.runStep()
Expand All @@ -5083,6 +5095,8 @@ def test_failure(self):
self.setProperty('buildername', 'Commit-Queue')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'rm -f .git/gc.log || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git am --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
Expand All @@ -5101,6 +5115,8 @@ def test_failure(self):
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'prune'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
)
self.expectOutcome(result=FAILURE, state_string='Encountered some issues during cleanup')
return self.runStep()
Expand All @@ -5111,6 +5127,8 @@ def test_branch(self):
self.setProperty('basename', 'safari-612-branch')

self.expectRemoteCommands(
ExpectShell(command=['/bin/sh', '-c', 'rm -f .git/gc.log || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git rebase --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git am --abort || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
Expand All @@ -5129,6 +5147,8 @@ def test_branch(self):
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['/bin/sh', '-c', 'git remote | grep -v origin | xargs -L 1 git remote rm || true'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
ExpectShell(command=['git', 'prune'], workdir='wkdir', timeout=300, logEnviron=False) + 0
+ ExpectShell.log('stdio', stdout=''),
)
self.expectOutcome(result=SUCCESS, state_string='Cleaned up git repository')
return self.runStep()
Expand Down

0 comments on commit 0284a8c

Please sign in to comment.