ofborg: remove tag_paths
This commit is contained in:
parent
2e710169d9
commit
6adac57ee9
|
@ -62,7 +62,6 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
cfg.acl(),
|
||||
cfg.runner.identity.clone(),
|
||||
events,
|
||||
cfg.tag_paths.clone().unwrap(),
|
||||
),
|
||||
easyamqp::ConsumeConfig {
|
||||
queue: queue_name.clone(),
|
||||
|
|
|
@ -22,7 +22,6 @@ pub struct Config {
|
|||
pub github: Option<GithubConfig>,
|
||||
pub github_app: Option<GithubAppConfig>,
|
||||
pub log_storage: Option<LogStorage>,
|
||||
pub tag_paths: Option<HashMap<String, Vec<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
@ -2,8 +2,6 @@ use crate::maintainers::{Maintainer, MaintainersByPackage};
|
|||
use crate::outpathdiff::PackageArch;
|
||||
use crate::tasks;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use tracing::info;
|
||||
|
||||
pub struct StdenvTagger {
|
||||
|
@ -237,47 +235,6 @@ impl RebuildTagger {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct PathsTagger {
|
||||
possible: HashMap<String, Vec<String>>,
|
||||
selected: Vec<String>,
|
||||
}
|
||||
|
||||
impl PathsTagger {
|
||||
pub fn new(tags_and_criteria: HashMap<String, Vec<String>>) -> PathsTagger {
|
||||
PathsTagger {
|
||||
possible: tags_and_criteria,
|
||||
selected: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path_changed(&mut self, path: &str) {
|
||||
let mut tags_to_add: Vec<String> = self
|
||||
.possible
|
||||
.iter()
|
||||
.filter(|&(ref tag, ref _paths)| !self.selected.contains(&tag))
|
||||
.filter(|&(ref _tag, ref paths)| paths.iter().any(|tp| path.contains(tp)))
|
||||
.map(|(tag, _paths)| tag.clone())
|
||||
.collect();
|
||||
self.selected.append(&mut tags_to_add);
|
||||
self.selected.sort();
|
||||
}
|
||||
|
||||
pub fn tags_to_add(&self) -> Vec<String> {
|
||||
self.selected.clone()
|
||||
}
|
||||
|
||||
pub fn tags_to_remove(&self) -> Vec<String> {
|
||||
let mut remove: Vec<String> = self.possible.keys().map(|k| k.to_owned()).collect();
|
||||
remove.sort();
|
||||
for tag in &self.selected {
|
||||
let pos = remove.binary_search(&tag).unwrap();
|
||||
remove.remove(pos);
|
||||
}
|
||||
|
||||
remove
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MaintainerPRTagger {
|
||||
possible: Vec<String>,
|
||||
selected: Vec<String>,
|
||||
|
@ -856,56 +813,4 @@ mod tests {
|
|||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_files_changed_list() {
|
||||
let mut criteria: HashMap<String, Vec<String>> = HashMap::new();
|
||||
criteria.insert(
|
||||
"topic: python".to_owned(),
|
||||
vec![
|
||||
"pkgs/top-level/python-packages.nix".to_owned(),
|
||||
"bogus".to_owned(),
|
||||
],
|
||||
);
|
||||
criteria.insert(
|
||||
"topic: ruby".to_owned(),
|
||||
vec![
|
||||
"pkgs/development/interpreters/ruby".to_owned(),
|
||||
"bogus".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
{
|
||||
let mut tagger = PathsTagger::new(criteria.clone());
|
||||
tagger.path_changed("default.nix");
|
||||
assert_eq!(tagger.tags_to_add().len(), 0);
|
||||
assert_eq!(
|
||||
tagger.tags_to_remove(),
|
||||
vec!["topic: python".to_owned(), "topic: ruby".to_owned()]
|
||||
);
|
||||
|
||||
tagger.path_changed("pkgs/development/interpreters/ruby/default.nix");
|
||||
assert_eq!(tagger.tags_to_add(), vec!["topic: ruby".to_owned()]);
|
||||
assert_eq!(tagger.tags_to_remove(), vec!["topic: python".to_owned()]);
|
||||
|
||||
tagger.path_changed("pkgs/development/interpreters/ruby/foobar.nix");
|
||||
assert_eq!(tagger.tags_to_add(), vec!["topic: ruby".to_owned()]);
|
||||
assert_eq!(tagger.tags_to_remove(), vec!["topic: python".to_owned()]);
|
||||
|
||||
tagger.path_changed("pkgs/top-level/python-packages.nix");
|
||||
assert_eq!(
|
||||
tagger.tags_to_add(),
|
||||
vec!["topic: python".to_owned(), "topic: ruby".to_owned()]
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
let mut tagger = PathsTagger::new(criteria.clone());
|
||||
tagger.path_changed("bogus");
|
||||
assert_eq!(
|
||||
tagger.tags_to_add(),
|
||||
vec!["topic: python".to_owned(), "topic: ruby".to_owned()]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,12 @@ use crate::message::evaluationjob::EvaluationJob;
|
|||
use crate::nix::{self, Nix};
|
||||
use crate::nixenv::HydraNixEnv;
|
||||
use crate::outpathdiff::{OutPathDiff, PackageArch};
|
||||
use crate::tagger::{
|
||||
MaintainerPRTagger, PathsTagger, PkgsAddedRemovedTagger, RebuildTagger, StdenvTagger,
|
||||
};
|
||||
use crate::tagger::{MaintainerPRTagger, PkgsAddedRemovedTagger, RebuildTagger, StdenvTagger};
|
||||
use crate::tasks::eval::{
|
||||
stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult,
|
||||
};
|
||||
use crate::tasks::evaluate::{get_prefix, make_gist, update_labels};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::Utc;
|
||||
|
@ -37,7 +34,6 @@ pub struct NixpkgsStrategy<'a> {
|
|||
repo: &'a Repository<'a>,
|
||||
gists: &'a Gists<'a>,
|
||||
nix: Nix,
|
||||
tag_paths: &'a HashMap<String, Vec<String>>,
|
||||
stdenv_diff: Option<Stdenvs>,
|
||||
outpath_diff: Option<OutPathDiff>,
|
||||
changed_paths: Option<Vec<String>>,
|
||||
|
@ -54,7 +50,6 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
repo: &'a Repository,
|
||||
gists: &'a Gists,
|
||||
nix: Nix,
|
||||
tag_paths: &'a HashMap<String, Vec<String>>,
|
||||
) -> NixpkgsStrategy<'a> {
|
||||
Self {
|
||||
job,
|
||||
|
@ -64,7 +59,6 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
repo,
|
||||
gists,
|
||||
nix,
|
||||
tag_paths,
|
||||
stdenv_diff: None,
|
||||
outpath_diff: None,
|
||||
changed_paths: None,
|
||||
|
@ -87,22 +81,6 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn tag_from_paths(&self) {
|
||||
if let Some(ref changed_paths) = self.changed_paths {
|
||||
let mut tagger = PathsTagger::new(self.tag_paths.clone());
|
||||
|
||||
for path in changed_paths {
|
||||
tagger.path_changed(&path);
|
||||
}
|
||||
|
||||
update_labels(
|
||||
&self.issue_ref,
|
||||
&tagger.tags_to_add(),
|
||||
&tagger.tags_to_remove(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_stdenvs_before(&mut self, dir: &Path) {
|
||||
let mut stdenvs = Stdenvs::new(self.nix.clone(), dir.to_path_buf());
|
||||
stdenvs.identify_before();
|
||||
|
@ -402,7 +380,6 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
|
|||
.files_changed_from_head(&self.job.pr.head_sha)
|
||||
.unwrap_or_else(|_| vec![]);
|
||||
self.changed_paths = Some(changed_paths);
|
||||
self.tag_from_paths();
|
||||
|
||||
self.touched_packages = Some(parse_commit_messages(
|
||||
&co.commit_messages_from_head(&self.job.pr.head_sha)
|
||||
|
|
|
@ -29,7 +29,6 @@ pub struct EvaluationWorker<E> {
|
|||
acl: ACL,
|
||||
identity: String,
|
||||
events: E,
|
||||
tag_paths: HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
/// Creates a finished github check, indicating that the ofborg eval started.
|
||||
|
@ -59,7 +58,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
|
|||
acl: ACL,
|
||||
identity: String,
|
||||
events: E,
|
||||
tag_paths: HashMap<String, Vec<String>>,
|
||||
) -> EvaluationWorker<E> {
|
||||
EvaluationWorker {
|
||||
cloner,
|
||||
|
@ -69,7 +67,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
|
|||
acl,
|
||||
identity,
|
||||
events,
|
||||
tag_paths,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +113,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
|
|||
&self.acl,
|
||||
&mut self.events,
|
||||
&self.identity,
|
||||
&self.tag_paths,
|
||||
&self.cloner,
|
||||
job,
|
||||
)
|
||||
|
@ -132,7 +128,6 @@ struct OneEval<'a, E> {
|
|||
acl: &'a ACL,
|
||||
events: &'a mut E,
|
||||
identity: &'a str,
|
||||
tag_paths: &'a HashMap<String, Vec<String>>,
|
||||
cloner: &'a checkout::CachedCloner,
|
||||
job: &'a evaluationjob::EvaluationJob,
|
||||
}
|
||||
|
@ -146,7 +141,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
acl: &'a ACL,
|
||||
events: &'a mut E,
|
||||
identity: &'a str,
|
||||
tag_paths: &'a HashMap<String, Vec<String>>,
|
||||
cloner: &'a checkout::CachedCloner,
|
||||
job: &'a evaluationjob::EvaluationJob,
|
||||
) -> OneEval<'a, E> {
|
||||
|
@ -161,7 +155,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
acl,
|
||||
events,
|
||||
identity,
|
||||
tag_paths,
|
||||
cloner,
|
||||
job,
|
||||
}
|
||||
|
@ -320,7 +313,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
&repo,
|
||||
&self.gists,
|
||||
self.nix.clone(),
|
||||
&self.tag_paths,
|
||||
))
|
||||
} else {
|
||||
Box::new(eval::GenericStrategy::new())
|
||||
|
|
Loading…
Reference in a new issue