Cap the auto-scheduled builds to 10

This commit is contained in:
Graham Christensen 2018-02-03 09:26:20 -05:00
parent b2655cac5b
commit a0575eeac5
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -91,7 +91,7 @@ impl<E: stats::SysEvents> worker::SimpleWorker for MassRebuildWorker<E> {
let gists = self.github.gists(); let gists = self.github.gists();
let issue = repo.issue(job.pr.number); let issue = repo.issue(job.pr.number);
let auto_schedule_build_archs: Option<Vec<buildjob::ExchangeQueue>>; let auto_schedule_build_archs: Vec<buildjob::ExchangeQueue>;
match issue.get() { match issue.get() {
Ok(iss) => { Ok(iss) => {
@ -101,10 +101,10 @@ impl<E: stats::SysEvents> worker::SimpleWorker for MassRebuildWorker<E> {
return self.actions().skip(&job); return self.actions().skip(&job);
} }
auto_schedule_build_archs = Some(self.acl.build_job_destinations_for_user_repo( auto_schedule_build_archs = self.acl.build_job_destinations_for_user_repo(
&iss.user.login, &iss.user.login,
&job.repo.full_name, &job.repo.full_name,
)); );
} }
Err(e) => { Err(e) => {
self.events.tick("issue-fetch-failed"); self.events.tick("issue-fetch-failed");
@ -390,16 +390,22 @@ impl<E: stats::SysEvents> worker::SimpleWorker for MassRebuildWorker<E> {
try_build.sort(); try_build.sort();
try_build.dedup(); try_build.dedup();
let msg = buildjob::BuildJob::new( if try_build.len() <= 10 {
job.repo.clone(), // In the case of trying to merge master in to
job.pr.clone(), // a stable branch, we don't want to do this.
Subset::Nixpkgs, // Therefore, only schedule builds if there
try_build, // less than or exactly 10
None, let msg = buildjob::BuildJob::new(
None, job.repo.clone(),
); job.pr.clone(),
for (dest, rk) in auto_schedule_build_archs.unwrap_or(vec![]) { Subset::Nixpkgs,
response.push(worker::publish_serde_action(dest, rk, &msg)); try_build,
None,
None,
);
for (dest, rk) in auto_schedule_build_archs {
response.push(worker::publish_serde_action(dest, rk, &msg));
}
} }
} }
Err(mut out) => { Err(mut out) => {