Skip to content

Commit

Permalink
Backed out changeset 1ddc1733cf76 (bug 1752677) for causing python ma…
Browse files Browse the repository at this point in the history
…ch failures on mac CLOSED TREE
  • Loading branch information
Cristian Tuns committed Feb 2, 2024
1 parent d601656 commit ae6a079
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 278 deletions.
1 change: 0 additions & 1 deletion python/sites/python-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pypi:pytest==7.0.1
pypi:pytest-mock==3.12.0
pypi:Flask==2.1.3
# (indirect) avoids dependency on markupsafe >= 2.1.0, which is currently incompatible with glean-parser
pypi:MarkupSafe==2.0.1
Expand Down
9 changes: 0 additions & 9 deletions tools/tryselect/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,8 @@ def generate_try_task_config(method, labels, params=None, routes=None):
# True). Their dependencies can be optimized though.
params.setdefault("optimize_target_tasks", False)

# Remove selected labels from 'existing_tasks' parameter if present
if "existing_tasks" in params:
params["existing_tasks"] = {
label: tid
for label, tid in params["existing_tasks"].items()
if label not in labels
}

try_config = params.setdefault("try_task_config", {})
try_config.setdefault("env", {})["TRY_SELECTOR"] = method

try_config["tasks"] = sorted(labels)

if routes:
Expand Down
1 change: 0 additions & 1 deletion tools/tryselect/selectors/chooser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ChooserParser(BaseTryParser):
"chemspill-prio",
"disable-pgo",
"env",
"existing-tasks",
"gecko-profile",
"path",
"pernosco",
Expand Down
1 change: 0 additions & 1 deletion tools/tryselect/selectors/fuzzy.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class FuzzyParser(BaseTryParser):
"chemspill-prio",
"disable-pgo",
"env",
"existing-tasks",
"gecko-profile",
"path",
"pernosco",
Expand Down
82 changes: 10 additions & 72 deletions tools/tryselect/task_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@
from textwrap import dedent

import mozpack.path as mozpath
import requests
import six
from mozbuild.base import BuildEnvironmentNotFoundException, MozbuildObject
from mozversioncontrol import Repository
from taskgraph.util import taskcluster

from .tasks import resolve_tests_by_suite
from .util.ssh import get_ssh_user

here = pathlib.Path(__file__).parent
build = MozbuildObject.from_environment(cwd=str(here))
here = os.path.abspath(os.path.dirname(__file__))
build = MozbuildObject.from_environment(cwd=here)


@contextmanager
Expand Down Expand Up @@ -158,7 +155,13 @@ def try_config(self, pernosco, **kwargs):
# log in. Prevent people with non-Mozilla addresses from using this
# flag so they don't end up consuming time and resources only to
# realize they can't actually log in and see the reports.
address = get_ssh_user()
cmd = ["ssh", "-G", "hg.mozilla.org"]
output = subprocess.check_output(
cmd, universal_newlines=True
).splitlines()
address = [
l.rsplit(" ", 1)[-1] for l in output if l.startswith("user")
][0]
if not address.endswith("@mozilla.com"):
print(
dedent(
Expand Down Expand Up @@ -257,70 +260,6 @@ def try_config(self, env, **kwargs):
}


class ExistingTasks(ParameterConfig):
TREEHERDER_PUSH_ENDPOINT = (
"https://treeherder.mozilla.org/api/project/try/push/?count=1&author={user}"
)
TREEHERDER_PUSH_URL = (
"https://treeherder.mozilla.org/jobs?repo={branch}&revision={revision}"
)

arguments = [
[
["-E", "--use-existing-tasks"],
{
"const": "last_try_push",
"default": None,
"nargs": "?",
"help": """
Use existing tasks from a previous push. Without args this
uses your most recent try push. You may also specify
`rev=<revision>` where <revision> is the head revision of the
try push or `task-id=<task id>` where <task id> is the Decision
task id of the push. This last method even works for non-try
branches.
""",
},
]
]

def find_decision_task(self, use_existing_tasks):
branch = "try"
if use_existing_tasks == "last_try_push":
# Use existing tasks from user's previous try push.
user = get_ssh_user()
url = self.TREEHERDER_PUSH_ENDPOINT.format(user=user)
res = requests.get(url, headers={"User-Agent": "gecko-mach-try/1.0"})
res.raise_for_status()
data = res.json()
if data["meta"]["count"] == 0:
raise Exception(f"Could not find a try push for '{user}'!")
revision = data["results"][0]["revision"]

elif use_existing_tasks.startswith("rev="):
revision = use_existing_tasks[len("rev=") :]

else:
raise Exception("Unable to parse '{use_existing_tasks}'!")

url = self.TREEHERDER_PUSH_URL.format(branch=branch, revision=revision)
print(f"Using existing tasks from: {url}")
index_path = f"gecko.v2.{branch}.revision.{revision}.taskgraph.decision"
return taskcluster.find_task_id(index_path)

def get_parameters(self, use_existing_tasks, **kwargs):
if not use_existing_tasks:
return

if use_existing_tasks.startswith("task-id="):
tid = use_existing_tasks[len("task-id=") :]
else:
tid = self.find_decision_task(use_existing_tasks)

label_to_task_id = taskcluster.get_artifact(tid, "public/label-to-taskid.json")
return {"existing_tasks": label_to_task_id}


class RangeAction(Action):
def __init__(self, min, max, *args, **kwargs):
self.min = min
Expand Down Expand Up @@ -479,7 +418,7 @@ def try_config(
gecko_profile_entries,
gecko_profile_features,
gecko_profile_threads,
**kwargs,
**kwargs
):
if profile or not all(
s is None for s in (gecko_profile_features, gecko_profile_threads)
Expand Down Expand Up @@ -609,7 +548,6 @@ def try_config(self, worker_overrides, worker_suffixes, **kwargs):
"chemspill-prio": ChemspillPrio,
"disable-pgo": DisablePgo,
"env": Environment,
"existing-tasks": ExistingTasks,
"gecko-profile": GeckoProfile,
"path": Path,
"pernosco": Pernosco,
Expand Down
7 changes: 0 additions & 7 deletions tools/tryselect/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
import pytest
import yaml
from moztest.resolve import TestResolver
from responses import RequestsMock
from taskgraph.graph import Graph
from taskgraph.task import Task
from taskgraph.taskgraph import TaskGraph
from tryselect import push


@pytest.fixture
def responses():
with RequestsMock() as rsps:
yield rsps


@pytest.fixture
def tg(request):
if not hasattr(request.module, "TASKS"):
Expand Down
2 changes: 0 additions & 2 deletions tools/tryselect/test/python.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ subsuite = "try"
# shouldn't be run in parallel with those other tests.
sequential = true

["test_push.py"]

["test_release.py"]

["test_scriptworker.py"]
Expand Down
54 changes: 0 additions & 54 deletions tools/tryselect/test/test_push.py

This file was deleted.

Loading

0 comments on commit ae6a079

Please sign in to comment.