Verified Commit d11dcdeb authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Tweaks to the build system

This reverts commit 4e4d1a17.

This reverts commit d0aa9093.
parent 07370c67
Loading
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import sys
from pathlib import Path
from threading import Thread

# import sentry_sdk
import sentry_sdk
from mozversioncontrol import (
    InvalidRepoPath,
    MissingUpstreamRepo,
@@ -35,8 +35,7 @@ class SentryErrorReporter(ErrorReporter):
    """Reports errors using Sentry."""

    def report_exception(self, exception):
        pass
        # return sentry_sdk.capture_exception(exception)
        return sentry_sdk.capture_exception(exception)


class NoopErrorReporter(ErrorReporter):
@@ -62,10 +61,10 @@ def register_sentry(argv, settings, topsrcdir: Path):
    )
    _is_unmodified_mach_core_thread.start()

    # sentry_sdk.init(
    #     _SENTRY_DSN, before_send=lambda event, _: _process_event(event, topsrcdir)
    # )
    # sentry_sdk.add_breadcrumb(message="./mach {}".format(" ".join(argv)))
    sentry_sdk.init(
        _SENTRY_DSN, before_send=lambda event, _: _process_event(event, topsrcdir)
    )
    sentry_sdk.add_breadcrumb(message="./mach {}".format(" ".join(argv)))
    return SentryErrorReporter()


+40 −2
Original line number Diff line number Diff line
@@ -7,9 +7,11 @@ import importlib.util
import os
import subprocess
import sys
import urllib.parse as urllib_parse
from pathlib import Path
from textwrap import dedent

import requests
from mozbuild.base import BuildEnvironmentNotFoundException, MozbuildObject
from mozbuild.telemetry import filter_args
from mozfile import json
@@ -90,8 +92,11 @@ def is_applicable_telemetry_environment():


def is_telemetry_enabled(settings):
    if os.environ.get("DISABLE_TELEMETRY") == "1":
        return False

    return settings.mach_telemetry.is_enabled


def arcrc_path():
    if sys.platform.startswith("win32") or sys.platform.startswith("msys"):
@@ -127,6 +132,39 @@ def resolve_setting_from_arcconfig(topsrcdir: Path, setting):


def resolve_is_employee_by_credentials(topsrcdir: Path):
    try:
        phabricator_uri = resolve_setting_from_arcconfig(topsrcdir, "phabricator.uri")

        if not phabricator_uri:
            return None

        with arcrc_path().open() as arcrc_file:
            arcrc = json.load(arcrc_file)

        phabricator_token = (
            arcrc.get("hosts", {})
            .get(urllib_parse.urljoin(phabricator_uri, "api/"), {})
            .get("token")
        )

        if not phabricator_token:
            return None

        bmo_uri = (
            resolve_setting_from_arcconfig(topsrcdir, "bmo_url")
            or "https://bugzilla.mozilla.org"
        )
        bmo_api_url = urllib_parse.urljoin(bmo_uri, "rest/whoami")
        bmo_result = requests.get(
            bmo_api_url, headers={"X-PHABRICATOR-TOKEN": phabricator_token}
        )

        return "mozilla-employee-confidential" in bmo_result.json().get("groups", [])
    except (
        FileNotFoundError,
        json.JSONDecodeError,
        requests.exceptions.RequestException,
    ):
        return None