No bug: [mozhanress]: Remove set_/query_property from mozharness; r=Callek

The last place any properties were written out was removed in
https://phabricator.services.mozilla.com/D6170
Looking at the remaining uses, properties get set and modified but not used
anywhere.

Differential Revision: https://phabricator.services.mozilla.com/D6171

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Prince 2018-09-19 18:54:51 +00:00
Родитель a7c3a25c9b
Коммит cc905dafe7
5 изменённых файлов: 3 добавлений и 191 удалений

Просмотреть файл

@ -7,8 +7,6 @@
"""Code to integration with automation.
"""
import os
try:
import simplejson as json
assert json
@ -73,38 +71,6 @@ class AutomationMixin(object):
def query_failure(self, key):
return key in self.failures
def set_property(self, prop_name, prop_value):
self.info("Setting property %s to %s" % (prop_name, prop_value))
self.properties[prop_name] = prop_value
return self.properties[prop_name]
def query_property(self, prop_name):
return self.properties.get(prop_name)
def query_is_nightly(self):
"""returns whether or not the script should run as a nightly build."""
return bool(self.config.get('nightly_build'))
def dump_properties(self, prop_list=None, file_name="properties",
error_level=ERROR):
c = self.config
if not os.path.isabs(file_name):
file_name = os.path.join(c['base_work_dir'], "properties",
file_name)
dir_name = os.path.dirname(file_name)
if not os.path.isdir(dir_name):
self.mkdir_p(dir_name)
if not prop_list:
prop_list = self.properties.keys()
self.info("Writing properties to %s" % file_name)
else:
if not isinstance(prop_list, (list, tuple)):
self.log("dump_properties: Can't dump non-list prop_list %s!" %
str(prop_list), level=error_level)
return
self.info("Writing properties %s to %s" % (str(prop_list),
file_name))
contents = ""
for prop in prop_list:
contents += "%s:%s\n" % (prop, self.properties.get(prop, "None"))
return self.write_to_file(file_name, contents)

Просмотреть файл

