def refresh_deploy_jobs(jobs): jobs = [ (FQSHA.from_json(json.loads(job.attributes['target'])), job) for job in jobs if 'target' in job.attributes ] jobs = [ (target, job) for (target, job) in jobs if target.ref in prs.deploy_jobs ] latest_jobs = {} for (target, job) in jobs: job2 = latest_jobs.get(target, None) if job2 is None: latest_jobs[target] = job else: if job_ordering(job, job2) > 0: log.info( f'cancelling {job2.id}, preferring {job.id}' ) try_to_cancel_job(job2) latest_jobs[target] = job else: log.info( f'cancelling {job.id}, preferring {job2.id}' ) try_to_cancel_job(job) prs.refresh_from_deploy_jobs(latest_jobs)
def refresh_ci_build_jobs(jobs): jobs = [ (FQSHA.from_json(json.loads(job.attributes['source'])), FQSHA.from_json(json.loads(job.attributes['target'])), job) for job in jobs ] jobs = [(s, t, j) for (s, t, j) in jobs if prs.exists(s, t)] latest_jobs = {} for (source, target, job) in jobs: key = (source, target) job2 = latest_jobs.get(key, None) if job2 is None: latest_jobs[key] = job else: if job_ordering(job, job2) > 0: log.info( f'cancelling {job2.id}, preferring {job.id}' ) try_to_cancel_job(job2) latest_jobs[key] = job else: log.info( f'cancelling {job.id}, preferring {job2.id}' ) try_to_cancel_job(job) prs.refresh_from_ci_jobs(latest_jobs)
def refresh_deploy_jobs(jobs): jobs = [(FQSHA.from_json(json.loads(job.attributes['target'])), job) for job in jobs if 'target' in job.attributes] jobs = [(target, job) for (target, job) in jobs if target.ref in prs.deploy_jobs] latest_jobs = {} for (target, job) in jobs: job2 = latest_jobs.get(target, None) if job2 is None: latest_jobs[target] = job else: if job_ordering(job, job2) > 0: log.info(f'cancelling {job2.id}, preferring {job.id}') try_to_cancel_job(job2) latest_jobs[target] = job else: log.info(f'cancelling {job.id}, preferring {job2.id}') try_to_cancel_job(job) prs.refresh_from_deploy_jobs(latest_jobs)
def refresh_ci_build_jobs(jobs): jobs = [(FQSHA.from_json(json.loads(job.attributes['source'])), FQSHA.from_json(json.loads(job.attributes['target'])), job) for job in jobs] jobs = [(s, t, j) for (s, t, j) in jobs if prs.exists(s, t)] latest_jobs = {} for (source, target, job) in jobs: key = (source, target) job2 = latest_jobs.get(key, None) if job2 is None: latest_jobs[key] = job else: if job_ordering(job, job2) > 0: log.info(f'cancelling {job2.id}, preferring {job.id}') try_to_cancel_job(job2) latest_jobs[key] = job else: log.info(f'cancelling {job.id}, preferring {job2.id}') try_to_cancel_job(job) prs.refresh_from_ci_jobs(latest_jobs)