Commit 82f6f89a authored by prasadv's avatar prasadv Committed by Commit bot

Trigger build request using git try instead of try_job_http on bisect bots

Bisect builders fail to apply patches sent via try_job_http,
because of this we were not able to build revisions with DEPS patches.
Now we are using "git try" instead to trigger build request on bisect builders.

BUG=411418
NOTRY=true

Review URL: https://codereview.chromium.org/607803005

Cr-Commit-Position: refs/heads/master@{#297918}
parent 2178ddcc
...@@ -176,10 +176,10 @@ HIGH_CONFIDENCE = 95 ...@@ -176,10 +176,10 @@ HIGH_CONFIDENCE = 95
# When a build requested is posted with a patch, bisect builders on try server, # When a build requested is posted with a patch, bisect builders on try server,
# once build is produced, it reads SHA value from this file and appends it # once build is produced, it reads SHA value from this file and appends it
# to build archive filename. # to build archive filename.
DEPS_SHA_PATCH = """diff --git src/DEPS.sha src/DEPS.sha DEPS_SHA_PATCH = """diff --git DEPS.sha DEPS.sha
new file mode 100644 new file mode 100644
--- /dev/null --- /dev/null
+++ src/DEPS.sha +++ DEPS.sha
@@ -0,0 +1 @@ @@ -0,0 +1 @@
+%(deps_sha)s +%(deps_sha)s
""" """
...@@ -250,6 +250,20 @@ O O | Visit http://www.chromium.org/developers/core-principles for Chrome's ...@@ -250,6 +250,20 @@ O O | Visit http://www.chromium.org/developers/core-principles for Chrome's
X | policy on perf regressions. Contact chrome-perf-dashboard-team with any X | policy on perf regressions. Contact chrome-perf-dashboard-team with any
/ \ | questions or suggestions about bisecting. THANK YOU.""" / \ | questions or suggestions about bisecting. THANK YOU."""
# Git branch name used to run bisect try jobs.
BISECT_TRYJOB_BRANCH = 'bisect-tryjob'
# Git master branch name.
BISECT_MASTER_BRANCH = 'master'
# File to store 'git diff' content.
BISECT_PATCH_FILE = 'deps_patch.txt'
# SVN repo where the bisect try jobs are submitted.
SVN_REPO_URL = 'svn://svn.chromium.org/chrome-try/try-perf'
class RunGitError(Exception):
def __str__(self):
return '%s\nError executing git command.' % self.args[0]
def _AddAdditionalDepotInfo(depot_info): def _AddAdditionalDepotInfo(depot_info):
"""Adds additional depot info to the global depot variables.""" """Adds additional depot info to the global depot variables."""
...@@ -846,6 +860,95 @@ class DepotDirectoryRegistry(object): ...@@ -846,6 +860,95 @@ class DepotDirectoryRegistry(object):
""" """
os.chdir(self.GetDepotDir(depot_name)) os.chdir(self.GetDepotDir(depot_name))
def _PrepareBisectBranch(parent_branch, new_branch):
"""Creates a new branch to submit bisect try job.
Args:
parent_branch: Parent branch to be used to create new branch.
new_branch: New branch name.
"""
current_branch, returncode = bisect_utils.RunGit(
['rev-parse', '--abbrev-ref', 'HEAD'])
if returncode:
raise RunGitError('Must be in a git repository to send changes to trybots.')
current_branch = current_branch.strip()
# Make sure current branch is master.
if current_branch != parent_branch:
output, returncode = bisect_utils.RunGit(['checkout', '-f', parent_branch])
if returncode:
raise RunGitError('Failed to checkout branch: %s.' % output)
# Delete new branch if exists.
output, returncode = bisect_utils.RunGit(['branch', '--list' ])
if new_branch in output:
output, returncode = bisect_utils.RunGit(['branch', '-D', new_branch])
if returncode:
raise RunGitError('Deleting branch failed, %s', output)
# Check if the tree is dirty: make sure the index is up to date and then
# run diff-index.
bisect_utils.RunGit(['update-index', '--refresh', '-q'])
output, returncode = bisect_utils.RunGit(['diff-index', 'HEAD'])
if output:
raise RunGitError('Cannot send a try job with a dirty tree.')
# Create/check out the telemetry-tryjob branch, and edit the configs
# for the tryjob there.
output, returncode = bisect_utils.RunGit(['checkout', '-b', new_branch])
if returncode:
raise RunGitError('Failed to checkout branch: %s.' % output)
output, returncode = bisect_utils.RunGit(
['branch', '--set-upstream-to', parent_branch])
if returncode:
raise RunGitError('Error in git branch --set-upstream-to')
def _BuilderTryjob(git_revision, bot_name, bisect_job_name, patch=None):
"""Attempts to run a tryjob from the current directory.
Args:
git_revision: A Git hash revision.
bot_name: Name of the bisect bot to be used for try job.
bisect_job_name: Bisect try job name.
patch: A DEPS patch (used while bisecting 3rd party repositories).
"""
try:
# Temporary branch for running tryjob.
_PrepareBisectBranch(BISECT_MASTER_BRANCH, BISECT_TRYJOB_BRANCH)
patch_content = '/dev/null'
# Create a temporary patch file, if it fails raise an exception.
if patch:
WriteStringToFile(patch, BISECT_PATCH_FILE)
patch_content = BISECT_PATCH_FILE
try_cmd = ['try',
'-b', bot_name,
'-r', git_revision,
'-n', bisect_job_name,
'--svn_repo=%s' % SVN_REPO_URL,
'--diff=%s' % patch_content
]
# Execute try job to build revision.
output, returncode = bisect_utils.RunGit(try_cmd)
if returncode:
raise RunGitError('Could not execute tryjob: %s.\n Error: %s' % (
'git %s' % ' '.join(try_cmd), output))
print ('Try job successfully submitted.\n TryJob Details: %s\n%s' % (
'git %s' % ' '.join(try_cmd), output))
finally:
# Delete patch file if exists
try:
os.remove(BISECT_PATCH_FILE)
except OSError as e:
if e.errno != errno.ENOENT:
raise
# Checkout master branch and delete bisect-tryjob branch.
bisect_utils.RunGit(['checkout', '-f', BISECT_MASTER_BRANCH])
bisect_utils.RunGit(['branch', '-D', BISECT_TRYJOB_BRANCH])
class BisectPerformanceMetrics(object): class BisectPerformanceMetrics(object):
"""This class contains functionality to perform a bisection of a range of """This class contains functionality to perform a bisection of a range of
...@@ -1182,7 +1285,7 @@ class BisectPerformanceMetrics(object): ...@@ -1182,7 +1285,7 @@ class BisectPerformanceMetrics(object):
return FetchFromCloudStorage(gs_bucket, source_file, out_dir) return FetchFromCloudStorage(gs_bucket, source_file, out_dir)
return downloaded_archive return downloaded_archive
def DownloadCurrentBuild(self, revision, build_type='Release', patch=None): def DownloadCurrentBuild(self, revision, depot, build_type='Release'):
"""Downloads the build archive for the given revision. """Downloads the build archive for the given revision.
Args: Args:
...@@ -1193,7 +1296,12 @@ class BisectPerformanceMetrics(object): ...@@ -1193,7 +1296,12 @@ class BisectPerformanceMetrics(object):
Returns: Returns:
True if download succeeds, otherwise False. True if download succeeds, otherwise False.
""" """
patch = None
patch_sha = None patch_sha = None
if depot != 'chromium':
# Create a DEPS patch with new revision for dependency repository.
revision, patch = self.CreateDEPSPatch(depot, revision)
if patch: if patch:
# Get the SHA of the DEPS changes patch. # Get the SHA of the DEPS changes patch.
patch_sha = GetSHA1HexDigest(patch) patch_sha = GetSHA1HexDigest(patch)
...@@ -1290,37 +1398,31 @@ class BisectPerformanceMetrics(object): ...@@ -1290,37 +1398,31 @@ class BisectPerformanceMetrics(object):
if not fetch_build: if not fetch_build:
return False return False
bot_name, build_timeout = GetBuilderNameAndBuildTime(
self.opts.target_platform, self.opts.target_arch)
builder_host = self.opts.builder_host
builder_port = self.opts.builder_port
# Create a unique ID for each build request posted to try server builders. # Create a unique ID for each build request posted to try server builders.
# This ID is added to "Reason" property of the build. # This ID is added to "Reason" property of the build.
build_request_id = GetSHA1HexDigest( build_request_id = GetSHA1HexDigest(
'%s-%s-%s' % (git_revision, patch, time.time())) '%s-%s-%s' % (git_revision, patch, time.time()))
# Creates a try job description. # Reverts any changes to DEPS file.
# Always use Git hash to post build request since Commit positions are self.source_control.CheckoutFileAtRevision(
# not supported by builders to build. bisect_utils.FILE_DEPS, git_revision, cwd=self.src_cwd)
job_args = {
'revision': 'src@%s' % git_revision, bot_name, build_timeout = GetBuilderNameAndBuildTime(
'bot': bot_name, self.opts.target_platform, self.opts.target_arch)
'name': build_request_id, target_file = None
} try:
# Update patch information if supplied. # Execute try job request to build revision with patch.
if patch: _BuilderTryjob(git_revision, bot_name, build_request_id, patch)
job_args['patch'] = patch
# Posts job to build the revision on the server.
if request_build.PostTryJob(builder_host, builder_port, job_args):
target_file, error_msg = _WaitUntilBuildIsReady( target_file, error_msg = _WaitUntilBuildIsReady(
fetch_build, bot_name, builder_host, builder_port, build_request_id, fetch_build, bot_name, self.opts.builder_host,
build_timeout) self.opts.builder_port, build_request_id, build_timeout)
if not target_file: if not target_file:
print '%s [revision: %s]' % (error_msg, git_revision) print '%s [revision: %s]' % (error_msg, git_revision)
return None except RunGitError as e:
return target_file print ('Failed to post builder try job for revision: [%s].\n'
print 'Failed to post build request for revision: [%s]' % git_revision 'Error: %s' % (git_revision, e))
return None
return target_file
def IsDownloadable(self, depot): def IsDownloadable(self, depot):
"""Checks if build can be downloaded based on target platform and depot.""" """Checks if build can be downloaded based on target platform and depot."""
...@@ -1417,6 +1519,7 @@ class BisectPerformanceMetrics(object): ...@@ -1417,6 +1519,7 @@ class BisectPerformanceMetrics(object):
print 'Something went wrong while updating DEPS file. [%s]' % e print 'Something went wrong while updating DEPS file. [%s]' % e
return False return False
def CreateDEPSPatch(self, depot, revision): def CreateDEPSPatch(self, depot, revision):
"""Modifies DEPS and returns diff as text. """Modifies DEPS and returns diff as text.
...@@ -1444,8 +1547,8 @@ class BisectPerformanceMetrics(object): ...@@ -1444,8 +1547,8 @@ class BisectPerformanceMetrics(object):
if self.UpdateDeps(revision, depot, deps_file_path): if self.UpdateDeps(revision, depot, deps_file_path):
diff_command = [ diff_command = [
'diff', 'diff',
'--src-prefix=src/', '--src-prefix=',
'--dst-prefix=src/', '--dst-prefix=',
'--no-ext-diff', '--no-ext-diff',
bisect_utils.FILE_DEPS, bisect_utils.FILE_DEPS,
] ]
...@@ -1474,16 +1577,7 @@ class BisectPerformanceMetrics(object): ...@@ -1474,16 +1577,7 @@ class BisectPerformanceMetrics(object):
# Fetch build archive for the given revision from the cloud storage when # Fetch build archive for the given revision from the cloud storage when
# the storage bucket is passed. # the storage bucket is passed.
if self.IsDownloadable(depot) and revision: if self.IsDownloadable(depot) and revision:
deps_patch = None build_success = self.DownloadCurrentBuild(revision, depot)
if depot != 'chromium':
# Create a DEPS patch with new revision for dependency repository.
revision, deps_patch = self.CreateDEPSPatch(depot, revision)
if self.DownloadCurrentBuild(revision, patch=deps_patch):
if deps_patch:
# Reverts the changes to DEPS file.
self.source_control.CheckoutFileAtRevision(
bisect_utils.FILE_DEPS, revision, cwd=self.src_cwd)
build_success = True
else: else:
# These codes are executed when bisect bots builds binaries locally. # These codes are executed when bisect bots builds binaries locally.
build_success = self.builder.Build(depot, self.opts) build_success = self.builder.Build(depot, self.opts)
...@@ -1779,17 +1873,7 @@ class BisectPerformanceMetrics(object): ...@@ -1779,17 +1873,7 @@ class BisectPerformanceMetrics(object):
Returns: Returns:
True if successful. True if successful.
""" """
if depot == 'chromium' or depot == 'android-chrome': if depot == 'cros':
# Removes third_party/libjingle. At some point, libjingle was causing
# issues syncing when using the git workflow (crbug.com/266324).
os.chdir(self.src_cwd)
if not bisect_utils.RemoveThirdPartyDirectory('libjingle'):
return False
# Removes third_party/skia. At some point, skia was causing
# issues syncing when using the git workflow (crbug.com/377951).
if not bisect_utils.RemoveThirdPartyDirectory('skia'):
return False
elif depot == 'cros':
return self.PerformCrosChrootCleanup() return self.PerformCrosChrootCleanup()
return True return True
...@@ -2639,7 +2723,8 @@ class BisectPerformanceMetrics(object): ...@@ -2639,7 +2723,8 @@ class BisectPerformanceMetrics(object):
current_data['depot']) current_data['depot'])
if not cl_link: if not cl_link:
cl_link = current_id cl_link = current_id
commit_position = self.source_control.GetCommitPosition(current_id) commit_position = self.source_control.GetCommitPosition(
current_id, self.depot_registry.GetDepotDir(current_data['depot']))
commit_position = str(commit_position) commit_position = str(commit_position)
if not commit_position: if not commit_position:
commit_position = '' commit_position = ''
......
...@@ -5,12 +5,18 @@ ...@@ -5,12 +5,18 @@
import os import os
import re import re
import shutil import shutil
import sys
import unittest import unittest
SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)
sys.path.append(os.path.join(SRC, 'third_party', 'pymock'))
import bisect_perf_regression import bisect_perf_regression
import bisect_results import bisect_results
import mock
import source_control as source_control_module import source_control as source_control_module
def _GetBisectPerformanceMetricsInstance(): def _GetBisectPerformanceMetricsInstance():
"""Returns an instance of the BisectPerformanceMetrics class.""" """Returns an instance of the BisectPerformanceMetrics class."""
options_dict = { options_dict = {
...@@ -348,5 +354,156 @@ class DepotDirectoryRegistryTest(unittest.TestCase): ...@@ -348,5 +354,156 @@ class DepotDirectoryRegistryTest(unittest.TestCase):
self.assertEqual(self.cur_dir, '/mock/src/foo') self.assertEqual(self.cur_dir, '/mock/src/foo')
# The tests below test private functions (W0212).
# pylint: disable=W0212
class GitTryJobTestCases(unittest.TestCase):
"""Test case for bisect try job."""
def setUp(self):
bisect_utils_patcher = mock.patch('bisect_perf_regression.bisect_utils')
self.mock_bisect_utils = bisect_utils_patcher.start()
self.addCleanup(bisect_utils_patcher.stop)
def _SetupRunGitMock(self, git_cmds):
"""Setup RunGit mock with expected output for given git command."""
def side_effect(git_cmd_args):
for val in git_cmds:
if set(val[0]) == set(git_cmd_args):
return val[1]
self.mock_bisect_utils.RunGit = mock.Mock(side_effect=side_effect)
def _AssertRunGitExceptions(self, git_cmds, func, *args):
"""Setup RunGit mock and tests RunGitException.
Args:
git_cmds: List of tuples with git command and expected output.
func: Callback function to be executed.
args: List of arguments to be passed to the function.
"""
self._SetupRunGitMock(git_cmds)
self.assertRaises(bisect_perf_regression.RunGitError,
func,
*args)
def testNotGitRepo(self):
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [(['rev-parse', '--abbrev-ref', 'HEAD'], (None, 128))]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testFailedCheckoutMaster(self):
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (new_branch, 0)),
(['checkout', '-f', parent_branch], ('Checkout Failed', 1))]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testDeleteBisectBranchIfExists(self):
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('Failed to delete branch', 128))
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testCreatNewBranchFails(self):
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
(['checkout', '-b', new_branch], ('Failed to create branch', 128))
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testSetUpstreamToFails(self):
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
cmds = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
(['checkout', '-b', new_branch], ('None', 0)),
(['branch', '--set-upstream-to', parent_branch],
('Setuptream fails', 1))
]
self._AssertRunGitExceptions(cmds,
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testBuilderTryJobForException(self):
git_revision = 'ac4a9f31fe2610bd146857bbd55d7a260003a888'
bot_name = 'linux_perf_bisect_builder'
bisect_job_name = 'testBisectJobname'
patch = None
patch_content = '/dev/null'
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
try_cmd = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
(['checkout', '-b', new_branch], ('None', 0)),
(['branch', '--set-upstream-to', parent_branch],
('Setuptream fails', 0)),
(['try',
'-b', bot_name,
'-r', git_revision,
'-n', bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.SVN_REPO_URL,
'--diff=%s' % patch_content
], (None, 1))
]
self._AssertRunGitExceptions(try_cmd,
bisect_perf_regression._BuilderTryjob,
git_revision, bot_name, bisect_job_name, patch)
def testBuilderTryJob(self):
git_revision = 'ac4a9f31fe2610bd146857bbd55d7a260003a888'
bot_name = 'linux_perf_bisect_builder'
bisect_job_name = 'testBisectJobname'
patch = None
patch_content = '/dev/null'
new_branch = bisect_perf_regression.BISECT_TRYJOB_BRANCH
parent_branch = bisect_perf_regression.BISECT_MASTER_BRANCH
try_cmd = [
(['rev-parse', '--abbrev-ref', 'HEAD'], (parent_branch, 0)),
(['branch', '--list' ], ('bisect-tryjob\n*master\nsomebranch', 0)),
(['branch', '-D', new_branch], ('None', 0)),
(['update-index', '--refresh', '-q'], (None, 0)),
(['diff-index', 'HEAD'], (None, 0)),
(['checkout', '-b', new_branch], ('None', 0)),
(['branch', '--set-upstream-to', parent_branch],
('Setuptream fails', 0)),
(['try',
'-b', bot_name,
'-r', git_revision,
'-n', bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.SVN_REPO_URL,
'--diff=%s' % patch_content
], (None, 0))
]
self._SetupRunGitMock(try_cmd)
bisect_perf_regression._BuilderTryjob(
git_revision, bot_name, bisect_job_name, patch)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -11,7 +11,6 @@ annotations for the Buildbot waterfall. ...@@ -11,7 +11,6 @@ annotations for the Buildbot waterfall.
import errno import errno
import imp import imp
import os import os
import shutil
import stat import stat
import subprocess import subprocess
import sys import sys
...@@ -83,6 +82,9 @@ REPO_PARAMS = [ ...@@ -83,6 +82,9 @@ REPO_PARAMS = [
'https://git.chromium.org/external/repo.git' 'https://git.chromium.org/external/repo.git'
] ]
# Bisect working directory.
BISECT_DIR = 'bisect'
def OutputAnnotationStepStart(name): def OutputAnnotationStepStart(name):
"""Outputs annotation to signal the start of a step to a try bot. """Outputs annotation to signal the start of a step to a try bot.
...@@ -162,12 +164,12 @@ def _CreateAndChangeToSourceDirectory(working_directory): ...@@ -162,12 +164,12 @@ def _CreateAndChangeToSourceDirectory(working_directory):
cwd = os.getcwd() cwd = os.getcwd()
os.chdir(working_directory) os.chdir(working_directory)
try: try:
os.mkdir('bisect') os.mkdir(BISECT_DIR)
except OSError, e: except OSError, e:
if e.errno != errno.EEXIST: # EEXIST indicates that it already exists. if e.errno != errno.EEXIST: # EEXIST indicates that it already exists.
os.chdir(cwd) os.chdir(cwd)
return False return False
os.chdir('bisect') os.chdir(BISECT_DIR)
return True return True
...@@ -308,28 +310,6 @@ def OnAccessError(func, path, _): ...@@ -308,28 +310,6 @@ def OnAccessError(func, path, _):
raise raise
def RemoveThirdPartyDirectory(dir_name):
"""Removes third_party directory from the source.
At some point, some of the third_parties were causing issues to changes in
the way they are synced. We remove such folder in order to avoid sync errors
while bisecting.
Returns:
True on success, otherwise False.
"""
path_to_dir = os.path.join(os.getcwd(), 'third_party', dir_name)
try:
if os.path.exists(path_to_dir):
shutil.rmtree(path_to_dir, onerror=OnAccessError)
except OSError, e:
print 'Error #%d while running shutil.rmtree(%s): %s' % (
e.errno, path_to_dir, str(e))
if e.errno != errno.ENOENT:
return False
return True
def _CleanupPreviousGitRuns(): def _CleanupPreviousGitRuns():
"""Cleans up any leftover index.lock files after running git.""" """Cleans up any leftover index.lock files after running git."""
# If a previous run of git crashed, or bot was reset, etc., then we might # If a previous run of git crashed, or bot was reset, etc., then we might
...@@ -350,7 +330,8 @@ def RunGClientAndSync(cwd=None): ...@@ -350,7 +330,8 @@ def RunGClientAndSync(cwd=None):
Returns: Returns:
The return code of the call. The return code of the call.
""" """
params = ['sync', '--verbose', '--nohooks', '--reset', '--force'] params = ['sync', '--verbose', '--nohooks', '--reset', '--force',
'--delete_unversioned_trees']
return RunGClient(params, cwd=cwd) return RunGClient(params, cwd=cwd)
...@@ -368,35 +349,19 @@ def SetupGitDepot(opts, custom_deps): ...@@ -368,35 +349,19 @@ def SetupGitDepot(opts, custom_deps):
otherwise. otherwise.
""" """
name = 'Setting up Bisection Depot' name = 'Setting up Bisection Depot'
try:
if opts.output_buildbot_annotations:
OutputAnnotationStepStart(name)
if opts.output_buildbot_annotations: if RunGClientAndCreateConfig(opts, custom_deps):
OutputAnnotationStepStart(name) return False
passed = False
if not RunGClientAndCreateConfig(opts, custom_deps):
passed_deps_check = True
if os.path.isfile(os.path.join('src', FILE_DEPS_GIT)):
cwd = os.getcwd()
os.chdir('src')
if passed_deps_check:
passed_deps_check = RemoveThirdPartyDirectory('libjingle')
if passed_deps_check:
passed_deps_check = RemoveThirdPartyDirectory('skia')
os.chdir(cwd)
if passed_deps_check:
_CleanupPreviousGitRuns()
RunGClient(['revert'])
if not RunGClientAndSync():
passed = True
if opts.output_buildbot_annotations: _CleanupPreviousGitRuns()
print RunGClient(['revert'])
OutputAnnotationStepClosed() return not RunGClientAndSync()
finally:
return passed if opts.output_buildbot_annotations:
OutputAnnotationStepClosed()
def CheckIfBisectDepotExists(opts): def CheckIfBisectDepotExists(opts):
...@@ -408,7 +373,7 @@ def CheckIfBisectDepotExists(opts): ...@@ -408,7 +373,7 @@ def CheckIfBisectDepotExists(opts):
Returns: Returns:
Returns True if it exists. Returns True if it exists.
""" """
path_to_dir = os.path.join(opts.working_directory, 'bisect', 'src') path_to_dir = os.path.join(opts.working_directory, BISECT_DIR, 'src')
return os.path.exists(path_to_dir) return os.path.exists(path_to_dir)
...@@ -451,6 +416,15 @@ def CreateBisectDirectoryAndSetupDepot(opts, custom_deps): ...@@ -451,6 +416,15 @@ def CreateBisectDirectoryAndSetupDepot(opts, custom_deps):
opts: The options parsed from the command line through parse_args(). opts: The options parsed from the command line through parse_args().
custom_deps: A dictionary of additional dependencies to add to .gclient. custom_deps: A dictionary of additional dependencies to add to .gclient.
""" """
if CheckIfBisectDepotExists(opts):
path_to_dir = os.path.join(os.path.abspath(opts.working_directory),
BISECT_DIR, 'src')
(output, _) = RunGit(['rev-parse', '--is-inside-work-tree'],
cwd=path_to_dir)
if output.strip() == 'true':
# Checks out the master branch, throws an exception if git command fails.
CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir)
if not _CreateAndChangeToSourceDirectory(opts.working_directory): if not _CreateAndChangeToSourceDirectory(opts.working_directory):
raise RuntimeError('Could not create bisect directory.') raise RuntimeError('Could not create bisect directory.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment