Skip to content

Commit

Permalink
Run the go_e2e_deps step in the flakes finder pipeline (#27963)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentClarret authored Jul 26, 2024
1 parent 9cf0b99 commit 190d7b8
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tasks/testwasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_tests_family(self, test_name_list):
return test_family


@task()
@task
def generate_flake_finder_pipeline(ctx, n=3):
"""
Generate a child pipeline where jobs marked with SHOULD_RUN_IN_FLAKES_FINDER are run n times
Expand All @@ -194,22 +194,18 @@ def generate_flake_finder_pipeline(ctx, n=3):
continue
kept_job[job] = job_details

deps_job = copy.deepcopy(config["go_e2e_deps"])

# Remove needs, rules, extends and retry from the jobs
for job in kept_job:
if 'needs' in kept_job[job]:
del kept_job[job]["needs"]
if 'rules' in kept_job[job]:
del kept_job[job]["rules"]
if 'retry' in kept_job[job]:
del kept_job[job]["retry"]
if 'extends' in kept_job[job]:
del kept_job[job]["extends"]
for job in [deps_job] + list(kept_job.values()):
_clean_job(job)

new_jobs = {}
new_jobs["go_e2e_deps"] = deps_job
new_jobs['variables'] = copy.deepcopy(config['variables'])
new_jobs['variables']['PARENT_PIPELINE_ID'] = 'undefined'
new_jobs['variables']['PARENT_COMMIT_SHA'] = 'undefined'
new_jobs['stages'] = [f'flake-finder-{i}' for i in range(n)]
new_jobs['stages'] = [deps_job["stage"]] + [f'flake-finder-{i}' for i in range(n)]

# Create n jobs with the same configuration
for job in kept_job:
Expand All @@ -229,10 +225,21 @@ def generate_flake_finder_pipeline(ctx, n=3):
):
new_job['variables']['E2E_COMMIT_SHA'] = "$PARENT_COMMIT_SHA"
new_job["rules"] = [{"when": "always"}]
new_job["needs"] = ["go_e2e_deps"]
new_jobs[f"{job}-{i}"] = new_job

with open("flake-finder-gitlab-ci.yml", "w") as f:
f.write(yaml.safe_dump(new_jobs))

with gitlab_section("Flake finder generated pipeline", collapsed=True):
print(yaml.safe_dump(new_jobs))


def _clean_job(job):
"""
Remove the needs, rules, extends and retry from the job
"""
for step in ('needs', 'rules', 'extends', 'retry'):
if step in job:
del job[step]
return job

0 comments on commit 190d7b8

Please sign in to comment.