@ -82,71 +82,13 @@ TBPL_UPLOAD_ERRORS = [
class MakeUploadOutputParser(OutputParser):
tbpl_error_list = TBPL_UPLOAD_ERRORS
# let's create a switch case using name-spaces/dict
# rather than a long if/else with duplicate code
property_conditions = [
# key: property name, value: condition
('symbolsUrl', "m.endswith('crashreporter-symbols.zip') or "
"m.endswith('crashreporter-symbols-full.zip')"),
('testsUrl', "m.endswith(('tests.tar.bz2', 'tests.zip', 'tests.tar.gz'))"),
('robocopApkUrl', "m.endswith('apk') and 'robocop' in m"),
('jsshellUrl', "'jsshell-' in m and m.endswith('.zip')"),
('partialMarUrl', "m.endswith('.mar') and '.partial.' in m"),
('completeMarUrl', "m.endswith('.mar')"),
('codeCoverageUrl', "m.endswith('code-coverage-gcno.zip')"),
]
def __init__(self, use_package_as_marfile=False, package_filename=None, **kwargs):
def __init__(self, **kwargs):
super(MakeUploadOutputParser, self).__init__(**kwargs)
self.matches = {}
self.tbpl_status = TBPL_SUCCESS
self.use_package_as_marfile = use_package_as_marfile
self.package_filename = package_filename
def parse_single_line(self, line):
prop_assigned = False
pat = r'''^(https?://.*?\.(?:tar\.bz2|dmg|zip|apk|rpm|mar|tar\.gz))$'''
m = re.compile(pat).match(line)
if m:
m = m.group(1)
for prop, condition in self.property_conditions:
if eval(condition):
self.matches[prop] = m
prop_assigned = True
break
if not prop_assigned:
# if we found a match but haven't identified the prop then this
# is the packageURL. Alternatively, if we already know the
# package filename, then use that explicitly so we don't pick up
# just any random file and assume it's the package.
if not self.package_filename or m.endswith(self.package_filename):
self.matches['packageUrl'] = m
# For android builds, the package is also used as the mar file.
# Grab the first one, since that is the one in the
# nightly/YYYY/MM directory
if self.use_package_as_marfile:
if 'tinderbox-builds' in m or 'nightly/latest-' in m:
self.info("Skipping wrong packageUrl: %s" % m)
else:
if 'completeMarUrl' in self.matches:
self.fatal("Found multiple package URLs. Please update buildbase.py")
self.info("Using package as mar file: %s" % m)
self.matches['completeMarUrl'] = m
u, self.package_filename = os.path.split(m)
if self.use_package_as_marfile and self.package_filename:
# The checksum file is also dumped during 'make upload'. Look
# through here to get the hash and filesize of the android package
# for balrog submission.
pat = r'''^([^ ]*) sha512 ([0-9]*) %s$''' % self.package_filename
m = re.compile(pat).match(line)
if m:
self.matches['completeMarHash'] = m.group(1)
self.matches['completeMarSize'] = m.group(2)
self.info("Using package as mar file and found package hash=%s size=%s" % (m.group(1), m.group(2)))
# now let's check for retry errors which will give log levels:
# let's check for retry errors which will give log levels:
# tbpl status as RETRY and mozharness status as WARNING
for error_check in self.tbpl_error_list:
if error_check['regex'].search(line):
@ -843,9 +785,6 @@ or run without that action (ie: --no-{action})"
self.info("Creating buildid through current time")
buildid = generate_build_ID()
if c.get('is_automation') or os.environ.get("TASK_ID"):
self.set_property('buildid', buildid)
self.buildid = buildid
return self.buildid
@ -1087,31 +1026,6 @@ or run without that action (ie: --no-{action})"
)
return revision.encode('ascii', 'replace') if revision else None
def _query_props_set_by_mach(self, console_output=True, error_level=FATAL):
mach_properties_path = os.path.join(
self.query_abs_dirs()['abs_obj_dir'], 'dist', 'mach_build_properties.json'
)
self.info("setting properties set by mach build. Looking in path: %s"
% mach_properties_path)
if os.path.exists(mach_properties_path):
with self.opened(mach_properties_path, error_level=error_level) as (fh, err):
build_props = json.load(fh)
if err:
self.log("%s exists but there was an error reading the "
"properties. props: `%s` - error: "
"`%s`" % (mach_properties_path,
build_props or 'None',
err or 'No error'),
error_level)
if console_output:
self.info("Properties set from 'mach build'")
self.info(pprint.pformat(build_props))
for key, prop in build_props.iteritems():
if prop != 'UNKNOWN':
self.set_property(key, prop)
else:
self.info("No mach_build_properties.json found - not importing properties.")
def generate_build_props(self, console_output=True, halt_on_failure=False):
"""sets props found from mach build and, in addition, buildid,
sourcestamp, appVersion, and appName."""
@ -1123,10 +1037,6 @@ or run without that action (ie: --no-{action})"
if self.generated_build_props:
return
# grab props set by mach if any
self._query_props_set_by_mach(console_output=console_output,
error_level=error_level)
dirs = self.query_abs_dirs()
print_conf_setting_path = os.path.join(dirs['abs_src_dir'],
'config',
@ -1141,25 +1051,10 @@ or run without that action (ie: --no-{action})"
dirs['abs_app_ini_path']),
level=error_level)
self.info("Setting properties found in: %s" % dirs['abs_app_ini_path'])
base_cmd = [
sys.executable, os.path.join(dirs['abs_src_dir'], 'mach'), 'python',
print_conf_setting_path, dirs['abs_app_ini_path'], 'App'
]
properties_needed = [
{'ini_name': 'SourceStamp', 'prop_name': 'sourcestamp'},
{'ini_name': 'Version', 'prop_name': 'appVersion'},
{'ini_name': 'Name', 'prop_name': 'appName'}
]
env = self.query_build_env()
# dirs['abs_obj_dir'] can be different from env['MOZ_OBJDIR'] on
# mac, and that confuses mach.
del env['MOZ_OBJDIR']
for prop in properties_needed:
prop_val = self.get_output_from_command(
base_cmd + [prop['ini_name']], cwd=dirs['abs_obj_dir'],
halt_on_failure=halt_on_failure, env=env
)
self.set_property(prop['prop_name'], prop_val)
if self.config.get('is_automation'):
self.info("Verifying buildid from application.ini matches buildid "
@ -1315,16 +1210,12 @@ or run without that action (ie: --no-{action})"
parser = MakeUploadOutputParser(config=self.config,
log_obj=self.log_obj,
use_package_as_marfile=True,
package_filename=package_filename,
)
upload_cmd = ['make', 'upload', 'AB_CD=multi']
self.run_command(upload_cmd,
env=self.query_mach_build_env(multiLocale=False),
cwd=objdir, halt_on_failure=True,
output_parser=parser)
for prop in parser.matches:
self.set_property(prop, parser.matches[prop])
upload_files_cmd = [
'make',
'echo-variable-UPLOAD_FILES',

Просмотреть файл

@ -412,7 +412,6 @@ You can set this by specifying --test-url URL
parent_dir=dirs['abs_work_dir'],
error_level=FATAL)
self.installer_path = os.path.realpath(source)
self.set_property("build_url", self.installer_url)
def _download_and_extract_symbols(self):
dirs = self.query_abs_dirs()
@ -435,7 +434,6 @@ You can set this by specifying --test-url URL
if not self.symbols_path:
self.symbols_path = os.path.join(dirs['abs_work_dir'], 'symbols')
self.set_property("symbols_url", self.symbols_url)
if self.symbols_url:
self.download_unpack(self.symbols_url, self.symbols_path)

Просмотреть файл

@ -125,7 +125,6 @@ class DesktopSingleLocale(LocalesMixin, AutomationMixin,
self.revision = None
self.version = None
self.upload_urls = {}
self.locales_property = {}
self.pushdate = None
# upload_files is a dictionary of files to upload, keyed by locale.
self.upload_files = {}
@ -347,34 +346,9 @@ class DesktopSingleLocale(LocalesMixin, AutomationMixin,
else:
# func failed...
message = 'failure: %s(%s)' % (name, item)
self._add_failure(item, message)
self.add_failure(item, message)
return (success_count, total_count)
def _add_failure(self, locale, message, **kwargs):
"""marks current step as failed"""
self.locales_property[locale] = FAILURE_STR
prop_key = "%s_failure" % locale
prop_value = self.query_property(prop_key)
if prop_value:
prop_value = "%s %s" % (prop_value, message)
else:
prop_value = message
self.set_property(prop_key, prop_value)
AutomationMixin.add_failure(self, locale, message=message, **kwargs)
def query_failed_locales(self):
return [l for l, res in self.locales_property.items() if
res == FAILURE_STR]
def summary(self):
"""generates a summary"""
BaseScript.summary(self)
# TODO we probably want to make this configurable on/off
locales = self.query_locales()
for locale in locales:
self.locales_property.setdefault(locale, SUCCESS_STR)
self.set_property("locales", json.dumps(self.locales_property))
# Actions {{{2
def clone_locales(self):
self.pull_locale_source()

Просмотреть файл

@ -95,7 +95,6 @@ class MobileSingleLocale(LocalesMixin, TooltoolMixin, AutomationMixin,
self.upload_env = None
self.version = None
self.upload_urls = {}
self.locales_property = {}
# Helper methods {{{2
def query_repack_env(self):
@ -209,24 +208,8 @@ class MobileSingleLocale(LocalesMixin, TooltoolMixin, AutomationMixin,
return self.abs_dirs
def add_failure(self, locale, message, **kwargs):
self.locales_property[locale] = "Failed"
prop_key = "%s_failure" % locale
prop_value = self.query_property(prop_key)
if prop_value:
prop_value = "%s %s" % (prop_value, message)
else:
prop_value = message
self.set_property(prop_key, prop_value)
AutomationMixin.add_failure(self, locale, message=message, **kwargs)
def summary(self):
MercurialScript.summary(self)
# TODO we probably want to make this configurable on/off
locales = self.query_locales()
for locale in locales:
self.locales_property.setdefault(locale, "Success")
self.set_property("locales", json.dumps(self.locales_property))
# Actions {{{2
def clone_locales(self):
self.pull_locale_source()