ofborg: remove tag_paths

This commit is contained in:
zowoq 2021-03-19 06:58:07 +10:00 committed by Cole Helbling
parent 2e710169d9
commit 6adac57ee9
5 changed files with 1 additions and 129 deletions

View file

@ -62,7 +62,6 @@ fn main() -> Result<(), Box<dyn Error>> {
cfg.acl(), cfg.acl(),
cfg.runner.identity.clone(), cfg.runner.identity.clone(),
events, events,
cfg.tag_paths.clone().unwrap(),
), ),
easyamqp::ConsumeConfig { easyamqp::ConsumeConfig {
queue: queue_name.clone(), queue: queue_name.clone(),

View file

@ -22,7 +22,6 @@ pub struct Config {
pub github: Option<GithubConfig>, pub github: Option<GithubConfig>,
pub github_app: Option<GithubAppConfig>, pub github_app: Option<GithubAppConfig>,
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)]

View file

@ -2,8 +2,6 @@ use crate::maintainers::{Maintainer, MaintainersByPackage};
use crate::outpathdiff::PackageArch; use crate::outpathdiff::PackageArch;
use crate::tasks; use crate::tasks;
use std::collections::HashMap;
use tracing::info; use tracing::info;
pub struct StdenvTagger { 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 { pub struct MaintainerPRTagger {
possible: Vec<String>, possible: Vec<String>,
selected: 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()]
);
}
}
} }

View file

@ -8,15 +8,12 @@ use crate::message::evaluationjob::EvaluationJob;
use crate::nix::{self, Nix}; use crate::nix::{self, Nix};
use crate::nixenv::HydraNixEnv; use crate::nixenv::HydraNixEnv;
use crate::outpathdiff::{OutPathDiff, PackageArch}; use crate::outpathdiff::{OutPathDiff, PackageArch};
use crate::tagger::{ use crate::tagger::{MaintainerPRTagger, PkgsAddedRemovedTagger, RebuildTagger, StdenvTagger};
MaintainerPRTagger, PathsTagger, PkgsAddedRemovedTagger, RebuildTagger, StdenvTagger,
};
use crate::tasks::eval::{ use crate::tasks::eval::{
stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult, stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult,
}; };
use crate::tasks::evaluate::{get_prefix, make_gist, update_labels}; use crate::tasks::evaluate::{get_prefix, make_gist, update_labels};
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use chrono::Utc; use chrono::Utc;
@ -37,7 +34,6 @@ pub struct NixpkgsStrategy<'a> {
repo: &'a Repository<'a>, repo: &'a Repository<'a>,
gists: &'a Gists<'a>, gists: &'a Gists<'a>,
nix: Nix, nix: Nix,
tag_paths: &'a HashMap<String, Vec<String>>,
stdenv_diff: Option<Stdenvs>, stdenv_diff: Option<Stdenvs>,
outpath_diff: Option<OutPathDiff>, outpath_diff: Option<OutPathDiff>,
changed_paths: Option<Vec<String>>, changed_paths: Option<Vec<String>>,
@ -54,7 +50,6 @@ impl<'a> NixpkgsStrategy<'a> {
repo: &'a Repository, repo: &'a Repository,
gists: &'a Gists, gists: &'a Gists,
nix: Nix, nix: Nix,
tag_paths: &'a HashMap<String, Vec<String>>,
) -> NixpkgsStrategy<'a> { ) -> NixpkgsStrategy<'a> {
Self { Self {
job, job,
@ -64,7 +59,6 @@ impl<'a> NixpkgsStrategy<'a> {
repo, repo,
gists, gists,
nix, nix,
tag_paths,
stdenv_diff: None, stdenv_diff: None,
outpath_diff: None, outpath_diff: None,
changed_paths: 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) { fn check_stdenvs_before(&mut self, dir: &Path) {
let mut stdenvs = Stdenvs::new(self.nix.clone(), dir.to_path_buf()); let mut stdenvs = Stdenvs::new(self.nix.clone(), dir.to_path_buf());
stdenvs.identify_before(); stdenvs.identify_before();
@ -402,7 +380,6 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
.files_changed_from_head(&self.job.pr.head_sha) .files_changed_from_head(&self.job.pr.head_sha)
.unwrap_or_else(|_| vec![]); .unwrap_or_else(|_| vec![]);
self.changed_paths = Some(changed_paths); self.changed_paths = Some(changed_paths);
self.tag_from_paths();
self.touched_packages = Some(parse_commit_messages( self.touched_packages = Some(parse_commit_messages(
&co.commit_messages_from_head(&self.job.pr.head_sha) &co.commit_messages_from_head(&self.job.pr.head_sha)

View file

@ -29,7 +29,6 @@ pub struct EvaluationWorker<E> {
acl: ACL, acl: ACL,
identity: String, identity: String,
events: E, events: E,
tag_paths: HashMap<String, Vec<String>>,
} }
/// Creates a finished github check, indicating that the ofborg eval started. /// Creates a finished github check, indicating that the ofborg eval started.
@ -59,7 +58,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
acl: ACL, acl: ACL,
identity: String, identity: String,
events: E, events: E,
tag_paths: HashMap<String, Vec<String>>,
) -> EvaluationWorker<E> { ) -> EvaluationWorker<E> {
EvaluationWorker { EvaluationWorker {
cloner, cloner,
@ -69,7 +67,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
acl, acl,
identity, identity,
events, events,
tag_paths,
} }
} }
} }
@ -116,7 +113,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
&self.acl, &self.acl,
&mut self.events, &mut self.events,
&self.identity, &self.identity,
&self.tag_paths,
&self.cloner, &self.cloner,
job, job,
) )
@ -132,7 +128,6 @@ struct OneEval<'a, E> {
acl: &'a ACL, acl: &'a ACL,
events: &'a mut E, events: &'a mut E,
identity: &'a str, identity: &'a str,
tag_paths: &'a HashMap<String, Vec<String>>,
cloner: &'a checkout::CachedCloner, cloner: &'a checkout::CachedCloner,
job: &'a evaluationjob::EvaluationJob, job: &'a evaluationjob::EvaluationJob,
} }
@ -146,7 +141,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
acl: &'a ACL, acl: &'a ACL,
events: &'a mut E, events: &'a mut E,
identity: &'a str, identity: &'a str,
tag_paths: &'a HashMap<String, Vec<String>>,
cloner: &'a checkout::CachedCloner, cloner: &'a checkout::CachedCloner,
job: &'a evaluationjob::EvaluationJob, job: &'a evaluationjob::EvaluationJob,
) -> OneEval<'a, E> { ) -> OneEval<'a, E> {
@ -161,7 +155,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
acl, acl,
events, events,
identity, identity,
tag_paths,
cloner, cloner,
job, job,
} }
@ -320,7 +313,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
&repo, &repo,
&self.gists, &self.gists,
self.nix.clone(), self.nix.clone(),
&self.tag_paths,
)) ))
} else { } else {
Box::new(eval::GenericStrategy::new()) Box::new(eval::GenericStrategy::new())