Skip to content

Commit

Permalink
Switch away from logging infra
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcgruer committed Aug 3, 2020
1 parent be2a7a2 commit 6be633b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
21 changes: 21 additions & 0 deletions tools/ci/tc/github_checks_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class GitHubChecksOutputter(object):
def __init__(self, path):
self.path = path

def output(self, line):
with open(self.path, 'a') as f:
f.write(line)
f.write('\n')


__outputter = None
def get_gh_checks_outputter(kwargs):
"""Return an outputter for GitHub Checks output, if enabled.
:param kwargs: The arguments passed to the program (to look for the
--github_checks_text_file flag)
"""
global __outputter
if kwargs['github_checks_text_file'] and __outputter is None:
__outputter = GitHubChecksOutputter(kwargs['github_checks_text_file'])
return __outputter
21 changes: 10 additions & 11 deletions tools/wptrunner/wptrunner/stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
from datetime import datetime
from six import iteritems

from . import wptlogging

from mozlog import reader
from mozlog.formatters import JSONFormatter
from mozlog.handlers import BaseHandler, StreamHandler, LogLevelFilter

here = os.path.dirname(__file__)
localpaths = imp.load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, os.pardir, "localpaths.py")))
from ci.tc.github_checks_output import get_gh_checks_outputter
from wpt.markdown import markdown_adjust, table


Expand Down Expand Up @@ -180,8 +179,8 @@ def err_string(results_dict, iterations):
return rv


def write_taskcluster_summary_inconsistent(log, inconsistent, iterations):
"""Outputs a summary of inconsistent tests for Taskcluster."""
def write_github_checks_summary_inconsistent(log, inconsistent, iterations):
"""Outputs a summary of inconsistent tests for GitHub Checks."""
log("Some affected tests had inconsistent (flaky) results:\n")
write_inconsistent(log, inconsistent, iterations)
log("\n")
Expand All @@ -191,8 +190,8 @@ def write_taskcluster_summary_inconsistent(log, inconsistent, iterations):
"@web-platform-tests/wpt-core-team in a comment for help.\n")


def write_taskcluster_summary_slow_tests(log, slow):
"""Outputs a summary of slow tests for Taskcluster."""
def write_github_checks_summary_slow_tests(log, slow):
"""Outputs a summary of slow tests for GitHub Checks."""
log("Some affected tests had slow results:\n")
write_slow_tests(log, slow)
log("\n")
Expand Down Expand Up @@ -347,7 +346,7 @@ def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, m
start_time = datetime.now()
step_results = []

taskcluster_logger = wptlogging.get_taskcluster_logger(kwargs)
github_checks_outputter = get_gh_checks_outputter(kwargs)

for desc, step_func in steps:
if max_time and datetime.now() - start_time > max_time:
Expand All @@ -365,16 +364,16 @@ def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, m

if inconsistent:
step_results.append((desc, "FAIL"))
if taskcluster_logger:
write_taskcluster_summary_inconsistent(taskcluster_logger.info, inconsistent, iterations)
if github_checks_outputter:
write_github_checks_summary_inconsistent(github_checks_outputter.output, inconsistent, iterations)
write_inconsistent(logger.info, inconsistent, iterations)
write_summary(logger, step_results, "FAIL")
return 1

if slow:
step_results.append((desc, "FAIL"))
if taskcluster_logger:
write_taskcluster_summary_slow_tests(taskcluster_logger.info, slow)
if github_checks_outputter:
write_github_checks_summary_slow_tests(github_checks_outputter.output, slow)
write_slow_tests(logger.info, slow)
write_summary(logger, step_results, "FAIL")
return 1
Expand Down
15 changes: 0 additions & 15 deletions tools/wptrunner/wptrunner/wptlogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,3 @@ def __call__(self, data):
not self.has_log and
log_levels[data["level"]] <= self.min_level):
self.has_log = True


__tc_logger = None
def get_taskcluster_logger(kwargs):
"""Return a logger for Taskcluster GitHub Checks output, if enabled.
:param kwargs: The arguments passed to the program (to look for the
--github_checks_text_file flag)
"""
global __tc_logger
if kwargs['github_checks_text_file'] and __tc_logger is None:
__tc_logger = logging.getLogger("taskcluster-logger")
__tc_logger.addHandler(logging.FileHandler(
kwargs['github_checks_text_file']))
return __tc_logger

0 comments on commit 6be633b

Please sign in to comment.