From f60a6452bae2c3cfc30dd8f6d35deeff75a8f58e Mon Sep 17 00:00:00 2001 From: Ben Hearsum Date: Mon, 7 Apr 2025 13:53:00 -0400 Subject: [PATCH 1/2] fix: ensure GraphConfig.root_dir is an absolute path --- src/taskgraph/config.py | 5 +++++ test/test_config.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/taskgraph/config.py b/src/taskgraph/config.py index b914b98f0..1f4eca909 100644 --- a/src/taskgraph/config.py +++ b/src/taskgraph/config.py @@ -112,6 +112,11 @@ class GraphConfig: _PATH_MODIFIED = False + def __post_init__(self): + # ensure we have an absolute path; this is required for assumptions + # made later, such as the `vcs_root` being a directory above `root_dir` + object.__setattr__(self, "root_dir", os.path.abspath(self.root_dir)) + def __getitem__(self, name): return self._config[name] diff --git a/test/test_config.py b/test/test_config.py index 596036f34..f0d9e6a1e 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import os.path import pytest from taskgraph.config import GraphConfig @@ -10,6 +11,8 @@ def test_graph_config_basic(): graph_config = GraphConfig({"foo": "bar"}, "root") + assert os.path.isabs(graph_config.root_dir) + assert "foo" in graph_config assert graph_config["foo"] == "bar" assert graph_config.get("foo") == "bar" From 4c7630c04415defca36cea763bcdae83e0772e9a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 13:52:40 +0000 Subject: [PATCH 2/2] style: pre-commit.ci auto fixes [...] --- test/test_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_config.py b/test/test_config.py index f0d9e6a1e..84e459f85 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -3,6 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os.path + import pytest from taskgraph.config import GraphConfig