Pull out stdenv tagging
This commit is contained in:
parent
2141f7352b
commit
f0b342e4d6
2 changed files with 48 additions and 30 deletions
|
@ -4,17 +4,23 @@ use ofborg::commitstatus::CommitStatus;
|
|||
use ofborg::evalchecker::EvalChecker;
|
||||
use ofborg::message::buildjob::BuildJob;
|
||||
use ofborg::nix::Nix;
|
||||
use ofborg::tasks::eval::{EvaluationStrategy, StepResult};
|
||||
use ofborg::tagger::StdenvTagger;
|
||||
use ofborg::tasks::eval::{stdenvs::Stdenvs, EvaluationStrategy, StepResult};
|
||||
use ofborg::tasks::evaluate::update_labels;
|
||||
use std::path::Path;
|
||||
|
||||
pub struct NixpkgsStrategy<'a> {
|
||||
issue_ref: &'a IssueRef<'a>,
|
||||
nix: Nix,
|
||||
stdenv_diff: Option<Stdenvs>,
|
||||
}
|
||||
impl<'a> NixpkgsStrategy<'a> {
|
||||
pub fn new(issue_ref: &'a IssueRef, nix: Nix) -> NixpkgsStrategy<'a> {
|
||||
Self { issue_ref, nix }
|
||||
Self {
|
||||
issue_ref,
|
||||
nix,
|
||||
stdenv_diff: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn tag_from_title(&self) {
|
||||
|
@ -31,6 +37,32 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
update_labels(&self.issue_ref, &[String::from("6.topic: darwin")], &[]);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_stdenvs_before(&mut self, dir: &Path) {
|
||||
let mut stdenvs = Stdenvs::new(self.nix.clone(), dir.to_path_buf());
|
||||
stdenvs.identify_before();
|
||||
self.stdenv_diff = Some(stdenvs);
|
||||
}
|
||||
|
||||
fn check_stdenvs_after(&mut self) {
|
||||
if let Some(ref mut stdenvs) = self.stdenv_diff {
|
||||
stdenvs.identify_after();
|
||||
}
|
||||
}
|
||||
|
||||
fn update_stdenv_labels(&self) {
|
||||
if let Some(ref stdenvs) = self.stdenv_diff {
|
||||
let mut stdenvtagger = StdenvTagger::new();
|
||||
if !stdenvs.are_same() {
|
||||
stdenvtagger.changed(stdenvs.changed());
|
||||
}
|
||||
update_labels(
|
||||
&self.issue_ref,
|
||||
&stdenvtagger.tags_to_add(),
|
||||
&stdenvtagger.tags_to_remove(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
|
||||
|
@ -39,7 +71,13 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn on_target_branch(&mut self, _co: &Path, _status: &mut CommitStatus) -> StepResult<()> {
|
||||
fn on_target_branch(&mut self, dir: &Path, status: &mut CommitStatus) -> StepResult<()> {
|
||||
status.set_with_description(
|
||||
"Checking original stdenvs",
|
||||
hubcaps::statuses::State::Pending,
|
||||
);
|
||||
self.check_stdenvs_before(dir);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -49,7 +87,10 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
|
|||
|
||||
fn merge_conflict(&mut self) {}
|
||||
|
||||
fn after_merge(&mut self, _status: &mut CommitStatus) -> StepResult<()> {
|
||||
fn after_merge(&mut self, status: &mut CommitStatus) -> StepResult<()> {
|
||||
status.set_with_description("Checking new stdenvs", hubcaps::statuses::State::Pending);
|
||||
self.check_stdenvs_after();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -62,6 +103,8 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
|
|||
_co: &Path,
|
||||
_status: &mut CommitStatus,
|
||||
) -> StepResult<Vec<BuildJob>> {
|
||||
self.update_stdenv_labels();
|
||||
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,7 @@ use ofborg::outpathdiff::{OutPathDiff, OutPaths};
|
|||
use ofborg::stats;
|
||||
use ofborg::stats::Event;
|
||||
use ofborg::systems;
|
||||
use ofborg::tagger::{
|
||||
MaintainerPRTagger, PathsTagger, PkgsAddedRemovedTagger, RebuildTagger, StdenvTagger,
|
||||
};
|
||||
use ofborg::tagger::{MaintainerPRTagger, PathsTagger, PkgsAddedRemovedTagger, RebuildTagger};
|
||||
use ofborg::worker;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
@ -222,14 +220,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
|
|||
return self.actions().skip(&job);
|
||||
}
|
||||
|
||||
overall_status.set_with_description(
|
||||
"Checking original stdenvs",
|
||||
hubcaps::statuses::State::Pending,
|
||||
);
|
||||
|
||||
let mut stdenvs = eval::Stdenvs::new(self.nix.clone(), PathBuf::from(&refpath));
|
||||
stdenvs.identify_before();
|
||||
|
||||
let mut rebuildsniff = OutPathDiff::new(self.nix.clone(), PathBuf::from(&refpath));
|
||||
|
||||
overall_status.set_with_description(
|
||||
|
@ -311,11 +301,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
|
|||
return self.actions().skip(&job);
|
||||
}
|
||||
|
||||
overall_status
|
||||
.set_with_description("Checking new stdenvs", hubcaps::statuses::State::Pending);
|
||||
|
||||
stdenvs.identify_after();
|
||||
|
||||
overall_status
|
||||
.set_with_description("Checking new out paths", hubcaps::statuses::State::Pending);
|
||||
|
||||
|
@ -552,16 +537,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
|
|||
hubcaps::statuses::State::Pending,
|
||||
);
|
||||
|
||||
let mut stdenvtagger = StdenvTagger::new();
|
||||
if !stdenvs.are_same() {
|
||||
stdenvtagger.changed(stdenvs.changed());
|
||||
}
|
||||
update_labels(
|
||||
&issue_ref,
|
||||
&stdenvtagger.tags_to_add(),
|
||||
&stdenvtagger.tags_to_remove(),
|
||||
);
|
||||
|
||||
if let Some((removed, added)) = rebuildsniff.package_diff() {
|
||||
let mut addremovetagger = PkgsAddedRemovedTagger::new();
|
||||
addremovetagger.changed(&removed, &added);
|
||||
|
|
Loading…
Reference in a new issue