Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: scripts/slave/slave_utils.py

Issue 2330133002: Updating the SwarmingIsolatedScriptTest to upload chartjson results to the (Closed)
Patch Set: Removing stale code Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Functions specific to build slaves, shared by several buildbot scripts. 5 """Functions specific to build slaves, shared by several buildbot scripts.
6 """ 6 """
7 7
8 import datetime 8 import datetime
9 import glob 9 import glob
10 import os 10 import os
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 '--filesync', 729 '--filesync',
730 '--recurse-paths', 730 '--recurse-paths',
731 '--symlinks', 731 '--symlinks',
732 local_archive, 732 local_archive,
733 ] 733 ]
734 zip_cmd.extend(targets) 734 zip_cmd.extend(targets)
735 735
736 chromium_utils.RunCommand(zip_cmd) 736 chromium_utils.RunCommand(zip_cmd)
737 GSUtilCopy(local_archive, 'gs://%s/%s' % (bucket, archive)) 737 GSUtilCopy(local_archive, 'gs://%s/%s' % (bucket, archive))
738 return 'https://storage.cloud.google.com/%s/%s' % (bucket, archive) 738 return 'https://storage.cloud.google.com/%s/%s' % (bucket, archive)
739
740
741 def GetTelemetryRevisions(
742 build_properties, main_revision, blink_revision, point_id=None):
743 """Fills in the same revisions fields that process_log_utils does."""
744
745 versions = {}
746 versions['rev'] = main_revision
747 versions['webkit_rev'] = blink_revision
748 versions['webrtc_rev'] = build_properties.get('got_webrtc_revision')
749 versions['v8_rev'] = build_properties.get('got_v8_revision')
750 versions['ver'] = build_properties.get('version')
751 versions['git_revision'] = build_properties.get('git_revision')
752 versions['point_id'] = point_id
753 # There are a lot of "bad" revisions to check for, so clean them all up here.
754 for key in versions.keys():
755 if not versions[key] or versions[key] == 'undefined':
756 del versions[key]
757 return versions
758
759
760 def GetMainRevision(build_properties, build_dir, revision=None):
761 """Return revision to use as the numerical x-value in the perf dashboard.
762
763 This will be used as the value of "rev" in the data passed to
764 results_dashboard.SendResults.
765
766 In order or priority, this function could return:
767 1. The value of the --revision flag (IF it can be parsed as an int).
768 2. The value of "got_revision_cp" in build properties.
769 3. An SVN number, git commit position, or git commit hash.
770 """
771 if revision and revision.isdigit():
772 return revision
773 commit_pos_num = _GetCommitPos(build_properties)
774 if commit_pos_num is not None:
775 return commit_pos_num
776 # TODO(sullivan,qyearsley): Don't fall back to _GetRevision if it returns
777 # a git commit, since this should be a numerical revision. Instead, abort
778 # and fail.
779 return GetRevision(os.path.dirname(os.path.abspath(build_dir)))
780
781
782 def GetBlinkRevision(build_dir, webkit_revision=None):
783 if webkit_revision:
784 webkit_revision = webkit_revision
785 else:
786 try:
787 webkit_dir = chromium_utils.FindUpward(
788 os.path.abspath(build_dir), 'third_party', 'WebKit', 'Source')
789 webkit_revision = slave_utils.GetRevision(webkit_dir)
790 except Exception:
791 webkit_revision = None
792 return webkit_revision
793
794
795 def GetRevision(in_directory):
796 """Returns the SVN revision, git commit position, or git hash.
797
798 Args:
799 in_directory: A directory in the repository to be checked.
800
801 Returns:
802 An SVN revision as a string if the given directory is in a SVN repository,
803 or a git commit position number, or if that's not available, a git hash.
804 If all of that fails, an empty string is returned.
805 """
806 import xml.dom.minidom
807 if not os.path.exists(os.path.join(in_directory, '.svn')):
808 if _IsGitDirectory(in_directory):
809 svn_rev = _GetGitCommitPosition(in_directory)
810 if svn_rev:
811 return svn_rev
812 return _GetGitRevision(in_directory)
813 else:
814 return ''
815
816 def _GetCommitPos(build_properties):
817 """Extracts the commit position from the build properties, if its there."""
818 if 'got_revision_cp' not in build_properties:
819 return None
820 commit_pos = build_properties['got_revision_cp']
821 return int(re.search(r'{#(\d+)}', commit_pos).group(1))
822
823
824 def _GetGitCommitPositionFromLog(log):
825 """Returns either the commit position or svn rev from a git log."""
826 # Parse from the bottom up, in case the commit message embeds the message
827 # from a different commit (e.g., for a revert).
828 for r in [GIT_CR_POS_RE, GIT_SVN_ID_RE]:
829 for line in reversed(log.splitlines()):
830 m = r.match(line.strip())
831 if m:
832 return m.group(1)
833 return None
834
835
836 def _GetGitCommitPosition(dir_path):
837 """Extracts the commit position or svn revision number of the HEAD commit."""
838 git_exe = 'git.bat' if sys.platform.startswith('win') else 'git'
839 p = subprocess.Popen(
840 [git_exe, 'log', '-n', '1', '--pretty=format:%B', 'HEAD'],
841 cwd=dir_path, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
842 (log, _) = p.communicate()
843 if p.returncode != 0:
844 return None
845 return _GetGitCommitPositionFromLog(log)
846
847
848 def _GetGitRevision(in_directory):
849 """Returns the git hash tag for the given directory.
850
851 Args:
852 in_directory: The directory where git is to be run.
853
854 Returns:
855 The git SHA1 hash string.
856 """
857 git_exe = 'git.bat' if sys.platform.startswith('win') else 'git'
858 p = subprocess.Popen(
859 [git_exe, 'rev-parse', 'HEAD'],
860 cwd=in_directory, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
861 (stdout, _) = p.communicate()
862 return stdout.strip()
OLDNEW
« scripts/slave/recipe_modules/swarming/api.py ('K') | « scripts/slave/runtest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698