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 transition(self, other): if isinstance(other, Merged): raise ValueError(f'bad transition {self} to {other}') if (not isinstance(other, Failure) and not isinstance(other, Mergeable) and not isinstance(other, NoMergeSHA)): log.info(f'cancelling unneeded job {self.job.id} {self} {other}') try_to_cancel_job(self.job) return other
def transition(self, other): if isinstance(other, Merged): raise ValueError(f'bad transition {self} to {other}') if (not isinstance(other, Failure) and not isinstance(other, Mergeable) and not isinstance(other, NoMergeSHA)): log.info(f'cancelling unneeded job {self.job.id} {self} {other}') try_to_cancel_job(self.job) return other
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)