aboutsummaryrefslogtreecommitdiff
path: root/.run/src/bin/ci.rs
diff options
context:
space:
mode:
Diffstat (limited to '.run/src/bin/ci.rs')
-rw-r--r--.run/src/bin/ci.rs49
1 files changed, 37 insertions, 12 deletions
diff --git a/.run/src/bin/ci.rs b/.run/src/bin/ci.rs
index 2527ece..4b6f973 100644
--- a/.run/src/bin/ci.rs
+++ b/.run/src/bin/ci.rs
@@ -1,6 +1,7 @@
use std::io::Write as _;
use std::process::exit;
+use arg_picker::{Picker, macros::arg};
use tools::{
cargo_tomls, crate_name_from, eprintln_cargo_style, println_cargo_style, run_cmd, run_parallel,
};
@@ -35,19 +36,20 @@ fn main() {
let _ = colored::control::set_virtual_terminal(true);
println!("{}", include_str!("../../../docs/res/ci_banner.txt"));
- let args: Vec<String> = std::env::args().collect();
+ let (auto_yes, dirty, test_docs, refresh_docs, test_codes, help) = Picker::from_args()
+ .pick_or_default(&arg![yes: bool, 'y'])
+ .pick_or_default(&arg![dirty: bool])
+ .pick_or_default(&arg![test_docs: bool])
+ .pick_or_default(&arg![refresh_docs: bool])
+ .pick_or_default(&arg![test_codes: bool])
+ .pick_or_default(&arg![help: bool, 'h'])
+ .unwrap();
- if args.iter().any(|a| a == "-h" || a == "--help") {
+ if help {
print_help();
return;
}
- let auto_yes = args.iter().any(|a| a == "-y");
- let dirty = args.iter().any(|a| a == "--dirty");
-
- let test_docs = args.iter().any(|a| a == "--test-docs");
- let refresh_docs = args.iter().any(|a| a == "--refresh-docs");
- let test_codes = args.iter().any(|a| a == "--test-codes");
let any_specified = test_docs || refresh_docs || test_codes;
let run_all = !any_specified;
@@ -123,14 +125,31 @@ fn ci(test_docs: bool, test_codes: bool, run_all: bool) -> Result<(), i32> {
}
if run_all || test_docs {
- println_cargo_style!("Phase: Test all examples");
- test_examples()?;
+ let mut exit_code = 0;
println_cargo_style!("Phase: Verify all *.md document code blocks are compilable");
- test_docs_code_blocks()?;
+ if let Err(code) = test_docs_code_blocks() {
+ exit_code = exit_code.max(code);
+ }
+
+ println_cargo_style!("Phase: Test all examples");
+ if let Err(code) = test_examples() {
+ exit_code = exit_code.max(code);
+ }
println_cargo_style!("Phase: Check all documentation is up to date");
- docs_refresh()?;
+ if let Err(code) = docs_refresh() {
+ exit_code = exit_code.max(code);
+ }
+
+ println_cargo_style!("Phase: Try Build API docs");
+ if let Err(code) = deploy_api_docs() {
+ exit_code = exit_code.max(code);
+ }
+
+ if exit_code != 0 {
+ return Err(exit_code);
+ }
}
run_cmd!("git add --renormalize .")?;
@@ -211,6 +230,12 @@ fn test_all() -> Result<(), i32> {
run_parallel("Testing", tasks)
}
+fn deploy_api_docs() -> Result<(), i32> {
+ run_cmd!(
+ "cargo run --manifest-path .run/Cargo.toml --color always --bin deploy-api-docs -- --docsrs"
+ )
+}
+
fn docs_refresh() -> Result<(), i32> {
println_cargo_style!("Refresh: document at `./docs/`");