зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1746414 - Use 'GraphConfig' from standalone taskgraph, r=releng-reviewers,aki
Depends on D136515 Differential Revision: https://phabricator.services.mozilla.com/D136516
This commit is contained in:
Родитель
8a26e659ba
Коммит
681b4e3edb
|
@ -5,14 +5,11 @@
|
|||
|
||||
import os
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import attr
|
||||
from mozpack import path
|
||||
from taskgraph.config import GraphConfig
|
||||
from taskgraph.util.yaml import load_yaml
|
||||
from voluptuous import Required, Optional, Any
|
||||
|
||||
from .util.python_path import find_object
|
||||
from .util.schema import validate_schema, Schema, optionally_keyed_by
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -138,48 +135,6 @@ graph_config_schema = Schema(
|
|||
)
|
||||
|
||||
|
||||
@attr.s(frozen=True, cmp=False)
|
||||
class GraphConfig:
|
||||
_config = attr.ib()
|
||||
root_dir = attr.ib()
|
||||
|
||||
_PATH_MODIFIED = False
|
||||
|
||||
def __getitem__(self, name):
|
||||
return self._config[name]
|
||||
|
||||
def register(self):
|
||||
"""
|
||||
Add the project's taskgraph directory to the python path, and register
|
||||
any extensions present.
|
||||
"""
|
||||
modify_path = os.path.dirname(self.root_dir)
|
||||
if GraphConfig._PATH_MODIFIED:
|
||||
if GraphConfig._PATH_MODIFIED == modify_path:
|
||||
# Already modified path with the same root_dir.
|
||||
# We currently need to do this to enable actions to call
|
||||
# taskgraph_decision, e.g. relpro.
|
||||
return
|
||||
raise Exception("Can't register multiple directories on python path.")
|
||||
GraphConfig._PATH_MODIFIED = modify_path
|
||||
sys.path.insert(0, modify_path)
|
||||
register_path = self["taskgraph"].get("register")
|
||||
if register_path:
|
||||
find_object(register_path)(self)
|
||||
|
||||
@property
|
||||
def taskcluster_yml(self):
|
||||
if path.split(self.root_dir)[-2:] != ["taskcluster", "ci"]:
|
||||
raise Exception(
|
||||
"Not guessing path to `.taskcluster.yml`. "
|
||||
"Graph config in non-standard location."
|
||||
)
|
||||
return os.path.join(
|
||||
os.path.dirname(os.path.dirname(self.root_dir)),
|
||||
".taskcluster.yml",
|
||||
)
|
||||
|
||||
|
||||
def validate_graph_config(config):
|
||||
validate_schema(graph_config_schema, config, "Invalid graph configuration:")
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import os
|
|||
import copy
|
||||
|
||||
import attr
|
||||
from taskgraph.config import GraphConfig
|
||||
from taskgraph.util.yaml import load_yaml
|
||||
|
||||
from . import filter_tasks
|
||||
|
@ -22,7 +23,7 @@ from .util.verify import (
|
|||
verify_docs,
|
||||
verifications,
|
||||
)
|
||||
from .config import load_graph_config, GraphConfig
|
||||
from .config import load_graph_config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import os
|
|||
import pytest
|
||||
from mach.logging import LoggingManager
|
||||
from responses import RequestsMock
|
||||
from taskgraph.config import GraphConfig
|
||||
|
||||
from gecko_taskgraph import (
|
||||
GECKO,
|
||||
|
@ -14,7 +15,7 @@ from gecko_taskgraph import (
|
|||
target_tasks as target_tasks_mod,
|
||||
)
|
||||
from gecko_taskgraph.actions import render_actions_json
|
||||
from gecko_taskgraph.config import load_graph_config, GraphConfig
|
||||
from gecko_taskgraph.config import load_graph_config
|
||||
from gecko_taskgraph.generator import TaskGraphGenerator, Kind
|
||||
from gecko_taskgraph.optimize import OptimizationStrategy
|
||||
from gecko_taskgraph.parameters import Parameters
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
import unittest
|
||||
|
||||
from taskgraph.config import GraphConfig
|
||||
from unittest import mock
|
||||
|
||||
from gecko_taskgraph import create
|
||||
from gecko_taskgraph.config import GraphConfig
|
||||
from gecko_taskgraph.graph import Graph
|
||||
from gecko_taskgraph.taskgraph import TaskGraph
|
||||
from gecko_taskgraph.task import Task
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
import attr
|
||||
from taskgraph.config import GraphConfig
|
||||
|
||||
from ..config import GraphConfig
|
||||
from ..parameters import Parameters
|
||||
from ..util.schema import Schema, validate_schema
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче