Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move lints outside infra check #1219

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions crates/infra/cli/src/commands/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use infra_utils::terminal::Terminal;
use rayon::iter::{ParallelBridge, ParallelIterator};
use strum::IntoEnumIterator;

use crate::toolchains::mkdocs::Mkdocs;
use crate::toolchains::wasm::WasmPackage;
use crate::utils::{ClapExtensions, OrderedCommand};

Expand All @@ -26,12 +25,8 @@ impl CheckController {
enum CheckCommand {
/// Run 'cargo check' for all crates, features, and targets.
Cargo,
/// Run `cargo doc` to generate Rustdoc documentation and check for any broken links.
Rustdoc,
/// Check NPM packages for any outdated codegen steps.
Npm,
/// Check mkdocs documentation for any build issues or broken links.
Mkdocs,
}

impl OrderedCommand for CheckCommand {
Expand All @@ -40,34 +35,19 @@ impl OrderedCommand for CheckCommand {

match self {
CheckCommand::Cargo => check_cargo(),
CheckCommand::Rustdoc => check_rustdoc(),
CheckCommand::Npm => check_npm(),
CheckCommand::Mkdocs => check_mkdocs(),
};

Ok(())
}
}

fn check_cargo() {
// 'cargo clippy' will run both 'cargo check', and 'clippy' lints:
Command::new("cargo")
.arg("clippy")
.arg("check")
.flag("--workspace")
.flag("--all-features")
.flag("--all-targets")
.flag("--no-deps")
.add_build_rustflags()
.run();
}

fn check_rustdoc() {
Command::new("cargo")
.arg("doc")
.flag("--workspace")
.flag("--all-features")
.flag("--no-deps")
.flag("--document-private-items")
.add_build_rustflags()
.run();
}
Expand All @@ -77,7 +57,3 @@ fn check_npm() {
.par_bridge()
.for_each(|package| package.build().unwrap());
}

fn check_mkdocs() {
Mkdocs::check();
}
37 changes: 37 additions & 0 deletions crates/infra/cli/src/commands/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use std::path::Path;

use anyhow::Result;
use clap::{Parser, ValueEnum};
use infra_utils::cargo::CargoWorkspaceCommands;
use infra_utils::commands::Command;
use infra_utils::github::GitHub;
use infra_utils::paths::{FileWalker, PathExtensions};
use infra_utils::terminal::Terminal;

use crate::toolchains::mkdocs::Mkdocs;
use crate::toolchains::pipenv::PipEnv;
use crate::utils::{ClapExtensions, OrderedCommand};

Expand All @@ -24,6 +26,12 @@ impl LintController {

#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)]
enum LintCommand {
/// Run `cargo clippy` to check for any Rust lints.
Clippy,
/// Run `cargo doc` to generate Rustdoc documentation and check for any broken links.
Rustdoc,
/// Check mkdocs documentation for any build issues or broken links.
Mkdocs,
/// Check for spelling issues in Markdown files.
Cspell,
/// Format all non-Rust source files.
Expand All @@ -49,6 +57,9 @@ impl OrderedCommand for LintCommand {
Terminal::step(format!("lint {name}", name = self.clap_name()));

match self {
LintCommand::Clippy => run_clippy(),
LintCommand::Rustdoc => run_rustdoc(),
LintCommand::Mkdocs => run_mkdocs(),
LintCommand::Cspell => run_cspell(),
LintCommand::Prettier => run_prettier(),
LintCommand::MarkdownLinkCheck => run_markdown_link_check()?,
Expand All @@ -64,6 +75,32 @@ impl OrderedCommand for LintCommand {
}
}

fn run_clippy() {
Command::new("cargo")
.arg("clippy")
.flag("--workspace")
.flag("--all-features")
.flag("--all-targets")
.flag("--no-deps")
.add_build_rustflags()
.run();
}

fn run_rustdoc() {
Command::new("cargo")
.arg("doc")
.flag("--workspace")
.flag("--all-features")
.flag("--no-deps")
.flag("--document-private-items")
.add_build_rustflags()
.run();
}

fn run_mkdocs() {
Mkdocs::check();
}

fn run_cspell() {
Command::new("cspell")
.arg("lint")
Expand Down
Loading