From 190d7b864c62de9c058bb99b067a396df401f36c Mon Sep 17 00:00:00 2001 From: Florent Clarret Date: Fri, 26 Jul 2024 13:10:40 +0000 Subject: [PATCH] Run the `go_e2e_deps` step in the flakes finder pipeline (#27963) --- tasks/testwasher.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tasks/testwasher.py b/tasks/testwasher.py index 60e45077fdfe9..1523e1aa9c72e 100644 --- a/tasks/testwasher.py +++ b/tasks/testwasher.py @@ -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 @@ -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: @@ -229,6 +225,7 @@ 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: @@ -236,3 +233,13 @@ def generate_flake_finder_pipeline(ctx, n=3): 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