From 3cd6c1c10366d7cbc5823944da8c85d444b64d0d Mon Sep 17 00:00:00 2001 From: Adam Bergmark Date: Sat, 25 Dec 2021 20:57:02 +0100 Subject: [PATCH] commenter outdated: Also check manually disabled packages --- CURATORS.md | 21 ++++++++++++ etc/commenter/src/lib.rs | 69 +++++++++++++++++++++++++++++++++------- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/CURATORS.md b/CURATORS.md index 4cbe245f..0a34d4ed 100644 --- a/CURATORS.md +++ b/CURATORS.md @@ -488,6 +488,27 @@ commenter clear Repeat the second command until no updates are made to build-constraints.yaml. +#### Checking for new releases + +Run `stack update` before doing this. + +`commenter outdated` looks through all bounds issues and library +compilation failures and compares the marked version with the latest hackage release. Example output is + +``` +Fin mismatch, manual: 0.2.8.0, hackage: 0.2.9.0 +aeson mismatch, auto: 1.5.6.0, hackage: 2.0.2.0 +``` + +where "manual" means the bound was added manually by a curator, +perhaps due to a compilation failure so we could try re-enabling the +package. "auto" means it's part of the sections generated by +`commenter`, to update that run the `Re-enabling` step as documented +above. + +`outdated` only finds packages that are in the auto generated +sections, or that are of the form `- package < 0 # $version`. + #### Notes * Please make sure to separate bounds issues from compilation failures/test run failures, as we cannot verify that a package builds or that tests pass without running the build! diff --git a/etc/commenter/src/lib.rs b/etc/commenter/src/lib.rs index e9902ed9..98766492 100644 --- a/etc/commenter/src/lib.rs +++ b/etc/commenter/src/lib.rs @@ -23,29 +23,52 @@ pub fn add(lib: Vec, test: Vec, bench: Vec) { }); lines.sort(); lines - }) + }); +} + +enum VersionTag { + Manual(String), + Auto(String), +} + +impl VersionTag { + + fn tag(&self) -> &'static str { + match self { + VersionTag::Manual(_) => "manual", + VersionTag::Auto(_) => "auto", + } + } + + fn version(&self) -> &str { + match self { + VersionTag::Manual(s) => &s, + VersionTag::Auto(s) => &s, + } + } } pub fn outdated() { - let mut all = vec![]; - handle(false, |_loc, lines| { + let mut all: Vec = vec![]; + let disabled = handle(false, |_loc, lines| { all.extend(lines); vec![] }); - let mut map = BTreeMap::new(); + let mut map: BTreeMap = BTreeMap::new(); + for DisabledPackage { package, version } in disabled { + map.insert(package, VersionTag::Manual(version)); + } let mut support: BTreeMap<(String, String), BTreeSet<(String, String)>> = BTreeMap::new(); for v in all.into_iter() { let caps = regex!("tried ([^ ]+)-([^,-]+),").captures(&v).unwrap(); let package = caps.get(1).unwrap().as_str().to_owned(); let version = caps.get(2).unwrap().as_str().to_owned(); - map.insert(package.clone(), version.clone()); + map.insert(package.clone(), VersionTag::Auto(version.clone())); if let Some(caps) = regex!("does not support: ([^ ]+)-([^-]+)").captures(&v) { let dep_package = caps.get(1).unwrap().as_str().to_owned(); let dep_version = caps.get(2).unwrap().as_str().to_owned(); - let entry = support - .entry((dep_package, dep_version)) - .or_default(); + let entry = support.entry((dep_package, dep_version)).or_default(); entry.insert((package, version)); } } @@ -59,10 +82,10 @@ pub fn outdated() { } i += 1; let latest = latest_version(&package); - if version != latest { + if version.version() != latest { println!( - "{} mismatch, snapshot: {}, hackage: {}", - package, version, latest + "{} mismatch, {}: {}, hackage: {}", + package, version.tag(), version.version(), latest ); } } @@ -112,16 +135,36 @@ enum State { Done, } -fn handle(write: bool, mut f: F) +struct DisabledPackage { + package: String, + version: String, +} + +fn parse_disabled_package(s: &str) -> Option { + if let Some(caps) = regex!(r#"- *([^ ]+) < *0 *# *([\d.]+)"#).captures(s) { + let package = caps.get(1).unwrap().as_str().to_owned(); + let version = caps.get(2).unwrap().as_str().to_owned(); + Some(DisabledPackage { package, version }) + } else { + None + } +} + +fn handle(write: bool, mut f: F) -> Vec where F: FnMut(Location, Vec) -> Vec, { let path = "build-constraints.yaml"; let mut new_lines: Vec = vec![]; + let mut disabled_packages: Vec = vec![]; let mut state = State::LookingForLibBounds; let mut buf = vec![]; for line in read_lines(path).map(|s| s.unwrap()) { + if let Some(disabled_package) = parse_disabled_package(&line) { + disabled_packages.push(disabled_package); + } + match state { State::LookingForLibBounds => { if line == r#" "Library and exe bounds failures":"# { @@ -189,6 +232,8 @@ where } file.flush().unwrap(); } + + disabled_packages } enum Location {