Skip to content

Commit

Permalink
Small fix to variables merging and e2e pre tests in flake finder (#27106
Browse files Browse the repository at this point in the history
)
  • Loading branch information
KevinFairise2 committed Jul 1, 2024
1 parent fd19df3 commit 9210466
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion tasks/libs/ciproviders/gitlab_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,20 @@ def apply_yaml_extends(config: dict, node):
if key not in node:
node[key] = value
elif key in node and isinstance(node[key], dict) and isinstance(value, dict):
node[key].update(value)
update_without_overwrite(node[key], value)

del node['extends']


def update_without_overwrite(d, u):
"""
Update a dictionary without overwriting existing keys
"""
for k, v in u.items():
if k not in d:
d[k] = v


def apply_yaml_reference(config: dict, node):
"""
Applies `!reference` gitlab yaml tags to the node and its children inplace
Expand Down
10 changes: 8 additions & 2 deletions tasks/testwasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,15 @@ def generate_flake_finder_pipeline(_, n=3):
new_job["stage"] = f"flake-finder-{i}"
new_job["dependencies"] = []
if 'variables' in new_job:
if 'E2E_PIPELINE_ID' in new_job['variables']:
if (
'E2E_PIPELINE_ID' in new_job['variables']
and new_job['variables']['E2E_PIPELINE_ID'] == "$CI_PIPELINE_ID"
):
new_job['variables']['E2E_PIPELINE_ID'] = "$PARENT_PIPELINE_ID"
if 'E2E_COMMIT_SHA' in new_job['variables']:
if (
'E2E_COMMIT_SHA' in new_job['variables']
and new_job['variables']['E2E_COMMIT_SHA'] == "$CI_COMMIT_SHA"
):
new_job['variables']['E2E_COMMIT_SHA'] = "$PARENT_COMMIT_SHA"
new_job["rules"] = [{"when": "always"}]
new_jobs[f"{job}-{i}"] = new_job
Expand Down

0 comments on commit 9210466

Please sign in to comment.