From 6adac57ee96f34e65354a449f70bad2b6e5b08dd Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Fri, 19 Mar 2021 06:58:07 +1000 Subject: [PATCH] ofborg: remove `tag_paths` --- ofborg/src/bin/mass-rebuilder.rs | 1 - ofborg/src/config.rs | 1 - ofborg/src/tagger.rs | 95 -------------------------------- ofborg/src/tasks/eval/nixpkgs.rs | 25 +-------- ofborg/src/tasks/evaluate.rs | 8 --- 5 files changed, 1 insertion(+), 129 deletions(-) diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index 3919703..bae6c7b 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -62,7 +62,6 @@ fn main() -> Result<(), Box> { cfg.acl(), cfg.runner.identity.clone(), events, - cfg.tag_paths.clone().unwrap(), ), easyamqp::ConsumeConfig { queue: queue_name.clone(), diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index f5b4327..f9f8fbc 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -22,7 +22,6 @@ pub struct Config { pub github: Option, pub github_app: Option, pub log_storage: Option, - pub tag_paths: Option>>, } #[derive(Serialize, Deserialize, Debug)] diff --git a/ofborg/src/tagger.rs b/ofborg/src/tagger.rs index 8ecdc7a..67011a0 100644 --- a/ofborg/src/tagger.rs +++ b/ofborg/src/tagger.rs @@ -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>, - selected: Vec, -} - -impl PathsTagger { - pub fn new(tags_and_criteria: HashMap>) -> PathsTagger { - PathsTagger { - possible: tags_and_criteria, - selected: vec![], - } - } - - pub fn path_changed(&mut self, path: &str) { - let mut tags_to_add: Vec = 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 { - self.selected.clone() - } - - pub fn tags_to_remove(&self) -> Vec { - let mut remove: Vec = 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, selected: Vec, @@ -856,56 +813,4 @@ mod tests { ] ); } - - #[test] - pub fn test_files_changed_list() { - let mut criteria: HashMap> = 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()] - ); - } - } } diff --git a/ofborg/src/tasks/eval/nixpkgs.rs b/ofborg/src/tasks/eval/nixpkgs.rs index 61a5972..2714abe 100644 --- a/ofborg/src/tasks/eval/nixpkgs.rs +++ b/ofborg/src/tasks/eval/nixpkgs.rs @@ -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>, stdenv_diff: Option, outpath_diff: Option, changed_paths: Option>, @@ -54,7 +50,6 @@ impl<'a> NixpkgsStrategy<'a> { repo: &'a Repository, gists: &'a Gists, nix: Nix, - tag_paths: &'a HashMap>, ) -> 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) diff --git a/ofborg/src/tasks/evaluate.rs b/ofborg/src/tasks/evaluate.rs index 009e9ec..5bdcbf4 100644 --- a/ofborg/src/tasks/evaluate.rs +++ b/ofborg/src/tasks/evaluate.rs @@ -29,7 +29,6 @@ pub struct EvaluationWorker { acl: ACL, identity: String, events: E, - tag_paths: HashMap>, } /// Creates a finished github check, indicating that the ofborg eval started. @@ -59,7 +58,6 @@ impl EvaluationWorker { acl: ACL, identity: String, events: E, - tag_paths: HashMap>, ) -> EvaluationWorker { EvaluationWorker { cloner, @@ -69,7 +67,6 @@ impl EvaluationWorker { acl, identity, events, - tag_paths, } } } @@ -116,7 +113,6 @@ impl worker::SimpleWorker for EvaluationWorker &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>, 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>, 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())