# Run code checks
check TOOLCHAIN="" *FLAGS="--all-targets":
cargo {{ TOOLCHAIN }} check {{ FLAGS }}
cargo {{ TOOLCHAIN }} clippy {{ FLAGS }}
cargo +nightly fmt --check --all
alias c := check
# Run tests
test TOOLCHAIN="":
cargo {{ TOOLCHAIN }} test
alias t := test
# Build the docs
doc $RUSTDOCFLAGS="-D warnings":
cargo doc --workspace
alias d := doc
# Run cargo-release (ignore no-commit-to-branch pre-commit)
release *FLAGS:
SKIP="no-commit-to-branch" cargo release {{ FLAGS }}
# Check the name of a branch follows convention. By default takes env var from pre-commit.
branch_name_check BRANCH=env('PRE_COMMIT_REMOTE_BRANCH'):
#!/usr/bin/env bash
set -euo pipefail
# Remove leading refs/heads/ from the branch name if it contains it
BRANCH_NAME=$(sed -r 's/^(refs\/heads\/)?(.+)$/\2/g' <<< "{{ BRANCH }}")
if [[ "$BRANCH_NAME" = "main" ]] ; then
exit 0
fi
if ! [[ "$BRANCH_NAME" =~ ^(fix|feat|junk|maint|docs|no-ci|test|release)/.+$ ]] ; then
echo "Branch $BRANCH_NAME does not match naming convention"
exit 1
fi