forked from the-distro/ofborg
Tag PRs based on paths they touch
This commit is contained in:
parent
a9182ea325
commit
de179794cb
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -39,6 +39,7 @@ fn main() {
|
|||
cfg.acl(),
|
||||
cfg.runner.identity.clone(),
|
||||
events,
|
||||
cfg.tag_paths.clone().unwrap(),
|
||||
);
|
||||
|
||||
channel.basic_prefetch(1).unwrap();
|
||||
|
|
|
@ -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<GithubConfig>,
|
||||
pub log_storage: Option<LogStorage>,
|
||||
pub tag_paths: Option<HashMap<String, Vec<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
@ -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<E> {
|
|||
acl: ACL,
|
||||
identity: String,
|
||||
events: E,
|
||||
tag_paths: HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
||||
|
@ -40,6 +41,7 @@ impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
|||
acl: ACL,
|
||||
identity: String,
|
||||
events: E,
|
||||
tag_paths: HashMap<String, Vec<String>>,
|
||||
) -> MassRebuildWorker<E> {
|
||||
return MassRebuildWorker {
|
||||
cloner: cloner,
|
||||
|
@ -48,12 +50,27 @@ impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
|||
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<String>) {
|
||||
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<E: stats::SysEvents> worker::SimpleWorker for MassRebuildWorker<E> {
|
||||
|
@ -199,6 +216,11 @@ impl<E: stats::SysEvents> worker::SimpleWorker for MassRebuildWorker<E> {
|
|||
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()) {
|
||||
|
|
Loading…
Reference in a new issue