evaluator: move out title-based tagging

This commit is contained in:
Graham Christensen 2019-03-22 13:49:04 -04:00
parent 795ace48df
commit 297dd02f62
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 25 additions and 17 deletions

View file

@ -3,8 +3,9 @@ use ofborg::checkout::CachedProjectCo;
use ofborg::commitstatus::CommitStatus; use ofborg::commitstatus::CommitStatus;
use ofborg::evalchecker::EvalChecker; use ofborg::evalchecker::EvalChecker;
use ofborg::message::buildjob::BuildJob; use ofborg::message::buildjob::BuildJob;
use ofborg::tasks::eval::{EvaluationStrategy, StepResult};
use ofborg::tasks::evaluate::update_labels;
use std::path::Path; use std::path::Path;
use tasks::eval::{EvaluationStrategy, StepResult};
pub struct NixpkgsStrategy<'a> { pub struct NixpkgsStrategy<'a> {
issue_ref: &'a IssueRef<'a>, issue_ref: &'a IssueRef<'a>,
@ -13,10 +14,26 @@ impl<'a> NixpkgsStrategy<'a> {
pub fn new(issue_ref: &'a IssueRef) -> NixpkgsStrategy<'a> { pub fn new(issue_ref: &'a IssueRef) -> NixpkgsStrategy<'a> {
Self { issue_ref } Self { issue_ref }
} }
fn tag_from_title(&self) {
let darwin = self
.issue_ref
.get()
.map(|iss| {
iss.title.to_lowercase().contains("darwin")
|| iss.title.to_lowercase().contains("macos")
})
.unwrap_or(false);
if darwin {
update_labels(&self.issue_ref, &[String::from("6.topic: darwin")], &[]);
}
}
} }
impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> { impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
fn pre_clone(&mut self) -> StepResult<()> { fn pre_clone(&mut self) -> StepResult<()> {
self.tag_from_title();
Ok(()) Ok(())
} }

View file

@ -68,20 +68,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
evaluationjob::Actions {} evaluationjob::Actions {}
} }
fn tag_from_title(&self, issue: &hubcaps::issues::IssueRef) {
let darwin = issue
.get()
.map(|iss| {
iss.title.to_lowercase().contains("darwin")
|| iss.title.to_lowercase().contains("macos")
})
.unwrap_or(false);
if darwin {
update_labels(&issue, &[String::from("6.topic: darwin")], &[]);
}
}
fn tag_from_paths(&self, issue: &hubcaps::issues::IssueRef, paths: &[String]) { fn tag_from_paths(&self, issue: &hubcaps::issues::IssueRef, paths: &[String]) {
let mut tagger = PathsTagger::new(self.tag_paths.clone()); let mut tagger = PathsTagger::new(self.tag_paths.clone());
@ -185,8 +171,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
} }
}; };
self.tag_from_title(&issue_ref);
let mut overall_status = CommitStatus::new( let mut overall_status = CommitStatus::new(
repo.statuses(), repo.statuses(),
job.pr.head_sha.clone(), job.pr.head_sha.clone(),
@ -197,6 +181,13 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
overall_status.set_with_description("Starting", hubcaps::statuses::State::Pending); overall_status.set_with_description("Starting", hubcaps::statuses::State::Pending);
if self
.handle_strategy_err(evaluation_strategy.pre_clone(), &gists, &mut overall_status)
.is_err()
{
return self.actions().skip(&job);
}
let project = self let project = self
.cloner .cloner
.project(&job.repo.full_name, job.repo.clone_url.clone()); .project(&job.repo.full_name, job.repo.clone_url.clone());