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"
|
"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": {
|
"checkout": {
|
||||||
"root": "/var/lib/gc-of-borg/.nix-test-rs"
|
"root": "/var/lib/gc-of-borg/.nix-test-rs"
|
||||||
},
|
},
|
||||||
|
|
|
@ -39,6 +39,7 @@ fn main() {
|
||||||
cfg.acl(),
|
cfg.acl(),
|
||||||
cfg.runner.identity.clone(),
|
cfg.runner.identity.clone(),
|
||||||
events,
|
events,
|
||||||
|
cfg.tag_paths.clone().unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
channel.basic_prefetch(1).unwrap();
|
channel.basic_prefetch(1).unwrap();
|
||||||
|
|
|
@ -7,6 +7,7 @@ use hyper::net::HttpsConnector;
|
||||||
use hyper_native_tls::NativeTlsClient;
|
use hyper_native_tls::NativeTlsClient;
|
||||||
use hubcaps::{Credentials, Github};
|
use hubcaps::{Credentials, Github};
|
||||||
use nix::Nix;
|
use nix::Nix;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
|
||||||
use ofborg::acl;
|
use ofborg::acl;
|
||||||
|
@ -20,6 +21,7 @@ pub struct Config {
|
||||||
pub rabbitmq: RabbitMQConfig,
|
pub rabbitmq: RabbitMQConfig,
|
||||||
pub github: Option<GithubConfig>,
|
pub github: Option<GithubConfig>,
|
||||||
pub log_storage: Option<LogStorage>,
|
pub log_storage: Option<LogStorage>,
|
||||||
|
pub tag_paths: Option<HashMap<String, Vec<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
@ -15,7 +15,7 @@ use ofborg::nix::Nix;
|
||||||
use ofborg::acl::ACL;
|
use ofborg::acl::ACL;
|
||||||
use ofborg::stats;
|
use ofborg::stats;
|
||||||
use ofborg::worker;
|
use ofborg::worker;
|
||||||
use ofborg::tagger::{StdenvTagger, RebuildTagger};
|
use ofborg::tagger::{StdenvTagger, RebuildTagger, PathsTagger};
|
||||||
use ofborg::outpathdiff::{OutPaths, OutPathDiff};
|
use ofborg::outpathdiff::{OutPaths, OutPathDiff};
|
||||||
use ofborg::evalchecker::EvalChecker;
|
use ofborg::evalchecker::EvalChecker;
|
||||||
use ofborg::commitstatus::CommitStatus;
|
use ofborg::commitstatus::CommitStatus;
|
||||||
|
@ -30,6 +30,7 @@ pub struct MassRebuildWorker<E> {
|
||||||
acl: ACL,
|
acl: ACL,
|
||||||
identity: String,
|
identity: String,
|
||||||
events: E,
|
events: E,
|
||||||
|
tag_paths: HashMap<String, Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
||||||
|
@ -40,6 +41,7 @@ impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
||||||
acl: ACL,
|
acl: ACL,
|
||||||
identity: String,
|
identity: String,
|
||||||
events: E,
|
events: E,
|
||||||
|
tag_paths: HashMap<String, Vec<String>>,
|
||||||
) -> MassRebuildWorker<E> {
|
) -> MassRebuildWorker<E> {
|
||||||
return MassRebuildWorker {
|
return MassRebuildWorker {
|
||||||
cloner: cloner,
|
cloner: cloner,
|
||||||
|
@ -48,12 +50,27 @@ impl<E: stats::SysEvents> MassRebuildWorker<E> {
|
||||||
acl: acl,
|
acl: acl,
|
||||||
identity: identity,
|
identity: identity,
|
||||||
events: events,
|
events: events,
|
||||||
|
tag_paths: tag_paths
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> massrebuildjob::Actions {
|
fn actions(&self) -> massrebuildjob::Actions {
|
||||||
return 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> {
|
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()],
|
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);
|
overall_status.set_with_description("Merging PR", hubcaps::statuses::State::Pending);
|
||||||
|
|
||||||
if let Err(_) = co.merge_commit(job.pr.head_sha.as_ref()) {
|
if let Err(_) = co.merge_commit(job.pr.head_sha.as_ref()) {
|
||||||
|
|
Loading…
Reference in a new issue