def test_publication(tmpdir, mock_issues, mock_revision): """ Test debug publication and report analysis """ from code_review_bot.report.debug import DebugReporter report_dir = str(tmpdir.mkdir("public").realpath()) report_path = os.path.join(report_dir, "report.json") assert not os.path.exists(report_path) r = DebugReporter(report_dir) r.publish(mock_issues, mock_revision) assert os.path.exists(report_path) with open(report_path) as f: report = json.load(f) assert "issues" in report assert report["issues"] == [{"nb": 0}, {"nb": 1}, {"nb": 2}, {"nb": 3}, {"nb": 4}] assert "revision" in report assert report["revision"] == { "id": 51, "diff_id": 42, "url": "https://phabricator.test/D51", "bugzilla_id": "", "diff_phid": "PHID-DIFF-test", "phid": "PHID-DREV-zzzzz", "title": "Static Analysis tests", "has_clang_files": False, } assert "time" in report assert isinstance(report["time"], float)
def test_publication(tmpdir, mock_issues, mock_revision): """ Test debug publication and report analysis """ from code_review_bot.report.debug import DebugReporter # Load description from Taskcluster tasks mock_revision.setup_try( { # Base information are retrieved from the decision task "decision": { "task": { "payload": { "image": "taskcluster/decision", "env": { "GECKO_HEAD_REV": "deadc0ffee", "GECKO_HEAD_REPOSITORY": "https://hg.mozilla.org/try", "GECKO_BASE_REPOSITORY": "https://hg.mozilla.org/mozilla-central", }, } } } } ) report_dir = str(tmpdir.mkdir("public").realpath()) report_path = os.path.join(report_dir, "report.json") assert not os.path.exists(report_path) r = DebugReporter(report_dir) r.publish(mock_issues, mock_revision) assert os.path.exists(report_path) with open(report_path) as f: report = json.load(f) assert "issues" in report assert report["issues"] == [{"nb": 0}, {"nb": 1}, {"nb": 2}, {"nb": 3}, {"nb": 4}] assert "revision" in report assert report["revision"] == { "id": 51, "diff_id": 42, "url": "https://phabricator.test/D51", "bugzilla_id": 1234567, "diff_phid": "PHID-DIFF-test", "phid": "PHID-DREV-zzzzz", "title": "Static Analysis tests", "has_clang_files": False, "repository": "try", "target_repository": "mozilla-central", "mercurial_revision": "deadc0ffee", } assert "time" in report assert isinstance(report["time"], float)
def __init__( self, reporters, index_service, queue_service, phabricator_api, zero_coverage_enabled=True, ): assert settings.try_task_id is not None, "Cannot run without Try task id" assert settings.try_group_id is not None, "Cannot run without Try task id" self.zero_coverage_enabled = zero_coverage_enabled # Use share phabricator API client assert isinstance(phabricator_api, PhabricatorAPI) self.phabricator = phabricator_api # Load reporters to use self.reporters = reporters if not self.reporters: logger.warn("No reporters configured, this analysis will not be published") # Always add debug reporter and Diff reporter self.reporters["debug"] = DebugReporter( output_dir=settings.taskcluster.results_dir ) # Use TC services client self.index_service = index_service self.queue_service = queue_service # Setup Backend API client self.backend_api = BackendAPI()
def __init__( self, reporters, index_service, queue_service, phabricator_api, zero_coverage_enabled=True, update_build=True, task_failures_ignored=[], ): self.zero_coverage_enabled = zero_coverage_enabled self.update_build = update_build self.task_failures_ignored = task_failures_ignored logger.info("Will ignore task failures", names=self.task_failures_ignored) # Use share phabricator API client assert isinstance(phabricator_api, PhabricatorAPI) self.phabricator = phabricator_api # Load reporters to use self.reporters = reporters if not self.reporters: logger.warn("No reporters configured, this analysis will not be published") # Always add debug reporter and Diff reporter self.reporters["debug"] = DebugReporter( output_dir=settings.taskcluster.results_dir ) # Use TC services client self.index_service = index_service self.queue_service = queue_service # Setup Backend API client self.backend_api = BackendAPI()