зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1417232 - Part 1: Move Treeherder report logging to mach command. r=ted.mielczarek
This was in Gradle due to history. When this first landed, we invoked Gradle directly from the mozharness, and the best way to print the report URLs was from Gradle itself. When the Android Gradle suites were made tier 1, little harnesses (|mach android {checkstyle,findbugs,lint,test}|) were written and invoked locally and in automation. This functionality should have migrated with them. This removes the special Gradle target names from the Gradle configuration, making it easier to change them in the future. MozReview-Commit-ID: 1KPd3J5t82Q --HG-- extra : rebase_source : 1da85e31c113bc9da138817bebf981af8b9b66dd
This commit is contained in:
Родитель
2d84ab6e71
Коммит
e7f29934ad
|
@ -376,60 +376,6 @@ android.applicationVariants.all { variant ->
|
||||||
configureVariantWithJNIWrappers(variant, "Fennec")
|
configureVariantWithJNIWrappers(variant, "Fennec")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bug 1299015: Complain to treeherder if checkstyle, lint, or unittest fails. It's not obvious
|
|
||||||
// how to listen to individual errors in most cases, so we just link to the reports for now.
|
|
||||||
def makeTaskExecutionListener(artifactRootUrl) {
|
|
||||||
return new TaskExecutionListener() {
|
|
||||||
void beforeExecute(Task task) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
void afterExecute(Task task, TaskState state) {
|
|
||||||
if (!state.failure) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Link to the failing report. The task path and the report path
|
|
||||||
// depend on the android-lint task in
|
|
||||||
// taskcluster/ci/android-stuff/kind.yml. It's not possible to link
|
|
||||||
// directly, so for now consumers will need to copy-paste the URL.
|
|
||||||
switch (task.path) {
|
|
||||||
case ':app:checkstyle':
|
|
||||||
def url = "${artifactRootUrl}/public/android/checkstyle/checkstyle.xml"
|
|
||||||
println "TEST-UNEXPECTED-FAIL | android-checkstyle | Checkstyle rule violations were found. See the report at: $url"
|
|
||||||
break
|
|
||||||
|
|
||||||
case ':app:lintOfficialPhotonDebug':
|
|
||||||
def url = "${artifactRootUrl}/public/android/lint/lint-results-officialPhotonDebug.html"
|
|
||||||
println "TEST-UNEXPECTED-FAIL | android-lint | Lint found errors in the project; aborting build. See the report at: $url"
|
|
||||||
break
|
|
||||||
|
|
||||||
case ':app:testOfficialPhotonDebugUnitTest':
|
|
||||||
def url = "${artifactRootUrl}/public/android/unittest/officialPhotonDebug/index.html"
|
|
||||||
println "TEST-UNEXPECTED-FAIL | android-test | There were failing tests. See the reports at: $url"
|
|
||||||
break
|
|
||||||
|
|
||||||
case ':app:findbugsHtmlOfficialPhotonDebug':
|
|
||||||
def url = "${artifactRootUrl}/public/android/findbugs/findbugs-officialPhotonDebug-output.html"
|
|
||||||
println "TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: $url"
|
|
||||||
break
|
|
||||||
|
|
||||||
case ':app:findbugsXmlOfficialPhotonDebug':
|
|
||||||
def url = "${artifactRootUrl}/public/android/findbugs/findbugs-officialPhotonDebug-output.xml"
|
|
||||||
println "TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: $url"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TASK_ID and RUN_ID are provided by docker-worker; see
|
|
||||||
// https://docs.taskcluster.net/manual/execution/workers/docker-worker.
|
|
||||||
if (System.env.TASK_ID && System.env.RUN_ID) {
|
|
||||||
def artifactRootUrl = "https://queue.taskcluster.net/v1/task/${System.env.TASK_ID}/runs/${System.env.RUN_ID}/artifacts"
|
|
||||||
gradle.addListener(makeTaskExecutionListener(artifactRootUrl))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gradle.startParameter.taskNames.any { it.endsWith('UnitTest') }) {
|
if (gradle.startParameter.taskNames.any { it.endsWith('UnitTest') }) {
|
||||||
// Approach cribbed from https://github.com/rwinch/jce-checker.
|
// Approach cribbed from https://github.com/rwinch/jce-checker.
|
||||||
int maxKeyLen = javax.crypto.Cipher.getMaxAllowedKeyLength("AES")
|
int maxKeyLen = javax.crypto.Cipher.getMaxAllowedKeyLength("AES")
|
||||||
|
|
|
@ -40,6 +40,13 @@ def REMOVED(cls):
|
||||||
|
|
||||||
@CommandProvider
|
@CommandProvider
|
||||||
class MachCommands(MachCommandBase):
|
class MachCommands(MachCommandBase):
|
||||||
|
def _root_url(self, artifactdir=None, objdir=None):
|
||||||
|
if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ:
|
||||||
|
return 'https://queue.taskcluster.net/v1/task/{}/runs/{}/artifacts/{}'.format(os.environ['TASK_ID'], os.environ['RUN_ID'], artifactdir)
|
||||||
|
else:
|
||||||
|
return os.path.join(self.topobjdir, objdir)
|
||||||
|
|
||||||
|
|
||||||
@Command('android', category='devenv',
|
@Command('android', category='devenv',
|
||||||
description='Run Android-specific commands.',
|
description='Run Android-specific commands.',
|
||||||
conditions=[conditions.is_android])
|
conditions=[conditions.is_android])
|
||||||
|
@ -67,10 +74,9 @@ class MachCommands(MachCommandBase):
|
||||||
FileFinder,
|
FileFinder,
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ:
|
root_url = self._root_url(
|
||||||
root_url = "https://queue.taskcluster.net/v1/task/{}/runs/{}/artifacts/public/android/unittest".format(os.environ['TASK_ID'], os.environ['RUN_ID'])
|
artifactdir='public/android/unittest',
|
||||||
else:
|
objdir='gradle/build/mobile/android/app/reports/tests')
|
||||||
root_url = os.path.join(self.topobjdir, 'gradle/build/mobile/android/app/reports/tests')
|
|
||||||
|
|
||||||
reports = ('officialPhotonDebug',)
|
reports = ('officialPhotonDebug',)
|
||||||
for report in reports:
|
for report in reports:
|
||||||
|
@ -80,6 +86,14 @@ class MachCommands(MachCommandBase):
|
||||||
tree = ET.parse(f)
|
tree = ET.parse(f)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
|
# Log reports for Tree Herder "Job Details".
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}/{}/index.html">HTML {} report</a>, visit "Inspect Task" link for details'.format(root_url, report, report))
|
||||||
|
|
||||||
|
# And make the report display as soon as possible.
|
||||||
|
failed = root.findall('testcase/error') or root.findall('testcase/failure')
|
||||||
|
if failed:
|
||||||
|
print('TEST-UNEXPECTED-FAIL | android-test | There were failing tests. See the reports at: {}/{}/index.html'.format(root_url, report))
|
||||||
|
|
||||||
print('SUITE-START | android-test | {} {}'.format(report, root.get('name')))
|
print('SUITE-START | android-test | {} {}'.format(report, root.get('name')))
|
||||||
|
|
||||||
for testcase in root.findall('testcase'):
|
for testcase in root.findall('testcase'):
|
||||||
|
@ -111,9 +125,6 @@ class MachCommands(MachCommandBase):
|
||||||
|
|
||||||
print('SUITE-END | android-test | {} {}'.format(report, root.get('name')))
|
print('SUITE-END | android-test | {} {}'.format(report, root.get('name')))
|
||||||
|
|
||||||
title = report
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/{}/index.html'>HTML {} report</a>, visit \"Inspect Task\" link for details".format(root_url, report, title))
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,10 +143,9 @@ class MachCommands(MachCommandBase):
|
||||||
# report(s) for human consumption.
|
# report(s) for human consumption.
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ:
|
root_url = self._root_url(
|
||||||
root_url = "https://queue.taskcluster.net/v1/task/{}/runs/{}/artifacts/public/android/lint".format(os.environ['TASK_ID'], os.environ['RUN_ID'])
|
artifactdir='public/android/lint',
|
||||||
else:
|
objdir='gradle/build/mobile/android/app/reports')
|
||||||
root_url = os.path.join(self.topobjdir, 'gradle/build/mobile/android/app/reports')
|
|
||||||
|
|
||||||
reports = ('officialPhotonDebug',)
|
reports = ('officialPhotonDebug',)
|
||||||
for report in reports:
|
for report in reports:
|
||||||
|
@ -143,6 +153,16 @@ class MachCommands(MachCommandBase):
|
||||||
tree = ET.parse(f)
|
tree = ET.parse(f)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
|
# Log reports for Tree Herder "Job Details".
|
||||||
|
html_report_url = '{}/lint-results-{}.html'.format(root_url, report)
|
||||||
|
xml_report_url = '{}/lint-results-{}.xml'.format(root_url, report)
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}">HTML {} report</a>, visit "Inspect Task" link for details'.format(html_report_url, report))
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}">XML {} report</a>, visit "Inspect Task" link for details'.format(xml_report_url, report))
|
||||||
|
|
||||||
|
# And make the report display as soon as possible.
|
||||||
|
if root.findall("issue[@severity='Error']"):
|
||||||
|
print('TEST-UNEXPECTED-FAIL | android-lint | Lint found errors in the project; aborting build. See the report at: {}'.format(html_report_url))
|
||||||
|
|
||||||
print('SUITE-START | android-lint | {}'.format(report))
|
print('SUITE-START | android-lint | {}'.format(report))
|
||||||
for issue in root.findall("issue[@severity='Error']"):
|
for issue in root.findall("issue[@severity='Error']"):
|
||||||
# There's no particular advantage to formatting the
|
# There's no particular advantage to formatting the
|
||||||
|
@ -153,10 +173,6 @@ class MachCommands(MachCommandBase):
|
||||||
ret |= 1
|
ret |= 1
|
||||||
print('SUITE-END | android-lint | {}'.format(report))
|
print('SUITE-END | android-lint | {}'.format(report))
|
||||||
|
|
||||||
title = report
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/lint-results-{}.html'>HTML {} report</a>, visit \"Inspect Task\" link for details".format(root_url, report, title))
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/lint-results-{}.xml'>XML {} report</a>, visit \"Inspect Task\" link for details".format(root_url, report, title))
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,6 +195,22 @@ class MachCommands(MachCommandBase):
|
||||||
tree = ET.parse(f)
|
tree = ET.parse(f)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
|
# Now the reports, linkified.
|
||||||
|
root_url = self._root_url(
|
||||||
|
artifactdir='public/android/checkstyle',
|
||||||
|
objdir='gradle/build/mobile/android/app/reports/checkstyle')
|
||||||
|
|
||||||
|
# Log reports for Tree Herder "Job Details".
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}/checkstyle.html">HTML checkstyle report</a>, visit "Inspect Task" link for details'.format(root_url))
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}/checkstyle.xml">XML checkstyle report</a>, visit "Inspect Task" link for details'.format(root_url))
|
||||||
|
|
||||||
|
# And make the report display as soon as possible.
|
||||||
|
if root.findall('file/error'):
|
||||||
|
ret |= 1
|
||||||
|
|
||||||
|
if ret:
|
||||||
|
print('TEST-UNEXPECTED-FAIL | android-checkstyle | Checkstyle rule violations were found. See the report at: {}/checkstyle.html'.format(root_url))
|
||||||
|
|
||||||
print('SUITE-START | android-checkstyle')
|
print('SUITE-START | android-checkstyle')
|
||||||
for file in root.findall('file'):
|
for file in root.findall('file'):
|
||||||
name = file.get('name')
|
name = file.get('name')
|
||||||
|
@ -193,21 +225,11 @@ class MachCommands(MachCommandBase):
|
||||||
for line in ET.tostring(error).strip().splitlines():
|
for line in ET.tostring(error).strip().splitlines():
|
||||||
print('TEST-UNEXPECTED-FAIL | {}'.format(line))
|
print('TEST-UNEXPECTED-FAIL | {}'.format(line))
|
||||||
error_count += 1
|
error_count += 1
|
||||||
ret |= 1
|
|
||||||
|
|
||||||
if not error_count:
|
if not error_count:
|
||||||
print('TEST-PASS | {}'.format(name))
|
print('TEST-PASS | {}'.format(name))
|
||||||
print('SUITE-END | android-checkstyle')
|
print('SUITE-END | android-checkstyle')
|
||||||
|
|
||||||
# Now the reports, linkified.
|
|
||||||
if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ:
|
|
||||||
root_url = "https://queue.taskcluster.net/v1/task/{}/runs/{}/artifacts/public/android/checkstyle".format(os.environ['TASK_ID'], os.environ['RUN_ID'])
|
|
||||||
else:
|
|
||||||
root_url = os.path.join(self.topobjdir, 'gradle/build/mobile/android/app/reports/checkstyle')
|
|
||||||
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/checkstyle.html'>HTML checkstyle report</a>, visit \"Inspect Task\" link for details".format(root_url))
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/checkstyle.xml'>XML checkstyle report</a>, visit \"Inspect Task\" link for details".format(root_url))
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,10 +249,9 @@ class MachCommands(MachCommandBase):
|
||||||
# report(s) for human consumption.
|
# report(s) for human consumption.
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
if 'TASK_ID' in os.environ and 'RUN_ID' in os.environ:
|
root_url = self._root_url(
|
||||||
root_url = "https://queue.taskcluster.net/v1/task/{}/runs/{}/artifacts/public/artifacts/findbugs".format(os.environ['TASK_ID'], os.environ['RUN_ID'])
|
artifactdir='public/android/findbugs',
|
||||||
else:
|
objdir='gradle/build/mobile/android/app/reports/findbugs')
|
||||||
root_url = os.path.join(self.topobjdir, 'gradle/build/mobile/android/app/reports/findbugs')
|
|
||||||
|
|
||||||
reports = ('findbugs-officialPhotonDebug-output.xml',)
|
reports = ('findbugs-officialPhotonDebug-output.xml',)
|
||||||
for report in reports:
|
for report in reports:
|
||||||
|
@ -242,6 +263,17 @@ class MachCommands(MachCommandBase):
|
||||||
tree = ET.parse(f)
|
tree = ET.parse(f)
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
|
|
||||||
|
# Log reports for Tree Herder "Job Details".
|
||||||
|
title = report.replace('findbugs-', '').replace('-output.xml', '')
|
||||||
|
html_report_url = '{}/{}'.format(root_url, report.replace('.xml', '.html'))
|
||||||
|
xml_report_url = '{}/{}'.format(root_url, report)
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}">HTML {} report</a>, visit "Inspect Task" link for details'.format(html_report_url, report))
|
||||||
|
print('TinderboxPrint: report<br/><a href="{}">XML {} report</a>, visit "Inspect Task" link for details'.format(xml_report_url, report))
|
||||||
|
|
||||||
|
# And make the report display as soon as possible.
|
||||||
|
if root.findall("./BugInstance"):
|
||||||
|
print('TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: {}'.format(html_report_url))
|
||||||
|
|
||||||
print('SUITE-START | android-findbugs | {}'.format(report))
|
print('SUITE-START | android-findbugs | {}'.format(report))
|
||||||
for error in root.findall('./BugInstance'):
|
for error in root.findall('./BugInstance'):
|
||||||
# There's no particular advantage to formatting the
|
# There's no particular advantage to formatting the
|
||||||
|
@ -253,10 +285,6 @@ class MachCommands(MachCommandBase):
|
||||||
ret |= 1
|
ret |= 1
|
||||||
print('SUITE-END | android-findbugs | {}'.format(report))
|
print('SUITE-END | android-findbugs | {}'.format(report))
|
||||||
|
|
||||||
title = report.replace('findbugs-', '').replace('-output.xml', '')
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/{}'>HTML {} report</a>, visit \"Inspect Task\" link for details".format(root_url, report.replace('.xml', '.html'), title))
|
|
||||||
print("TinderboxPrint: report<br/><a href='{}/{}'>XML {} report</a>, visit \"Inspect Task\" link for details".format(root_url, report, title))
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +312,7 @@ class MachCommands(MachCommandBase):
|
||||||
# We don't want to gate producing dependency archives on clean
|
# We don't want to gate producing dependency archives on clean
|
||||||
# lint or checkstyle, particularly because toolchain versions
|
# lint or checkstyle, particularly because toolchain versions
|
||||||
# can change the outputs for those processes.
|
# can change the outputs for those processes.
|
||||||
ret = self.gradle(gradle_targets + ["--continue"] + args, verbose=True)
|
self.gradle(gradle_targets + ["--continue"] + args, verbose=True)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче