-
Notifications
You must be signed in to change notification settings - Fork 45
/
qualify.rs
executable file
·104 lines (91 loc) · 3.39 KB
/
qualify.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! yansi = "0.5"
//! ```
extern crate yansi;
use std::process::Command;
macro_rules! run_command {
($cmd:expr , $($arg:expr),*) => (
let mut command = command!($cmd, $($arg),*);
let mut child = command.spawn().unwrap();
let status = child.wait().unwrap();
if !status.success() {
print!("> {}",yansi::Paint::red("qualify terminates due to error"));
std::process::exit(-1);
}
)
}
macro_rules! command {
($cmd:expr , $($arg:expr),*) => (
{
print!("\n> {}",yansi::Paint::yellow($cmd));
let mut command = Command::new($cmd);
$(
print!(" {}",yansi::Paint::yellow(&$arg));
command.arg($arg);
)*
print!("\n");
command
}
)
}
fn run_script(s: &str) {
let mut path = std::path::PathBuf::from(std::env::var("CARGO_SCRIPT_BASE_PATH").unwrap());
path.push(s);
let script = path.to_string_lossy().to_owned().to_string();
run_command!("cargo", "script", script);
}
fn main() {
println!("Qualify flexi_logger");
// format
run_command!("cargo", "fmt");
// Build in important variants
std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo", "+1.66.1", "build", "--no-default-features");
run_command!("cargo", "+1.66.1", "build", "--all-features");
std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo", "build");
run_command!("cargo", "build", "--no-default-features");
#[rustfmt::skip]
run_command!("cargo", "build", "--no-default-features", "--features=is-terminal");
run_command!("cargo", "build", "--all-features");
run_command!("cargo", "build", "--release");
run_command!("cargo", "build", "--release", "--all-features");
// Clippy in important variants
run_command!("cargo", "clippy", "--", "-D", "warnings");
run_command!("cargo", "clippy", "--all-features", "--", "-D", "warnings");
#[rustfmt::skip]
run_command!("cargo", "+nightly", "clippy", "--all-targets", "--all-features", "--", "-D", "warnings");
// Run tests in important variants
run_command!("cargo", "+1.66.1", "test", "--all-features");
run_command!("cargo", "test", "--release", "--all-features");
run_command!("cargo", "test", "--no-default-features");
run_command!("cargo", "test", "--release");
#[rustfmt::skip]
run_command!("cargo", "test", "--release", "--features", "specfile_without_notification");
// doc
run_command!("cargo", "+nightly", "test", "--all-features", "--doc");
#[rustfmt::skip]
run_command!("cargo", "+nightly", "doc", "--all-features", "--no-deps", "--open");
// check version consistency
run_command!("cargo", "run", "--example", "version_numbers");
// check git status
let mut cmd = command!("git", "status", "-s");
let child = cmd.stdout(std::process::Stdio::piped()).spawn().unwrap();
let output = child.wait_with_output().unwrap();
if output.stdout.len() > 0 {
print!("> {}", yansi::Paint::red("there are unsubmitted files"));
std::process::exit(-1);
}
// say goodbye
println!(
"\n\
> all done :-) Looks like you're ready to\n\
- \"git push\"\n\
- check if the github actions were successful, and then\n\
- \"cargo publish\""
);
// cleanup
run_script("cleanup");
}