Merge pull request #6368 from commercialhaskell/outdated-v2

commenter outdated: Also check manually disabled packages
This commit is contained in:
Adam Bergmark 2021-12-25 21:01:19 +01:00 committed by GitHub
commit cbffdf9e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 12 deletions

View File

@ -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!

View File

@ -23,29 +23,52 @@ pub fn add(lib: Vec<String>, test: Vec<String>, bench: Vec<String>) {
});
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<String> = vec![];
let disabled = handle(false, |_loc, lines| {
all.extend(lines);
vec![]
});
let mut map = BTreeMap::new();
let mut map: BTreeMap<String, VersionTag> = 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<F>(write: bool, mut f: F)
struct DisabledPackage {
package: String,
version: String,
}
fn parse_disabled_package(s: &str) -> Option<DisabledPackage> {
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<F>(write: bool, mut f: F) -> Vec<DisabledPackage>
where
F: FnMut(Location, Vec<String>) -> Vec<String>,
{
let path = "build-constraints.yaml";
let mut new_lines: Vec<String> = vec![];
let mut disabled_packages: Vec<DisabledPackage> = 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 {