Skip to content

Commit

Permalink
tools: add dev as the entrypoint of check tools (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben1009 authored Jan 9, 2024
1 parent f8f0af1 commit d77deba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@ skip_crate_env_info = true
min_version = "0.36.10"

[tasks.install-nextest]
category = "Misc"
description = "install cargo-nextest"
install_crate = { crate_name = "cargo-nextest", version = "0.9.61", binary = "cargo", test_arg = [
"nextest",
"--help",
] }

[tasks.install-llvm-cov]
category = "Misc"
description = "install cargo-llvm-cov"
install_crate = { crate_name = "cargo-llvm-cov", version = "0.5.35", binary = "cargo", test_arg = [
"llvm-cov",
"--help",
] }

[tasks.clean]
category = "Dev - check"
description = "Run cargo clean"
command = "cargo"
args = ["clean"]

[tasks.check-clippy]
category = "Dev - check"
description = "Run full cargo clippy check"
script = """
#!/usr/bin/env bash
Expand All @@ -38,11 +42,13 @@ cargo clippy --workspace --all-features --all-targets -- -D warnings
"""

[tasks.check-fmt]
category = "Dev - check"
description = "Run cargo fmt check"
command = "cargo"
args = ["fmt", "--all"]

[tasks.check-typos]
category = "Dev - check"
description = "Run cargo typos-cli check"
install_crate = { version = "1.16.20", crate_name = "typos-cli", binary = "typos", test_arg = [
"--help",
Expand All @@ -58,6 +64,7 @@ fi
"""

[tasks.check-hakari]
category = "Dev - check"
description = "Run cargo hakari check and attempt to fix"
install_crate = { version = "0.9.27", crate_name = "cargo-hakari", binary = "cargo", test_arg = [
"hakari",
Expand All @@ -71,6 +78,7 @@ cargo hakari verify > /dev/null
"""

[tasks.check-machete]
category = "Dev - check"
description = "Run cargo machete check"
install_crate = { version = "0.6.0", crate_name = "cargo-machete", binary = "cargo", test_arg = [
"machete",
Expand All @@ -84,6 +92,7 @@ cargo machete
"""

[tasks.check-dep-sort]
category = "Dev - check"
description = "Run cargo sort check and attempt to fix"
install_crate = { version = "1.0.9", crate_name = "cargo-sort", binary = "cargo", test_arg = [
"sort",
Expand All @@ -96,6 +105,7 @@ script = """
"""

[tasks.test-cov]
category = "Dev - check"
description = "Run unit tests and report coverage"
dependencies = ["install-llvm-cov", "install-nextest"]
script = """
Expand All @@ -106,6 +116,7 @@ cargo llvm-cov nextest --workspace --all-features --all-targets --html
"""

[tasks.test]
category = "Dev - check"
description = "Run unit tests"
dependencies = ["install-nextest"]
script = """
Expand All @@ -116,6 +127,8 @@ cargo nextest run --workspace --all-features --all-targets
"""

[tasks.check]
category = "Dev - check"
description = "Run all checks one by one"
dependencies = [
"check-fmt",
"check-dep-sort",
Expand Down
18 changes: 18 additions & 0 deletions dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

if [ -z "$(which cargo-binstall)" ]; then
echo "Installing cargo-binstall..."
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
fi

if [ -z "$(which cargo-make)" ]; then
echo "Installing cargo-make..."
cargo binstall cargo-make
fi

if [ $# -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
cargo make --list-all-steps --hide-uninteresting
exit 0
fi

cargo make "$@"

0 comments on commit d77deba

Please sign in to comment.