mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat(workflow) update helper cargo-check scripts (#892)
They can now run check, clippy, fmt, or test. They default to running clippy, fmt, and test in that order. The cargo sub-commands to run can be specified as arguments to the script. Only the 4 supported sub-commands are allowed. Signed-off-by: Chip Reed <chip@chip.sh>
This commit is contained in:
@@ -1,14 +1,59 @@
|
||||
Write-Output "Checking tauri crates"
|
||||
#!/usr/bin/env pwsh
|
||||
# note: you can pass in the cargo sub-commands used to check manually.
|
||||
# allowed commands: check, clippy, fmt, test
|
||||
# default: clippy, fmt, test
|
||||
|
||||
# set the script arguments if none are found
|
||||
if(-Not $args) {
|
||||
$args=@("clippy","fmt","test")
|
||||
}
|
||||
|
||||
$commands=@("clippy","test")
|
||||
$features=@("no-server","embedded-server")
|
||||
foreach ($command in $commands) {
|
||||
foreach ($feature in $features) {
|
||||
Write-Output "[$command][$feature] checking tauri"
|
||||
cargo $command --manifest-path tauri/Cargo.toml --all-targets --features "$feature,cli,all-api"
|
||||
# exit the script early if the last command returned an error
|
||||
function check_error {
|
||||
if($LASTEXITCODE -ne 0 ) {
|
||||
Exit $LASTEXITCODE
|
||||
}
|
||||
}
|
||||
|
||||
# run n+1 times, where n is the amount of mutually exclusive features.
|
||||
# the extra run is for all the crates without mutually exclusive features.
|
||||
# as many features as possible are enabled at for each command
|
||||
function mutex {
|
||||
$command, $_args = $args
|
||||
|
||||
foreach ($feature in @("no-server","embedded-server")) {
|
||||
Write-Output "[$command][$feature] tauri"
|
||||
cargo $command --manifest-path tauri/Cargo.toml --all-targets --features "$feature,cli,all-api" $_args
|
||||
check_error
|
||||
}
|
||||
|
||||
Write-Output "[$command] checking other crates"
|
||||
cargo $command --workspace --exclude tauri --all-targets --all-features
|
||||
Write-Output "[$command] other crates"
|
||||
cargo $command --workspace --exclude tauri --all-targets --all-features $_args
|
||||
check_error
|
||||
}
|
||||
|
||||
foreach ($command in $args) {
|
||||
Switch ($command) {
|
||||
"check" {
|
||||
mutex check
|
||||
break
|
||||
}
|
||||
"test" {
|
||||
mutex test
|
||||
break
|
||||
}
|
||||
"clippy" {
|
||||
mutex clippy "--" -D warnings
|
||||
break
|
||||
}
|
||||
"fmt" {
|
||||
Write-Output "[$command] checking formatting"
|
||||
cargo fmt "--" --check
|
||||
check_error
|
||||
}
|
||||
default {
|
||||
Write-Output "[cargo-check.ps1] Unknown cargo sub-command: $command"
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,47 @@
|
||||
#!/usr/bin/env sh
|
||||
# note: you can pass in the cargo sub-commands used to check manually.
|
||||
# allowed commands: check, clippy, fmt, test
|
||||
# default: clippy, fmt, test
|
||||
|
||||
# exit the script early if any of the commands return an error
|
||||
set -e
|
||||
|
||||
echo "Checking tauri crates"
|
||||
# set the script arguments if none are found
|
||||
if [ -z "$*" ]; then
|
||||
set -- "clippy" "fmt" "test"
|
||||
fi
|
||||
|
||||
for command in "clippy" "test"
|
||||
do
|
||||
for feature in "no-server" "embedded-server"
|
||||
do
|
||||
echo "[$command][$feature] checking tauri"
|
||||
cargo "$command" --manifest-path tauri/Cargo.toml --all-targets --features "$feature,cli,all-api"
|
||||
# run n+1 times, where n is the amount of mutually exclusive features.
|
||||
# the extra run is for all the crates without mutually exclusive features.
|
||||
# as many features as possible are enabled at for each command
|
||||
mutex() {
|
||||
command=$1
|
||||
shift 1
|
||||
|
||||
for feature in "no-server" "embedded-server"; do
|
||||
echo "[$command][$feature] tauri"
|
||||
cargo "$command" --manifest-path tauri/Cargo.toml --all-targets --features "$feature,cli,all-api" "$@"
|
||||
done
|
||||
|
||||
echo "[$command] checking other crates"
|
||||
cargo "$command" --workspace --exclude tauri --all-targets --all-features
|
||||
echo "[$command] other crates"
|
||||
cargo "$command" --workspace --exclude tauri --all-targets --all-features "$@"
|
||||
}
|
||||
|
||||
for command in "$@"; do
|
||||
case "$command" in
|
||||
check | test)
|
||||
mutex "$command"
|
||||
;;
|
||||
clippy)
|
||||
mutex clippy -- -D warnings
|
||||
;;
|
||||
fmt)
|
||||
echo "[$command] checking formatting"
|
||||
cargo fmt -- --check
|
||||
;;
|
||||
*)
|
||||
echo "[cargo-check.sh] Unknown cargo sub-command: $command"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user