Tag issues :)
This commit is contained in:
parent
12fcd21725
commit
4ae086fca8
14
ofborg/Cargo.lock
generated
14
ofborg/Cargo.lock
generated
|
@ -2,10 +2,10 @@
|
|||
name = "ofborg"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"amqp 0.1.0",
|
||||
"amqp 0.1.0 (git+https://github.com/grahamc/rust-amqp.git)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hubcaps 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hubcaps 0.3.16 (git+https://github.com/grahamc/hubcaps.git)",
|
||||
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hyper-native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -44,6 +44,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "amq-proto"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -56,8 +57,9 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "amqp"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/grahamc/rust-amqp.git#1216885c84f7c94a205a8e41519684e7df0e0f35"
|
||||
dependencies = [
|
||||
"amq-proto 0.1.0",
|
||||
"amq-proto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -249,7 +251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "hubcaps"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+https://github.com/grahamc/hubcaps.git#3ddb700e6b51d7ffc2edd3b001987b4fa124d0e2"
|
||||
dependencies = [
|
||||
"error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -733,6 +735,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a"
|
||||
"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
|
||||
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
|
||||
"checksum amq-proto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66d79639b71f74c7006c12683cc2ff221615a51a741688fa7798ccd080dc54d3"
|
||||
"checksum amqp 0.1.0 (git+https://github.com/grahamc/rust-amqp.git)" = "<none>"
|
||||
"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
|
||||
"checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983"
|
||||
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
|
||||
|
@ -758,7 +762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
|
||||
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
|
||||
"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07"
|
||||
"checksum hubcaps 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "13d7f1355f4260166557df0f28522dc16f02e197c37e6b48ea0c1a996c8b0193"
|
||||
"checksum hubcaps 0.3.16 (git+https://github.com/grahamc/hubcaps.git)" = "<none>"
|
||||
"checksum hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "368cb56b2740ebf4230520e2b90ebb0461e69034d85d1945febd9b3971426db2"
|
||||
"checksum hyper-native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72332e4a35d3059583623b50e98e491b78f8b96c5521fcb3f428167955aa56e8"
|
||||
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
|
||||
|
|
|
@ -6,13 +6,13 @@ authors = ["Graham Christensen <graham@grahamc.com>"]
|
|||
[dependencies]
|
||||
log = "0.3.8"
|
||||
env_logger = "0.4.3"
|
||||
amqp = { path = "rust-amqp" }
|
||||
amqp = { git = "https://github.com/grahamc/rust-amqp.git" }
|
||||
md5 = "0.3.5"
|
||||
fs2 = "0.4.2"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
tempfile = "2.2.0"
|
||||
hubcaps = "0.3.16"
|
||||
hubcaps = { git = "https://github.com/grahamc/hubcaps.git" }
|
||||
hyper = "0.10.*"
|
||||
hyper-native-tls = "0.2.4"
|
||||
|
|
|
@ -57,6 +57,7 @@ fn main() {
|
|||
cfg.github(),
|
||||
cfg.checkout.root.clone()
|
||||
);
|
||||
/*
|
||||
println!("{:?}", mrw.consumer(&message::massrebuildjob::MassRebuildJob{
|
||||
pr: ofborg::message::Pr {
|
||||
head_sha: String::from("85589b80e81d5839cc91eb6be2cc3f7c041b760a"),
|
||||
|
@ -70,9 +71,7 @@ fn main() {
|
|||
name: String::from("nixpkgs"),
|
||||
}
|
||||
}));
|
||||
panic!();
|
||||
|
||||
|
||||
*/
|
||||
|
||||
channel.basic_consume(
|
||||
worker::new(mrw),
|
||||
|
|
|
@ -1,3 +1,58 @@
|
|||
use ofborg::tasks;
|
||||
|
||||
pub struct StdenvTagger {
|
||||
possible: Vec<String>,
|
||||
selected: Vec<String>,
|
||||
}
|
||||
|
||||
impl StdenvTagger {
|
||||
pub fn new() -> StdenvTagger {
|
||||
let mut t = StdenvTagger {
|
||||
possible: vec![
|
||||
String::from("10.rebuild-linux-stdenv"),
|
||||
String::from("10.rebuild-darwin-stdenv"),
|
||||
],
|
||||
selected: vec![],
|
||||
};
|
||||
t.possible.sort();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
pub fn changed(&mut self, systems: Vec<tasks::massrebuilder::System>) {
|
||||
for system in systems {
|
||||
match system {
|
||||
tasks::massrebuilder::System::X8664Darwin => {
|
||||
self.selected.push(String::from("10.rebuild-darwin-stdenv"));
|
||||
}
|
||||
tasks::massrebuilder::System::X8664Linux => {
|
||||
self.selected.push(String::from("10.rebuild-linux-stdenv"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub struct RebuildTagger {
|
||||
possible: Vec<String>,
|
||||
|
|
|
@ -13,7 +13,7 @@ use ofborg::message::massrebuildjob;
|
|||
use ofborg::nix;
|
||||
|
||||
use ofborg::worker;
|
||||
use ofborg::tagger::RebuildTagger;
|
||||
use ofborg::tagger::{StdenvTagger,RebuildTagger};
|
||||
use ofborg::outpathdiff::OutPathDiff;
|
||||
use ofborg::evalchecker::EvalChecker;
|
||||
use ofborg::commitstatus::CommitStatus;
|
||||
|
@ -61,7 +61,7 @@ impl worker::SimpleWorker for MassRebuildWorker {
|
|||
let repo = self.github
|
||||
.repo(job.repo.owner.clone(), job.repo.name.clone());
|
||||
let gists = self.github.gists();
|
||||
|
||||
let issue = repo.issue(job.pr.number);
|
||||
|
||||
let mut overall_status = CommitStatus::new(
|
||||
repo.statuses(),
|
||||
|
@ -289,18 +289,19 @@ impl worker::SimpleWorker for MassRebuildWorker {
|
|||
hubcaps::statuses::State::Pending
|
||||
);
|
||||
|
||||
// let tagger = StdenvTagger::new();
|
||||
let mut stdenvtagger = StdenvTagger::new();
|
||||
if !stdenvs.are_same() {
|
||||
println!("Stdenvs changed? {:?}", stdenvs.changed());
|
||||
stdenvtagger.changed(stdenvs.changed());
|
||||
}
|
||||
update_labels(&issue, stdenvtagger.tags_to_add(),
|
||||
stdenvtagger.tags_to_remove());
|
||||
|
||||
let mut rebuildTags = RebuildTagger::new();
|
||||
if let Some(attrs) = rebuildsniff.calculate_rebuild() {
|
||||
tagger.parse_attrs(attrs);
|
||||
rebuildTags.parse_attrs(attrs);
|
||||
}
|
||||
println!("New Tags: {:?}", tagger.tags_to_add());
|
||||
println!("Drop Tags: {:?}", tagger.tags_to_remove());
|
||||
|
||||
update_labels(&issue, rebuildTags.tags_to_add(),
|
||||
rebuildTags.tags_to_remove());
|
||||
|
||||
overall_status.set_with_description(
|
||||
"^.^!",
|
||||
|
@ -324,7 +325,7 @@ enum StdenvFrom {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum System {
|
||||
pub enum System {
|
||||
X8664Darwin,
|
||||
X8664Linux
|
||||
}
|
||||
|
@ -425,6 +426,35 @@ impl Stdenvs {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec<String>, remove: Vec<String>) {
|
||||
let l = issue.labels();
|
||||
|
||||
let existing: Vec<String> = issue.get().unwrap().labels
|
||||
.iter()
|
||||
.map(|l| l.name.clone())
|
||||
.collect();
|
||||
println!("Already: {:?}", existing);
|
||||
let to_add = add
|
||||
.iter()
|
||||
.filter(|l| !existing.contains(l)) // Remove labels already on the issue
|
||||
.map(|l| l.as_ref()).collect();
|
||||
info!("Adding labels: {:?}", to_add);
|
||||
|
||||
let to_remove: Vec<String> = remove
|
||||
.iter()
|
||||
.filter(|l| existing.contains(l)) // Remove labels already on the issue
|
||||
.map(|l| l.clone())
|
||||
.collect();
|
||||
info!("Removing labels: {:?}", to_remove);
|
||||
|
||||
l.add(to_add);
|
||||
|
||||
for label in to_remove {
|
||||
l.remove(&label);
|
||||
}
|
||||
}
|
||||
|
||||
fn file_to_drv(f: &mut File) -> Option<String> {
|
||||
let r = BufReader::new(f);
|
||||
let matches: Vec<String>;
|
||||
|
|
Loading…
Reference in a new issue