Skip to content

Commit

Permalink
Use relative paths in generator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdatko committed Jan 25, 2024
1 parent 71b14ad commit 42883eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions znoyder/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions znoyder/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 42883eb

Please sign in to comment.