-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
status = [ | ||
"Tests (stable)", | ||
"Tests (beta)", | ||
] | ||
status = [ "Rust" ] | ||
delete_merged_branches = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "xtask" | ||
version = "0.0.0" | ||
publish = false | ||
authors = ["Aleksey Kladov <[email protected]>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
xaction = "0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use std::env; | ||
|
||
use xaction::{cargo_toml, cmd, git, section, Result}; | ||
|
||
fn main() { | ||
if let Err(err) = try_main() { | ||
eprintln!("error: {}", err); | ||
std::process::exit(1) | ||
} | ||
} | ||
|
||
fn try_main() -> Result<()> { | ||
let subcommand = std::env::args().nth(1); | ||
match subcommand { | ||
Some(it) if it == "ci" => (), | ||
_ => { | ||
print_usage(); | ||
Err("invalid arguments")? | ||
} | ||
} | ||
|
||
let cargo_toml = cargo_toml()?; | ||
|
||
{ | ||
let _s = section("BUILD"); | ||
cmd!("cargo test --workspace --no-run").run()?; | ||
} | ||
|
||
{ | ||
let _s = section("TEST"); | ||
cmd!("cargo test --workspace -- --nocapture").run()?; | ||
} | ||
|
||
let version = cargo_toml.version()?; | ||
let tag = format!("v{}", version); | ||
|
||
let dry_run = | ||
env::var("CI").is_err() || git::has_tag(&tag)? || git::current_branch()? != "master"; | ||
xaction::set_dry_run(dry_run); | ||
|
||
{ | ||
let _s = section("PUBLISH"); | ||
cargo_toml.publish()?; | ||
git::tag(&tag)?; | ||
git::push_tags()?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn print_usage() { | ||
eprintln!( | ||
"\ | ||
Usage: cargo run -p xtask <SUBCOMMAND> | ||
SUBCOMMANDS: | ||
ci | ||
" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use xaction::cmd; | ||
|
||
#[test] | ||
fn test_formatting() { | ||
cmd!("cargo fmt --all -- --check").run().unwrap() | ||
} |