mirror of
https://github.com/ratatui/ratatui.git
synced 2025-09-26 20:40:44 +00:00
chore(xtask): check lints for only library targets (#1531)
Makes it possible to filter workspace packages by their targets. (e.g. when we want to retrieve all the binary targets / examples, etc.)
This commit is contained in:
parent
21e62d84c2
commit
d201b8e5dd
@ -6,7 +6,7 @@
|
||||
|
||||
use std::{fmt::Debug, io, process::Output, vec};
|
||||
|
||||
use cargo_metadata::MetadataCommand;
|
||||
use cargo_metadata::{MetadataCommand, TargetKind};
|
||||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
use clap_verbosity_flag::{InfoLevel, Verbosity};
|
||||
use color_eyre::{eyre::Context, Result};
|
||||
@ -183,14 +183,14 @@ fn check() -> Result<()> {
|
||||
|
||||
/// Run cargo-rdme to check if README.md is up-to-date with the library documentation
|
||||
fn check_readme() -> Result<()> {
|
||||
for package in get_workspace_packages()? {
|
||||
for package in workspace_packages(TargetKind::Lib)? {
|
||||
run_cargo(vec!["rdme", "--workspace-project", &package, "--check"])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fix_readme() -> Result<()> {
|
||||
for package in get_workspace_packages()? {
|
||||
for package in workspace_packages(TargetKind::Lib)? {
|
||||
run_cargo(vec!["rdme", "--workspace-project", &package])?;
|
||||
}
|
||||
Ok(())
|
||||
@ -250,21 +250,24 @@ fn fix_clippy() -> Result<()> {
|
||||
|
||||
/// Check that docs build without errors using flags for docs.rs
|
||||
fn lint_docs() -> Result<()> {
|
||||
for package in get_workspace_packages()? {
|
||||
for package in workspace_packages(TargetKind::Lib)? {
|
||||
run_cargo_nightly(vec!["docs-rs", "--package", &package])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_workspace_packages() -> Result<Vec<String>> {
|
||||
/// Return the available packages in the workspace
|
||||
fn workspace_packages(kind: TargetKind) -> Result<Vec<String>> {
|
||||
let meta = MetadataCommand::new()
|
||||
.exec()
|
||||
.wrap_err("failed to get cargo metadata")?;
|
||||
Ok(meta
|
||||
.workspace_default_packages()
|
||||
let packages = meta
|
||||
.workspace_packages()
|
||||
.iter()
|
||||
.filter(|v| v.targets.iter().any(|t| t.kind.contains(&kind)))
|
||||
.map(|v| v.name.clone())
|
||||
.collect())
|
||||
.collect();
|
||||
Ok(packages)
|
||||
}
|
||||
|
||||
/// Lint formatting issues in the project
|
||||
|
Loading…
x
Reference in New Issue
Block a user