diff --git a/config.public.json b/config.public.json index 96ca3f4..30f7998 100644 --- a/config.public.json +++ b/config.public.json @@ -40,6 +40,18 @@ "zimbatm" ] }, + "tag_paths": { + "6.topic: python": [ + "pkgs/top-level/python-packages.nix", + "pkgs/development/interpreters/python", + "pkgs/development/python-modules", + "doc/languages-frameworks/python.md" + ], + "6.topic: ruby": [ + "pkgs/development/interpreters/ruby", + "pkgs/development/ruby-modules" + ] + }, "checkout": { "root": "/var/lib/gc-of-borg/.nix-test-rs" }, diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index 79732d2..8f0a5a5 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -39,6 +39,7 @@ fn main() { cfg.acl(), cfg.runner.identity.clone(), events, + cfg.tag_paths.clone().unwrap(), ); channel.basic_prefetch(1).unwrap(); diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index a77a159..5381b81 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -7,6 +7,7 @@ use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use hubcaps::{Credentials, Github}; use nix::Nix; +use std::collections::HashMap; use ofborg::acl; @@ -20,6 +21,7 @@ pub struct Config { pub rabbitmq: RabbitMQConfig, pub github: Option, pub log_storage: Option, + pub tag_paths: Option>>, } #[derive(Serialize, Deserialize, Debug)] diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 53c0596..dfcfaee 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -15,7 +15,7 @@ use ofborg::nix::Nix; use ofborg::acl::ACL; use ofborg::stats; use ofborg::worker; -use ofborg::tagger::{StdenvTagger, RebuildTagger}; +use ofborg::tagger::{StdenvTagger, RebuildTagger, PathsTagger}; use ofborg::outpathdiff::{OutPaths, OutPathDiff}; use ofborg::evalchecker::EvalChecker; use ofborg::commitstatus::CommitStatus; @@ -30,6 +30,7 @@ pub struct MassRebuildWorker { acl: ACL, identity: String, events: E, + tag_paths: HashMap>, } impl MassRebuildWorker { @@ -40,6 +41,7 @@ impl MassRebuildWorker { acl: ACL, identity: String, events: E, + tag_paths: HashMap>, ) -> MassRebuildWorker { return MassRebuildWorker { cloner: cloner, @@ -48,12 +50,27 @@ impl MassRebuildWorker { acl: acl, identity: identity, events: events, + tag_paths: tag_paths }; } fn actions(&self) -> massrebuildjob::Actions { return massrebuildjob::Actions {}; } + + fn tag_from_paths(&self, issue: &hubcaps::issues::IssueRef, paths: Vec) { + let mut tagger = PathsTagger::new(self.tag_paths.clone()); + + for path in paths { + tagger.path_changed(&path); + } + + update_labels( + &issue, + tagger.tags_to_add(), + tagger.tags_to_remove(), + ); + } } impl worker::SimpleWorker for MassRebuildWorker { @@ -199,6 +216,11 @@ impl worker::SimpleWorker for MassRebuildWorker { vec!["".to_owned()], )); + self.tag_from_paths( + &issue, + co.files_changed_from_head(&job.pr.head_sha).unwrap_or(vec![]) + ); + overall_status.set_with_description("Merging PR", hubcaps::statuses::State::Pending); if let Err(_) = co.merge_commit(job.pr.head_sha.as_ref()) {