RebuildTagger
This commit is contained in:
parent
2749bb4bc9
commit
12fcd21725
|
@ -29,6 +29,7 @@ pub mod ghevent;
|
|||
pub mod commentparser;
|
||||
pub mod commitstatus;
|
||||
pub mod outpathdiff;
|
||||
pub mod tagger;
|
||||
|
||||
|
||||
pub mod ofborg {
|
||||
|
@ -46,4 +47,5 @@ pub mod ofborg {
|
|||
pub use acl;
|
||||
pub use commentparser;
|
||||
pub use outpathdiff;
|
||||
pub use tagger;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,83 @@
|
|||
|
||||
struct Tagger {
|
||||
pub struct RebuildTagger {
|
||||
possible: Vec<String>,
|
||||
selected: Vec<String>,
|
||||
}
|
||||
|
||||
impl Tagger {
|
||||
impl RebuildTagger {
|
||||
pub fn new() -> RebuildTagger {
|
||||
let mut t = RebuildTagger {
|
||||
possible: vec![
|
||||
String::from("10.rebuild-linux: 501+"),
|
||||
String::from("10.rebuild-linux: 101-500"),
|
||||
String::from("10.rebuild-linux: 11-100"),
|
||||
String::from("10.rebuild-linux: 1-10"),
|
||||
String::from("10.rebuild-linux: 0"),
|
||||
|
||||
String::from("10.rebuild-darwin: 501+"),
|
||||
String::from("10.rebuild-darwin: 101-500"),
|
||||
String::from("10.rebuild-darwin: 11-100"),
|
||||
String::from("10.rebuild-darwin: 1-10"),
|
||||
String::from("10.rebuild-darwin: 0"),
|
||||
],
|
||||
selected: vec![],
|
||||
};
|
||||
t.possible.sort();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
pub fn parse_attrs(&mut self, attrs: Vec<String>) {
|
||||
let mut counter_darwin = 0;
|
||||
let mut counter_linux = 0;
|
||||
|
||||
for attr in attrs {
|
||||
match attr.rsplit(".").next() {
|
||||
Some("x86_64-darwin") => { counter_darwin += 1; }
|
||||
Some("x86_64-linux") => { counter_linux += 1; }
|
||||
Some(arch) => { info!("Unknown arch: {:?}", arch); }
|
||||
None => { info!("Cannot grok attr: {:?}", attr); }
|
||||
}
|
||||
}
|
||||
|
||||
self.selected = vec![
|
||||
String::from(format!("10.rebuild-linux: {}", self.bucket(counter_linux))),
|
||||
String::from(format!("10.rebuild-darwin: {}", self.bucket(counter_darwin))),
|
||||
];
|
||||
|
||||
for tag in &self.selected {
|
||||
if !self.possible.contains(&tag) {
|
||||
panic!("Tried to add label {} but it isn't in the possible list!", tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tags_to_add(&self) -> Vec<String> {
|
||||
self.selected.clone()
|
||||
}
|
||||
|
||||
pub fn tags_to_remove(&self) -> Vec<String> {
|
||||
let mut remove = self.possible.clone();
|
||||
for tag in &self.selected {
|
||||
let pos = remove.binary_search(&tag).unwrap();
|
||||
remove.remove(pos);
|
||||
}
|
||||
|
||||
return remove;
|
||||
}
|
||||
|
||||
fn bucket(&self, count: u64) -> &str{
|
||||
if count > 500 {
|
||||
return "501+";
|
||||
} else if count > 100 {
|
||||
return "101-500";
|
||||
} else if count > 10 {
|
||||
return "11-100";
|
||||
} else if count > 0 {
|
||||
return "1-10";
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use ofborg::message::massrebuildjob;
|
|||
use ofborg::nix;
|
||||
|
||||
use ofborg::worker;
|
||||
use ofborg::tagger::RebuildTagger;
|
||||
use ofborg::outpathdiff::OutPathDiff;
|
||||
use ofborg::evalchecker::EvalChecker;
|
||||
use ofborg::commitstatus::CommitStatus;
|
||||
|
@ -288,14 +289,18 @@ impl worker::SimpleWorker for MassRebuildWorker {
|
|||
hubcaps::statuses::State::Pending
|
||||
);
|
||||
|
||||
tagger = StdenvTagger::new();
|
||||
// let tagger = StdenvTagger::new();
|
||||
if !stdenvs.are_same() {
|
||||
println!("Stdenvs changed? {:?}", stdenvs.changed());
|
||||
}
|
||||
|
||||
let mut rebuildTags = RebuildTagger::new();
|
||||
if let Some(attrs) = rebuildsniff.calculate_rebuild() {
|
||||
bucketize_attrs(attrs)
|
||||
tagger.parse_attrs(attrs);
|
||||
}
|
||||
println!("New Tags: {:?}", tagger.tags_to_add());
|
||||
println!("Drop Tags: {:?}", tagger.tags_to_remove());
|
||||
|
||||
|
||||
overall_status.set_with_description(
|
||||
"^.^!",
|
||||
|
|
Loading…
Reference in a new issue