Add xtask check

This commit is contained in:
Ajeet D'Souza 2021-10-08 21:03:28 +05:30
parent 454bededc1
commit 54dd5dd1dd
3 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,5 @@
//! Syntax checking for auto-generated shell completions. //! Syntax checking for auto-generated shell completions.
#![cfg(feature = "nix_tests")] #![cfg(feature = "nix")]
use assert_cmd::Command; use assert_cmd::Command;

View File

@ -1,5 +1,5 @@
//! Syntax checking for manpages. //! Syntax checking for manpages.
#![cfg(feature = "nix_tests")] #![cfg(feature = "nix")]
use assert_cmd::Command; use assert_cmd::Command;

View File

@ -12,6 +12,8 @@ fn main() -> Result<()> {
let app = App::parse(); let app = App::parse();
match app { match app {
App::Audit => run_audit(&[] as &[&str])?, App::Audit => run_audit(&[] as &[&str])?,
App::Check => run_check(&[] as &[&str])?,
App::Clippy => run_clippy(&[] as &[&str])?,
App::CI => run_ci(nix_enabled)?, App::CI => run_ci(nix_enabled)?,
App::Fmt => run_fmt(&[] as &[&str])?, App::Fmt => run_fmt(&[] as &[&str])?,
App::Markdownlint => run_markdownlint()?, App::Markdownlint => run_markdownlint()?,
@ -24,7 +26,9 @@ fn main() -> Result<()> {
#[derive(Clap)] #[derive(Clap)]
enum App { enum App {
Audit, Audit,
Check,
CI, CI,
Clippy,
Fmt, Fmt,
Markdownlint, Markdownlint,
Test { args: Vec<String> }, Test { args: Vec<String> },
@ -49,6 +53,10 @@ fn run_audit<S: AsRef<OsStr>>(args: &[S]) -> Result<()> {
Command::new("cargo").args(&["audit", "--deny=warnings"]).args(args)._run() Command::new("cargo").args(&["audit", "--deny=warnings"]).args(args)._run()
} }
fn run_check<S: AsRef<OsStr>>(args: &[S]) -> Result<()> {
Command::new("cargo").args(&["check", "--all-features", "--all-targets", "--workspace"]).args(args)._run()
}
fn run_clippy<S: AsRef<OsStr>>(args: &[S]) -> Result<()> { fn run_clippy<S: AsRef<OsStr>>(args: &[S]) -> Result<()> {
Command::new("cargo").args(&["clippy", "--all-features", "--all-targets"]).args(args)._run() Command::new("cargo").args(&["clippy", "--all-features", "--all-targets"]).args(args)._run()
} }
@ -56,6 +64,7 @@ fn run_clippy<S: AsRef<OsStr>>(args: &[S]) -> Result<()> {
fn run_ci(nix_enabled: bool) -> Result<()> { fn run_ci(nix_enabled: bool) -> Result<()> {
let color = if env::var_os("CI").is_some() { "--color=always" } else { "--color=auto" }; let color = if env::var_os("CI").is_some() { "--color=always" } else { "--color=auto" };
run_fmt(&["--check", color, "--files-with-diff"])?; run_fmt(&["--check", color, "--files-with-diff"])?;
run_check(&[color])?;
run_clippy(&[color])?; run_clippy(&[color])?;
run_test(nix_enabled, &[color, "--no-fail-fast"])?; run_test(nix_enabled, &[color, "--no-fail-fast"])?;
if nix_enabled { if nix_enabled {