From 9310b1eff24e9449aa1257592aab4601c7ebc4f0 Mon Sep 17 00:00:00 2001 From: Adrian Duke Date: Wed, 8 Apr 2026 17:27:44 +0100 Subject: [PATCH] just: Add more pre-push tasks Migrating further pre-push checks from `flake.nix` --- justfile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/justfile b/justfile index 5e5d4245..43680194 100644 --- a/justfile +++ b/justfile @@ -1,8 +1,67 @@ default: @just --list +# Format Rust code +format-rust: (verify-tool "cargo") + @echo "Cargo fmt..." + @cargo fmt --all + +# Run cargo check +check-rust: + @echo "Cargo check..." + @cargo check --workspace --all-targets --all-features + +# Check documentation for warnings +check-docs: + @echo "Checking docs for warnings..." + @RUSTDOCFLAGS="--deny warnings" cargo doc --workspace --all-features --no-deps + +# Check for typos +check-typos: (verify-tool "typos" "typos-cli") + @echo "Checking for spelling typos..." + @typos + +# Run codespell +check-spelling: (verify-tool "codespell") + @echo "Checking for code typos..." + @git ls-files -z | xargs -0 codespell -w + +# Run shellcheck on all shell scripts +check-scripts: (verify-tool "shellcheck") + @echo "Checking shell scripts..." + @shellcheck scripts/*.sh + +# Replicate the custom grep checks from flake.nix +check-keywords: (verify-tool "rg" "ripgrep") + #! /usr/bin/env bash + set -e + echo "Checking for forbidden words in staged files..." + + # Get staged Rust files + STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '\.rs$' || true) + + if [ -n "$STAGED_FILES" ]; then + ! echo "$STAGED_FILES" | xargs rg --context=3 --fixed-strings 'radicle.xyz' + ! echo "$STAGED_FILES" | xargs rg --context=3 --fixed-strings 'radicle.zulipchat.com' + + # For `git2::` we need to exclude raw.rs + FILTERED_GIT2=$(echo "$STAGED_FILES" | grep '^crates/radicle/.*\.rs$' | grep -v 'crates/radicle/src/git/raw.rs' || true) + if [ -n "$FILTERED_GIT2" ]; then + ! echo "$FILTERED_GIT2" | xargs rg --context=3 --fixed-strings 'git2::' + fi + fi + +# Format Nix files +format-nix: + #!/usr/bin/env bash + if command -v alejandra >/dev/null 2>&1; then + alejandra --check . + else + echo "⏭️ alejandra not found, skipping Nix formatting." + fi + # Run pre-push checks -pre-push: lint-rust +pre-push: format-rust check-rust check-keywords check-docs check-spelling check-scripts check-typos format-nix lint-rust @echo "✅ pre-push passed" # Run Clippy lints