From 42883eb3120ef8eccba15c97cf6fb3cdd7946f60 Mon Sep 17 00:00:00 2001 From: Szymon Datko Date: Wed, 24 Jan 2024 16:35:44 +0100 Subject: [PATCH] Use relative paths in generator The existing code relied on absolute paths to files, which would result in generated cache to be specific for a given environment where the Znoyder is called. Using relative paths would make the calls universal and properly cacheable. --- znoyder/generator.py | 6 ++---- znoyder/tests/test_generator.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/znoyder/generator.py b/znoyder/generator.py index 2ce9bf9..d8b6a54 100644 --- a/znoyder/generator.py +++ b/znoyder/generator.py @@ -114,8 +114,7 @@ def discover_jobs(project_name, osp_tag, directory, jobs = [] if directory: - path = os.path.abspath(os.path.join(UPSTREAM_CONFIGS_DIR, - directory)) + path = os.path.join(UPSTREAM_CONFIGS_DIR, directory) if os.path.exists(path): LOG.info(f'Including from: {directory}') upstream_jobs = discover_upstream_jobs(path, templates, pipelines) @@ -171,8 +170,7 @@ def generate_projects_pipelines_dict(args): f'{ospinfo_filters}.') continue - path = os.path.abspath(os.path.join(UPSTREAM_CONFIGS_DIR, - templates_directory)) + path = os.path.join(UPSTREAM_CONFIGS_DIR, templates_directory) pipelines = finder.find_pipelines('check,gate') templates = finder.find_templates(path, pipelines) diff --git a/znoyder/tests/test_generator.py b/znoyder/tests/test_generator.py index 3c7e195..a954c3e 100644 --- a/znoyder/tests/test_generator.py +++ b/znoyder/tests/test_generator.py @@ -210,8 +210,7 @@ def test_discover_jobs(self, mock_exists, mock_finder, self.assertEqual(len(mock_log.records), 2) self.assertEqual(mock_log.output, expected_log) - expected_dir = os.path.abspath(os.path.join(UPSTREAM_CONFIGS_DIR, - directory)) + expected_dir = os.path.join(UPSTREAM_CONFIGS_DIR, directory) mock_exists.assert_called_once_with(expected_dir) mock_finder.assert_called_once_with(expected_dir, templates, pipelines)