generated from rust-templates/rust-bin-template
Some scripts to watch specific pieces of specific git projects on any accessible repo.
- Rust 92.8%
- Gherkin 7.2%
Watch Git
A Rust based tool for watching specific parts of git repositories, and triggering local events on a change.
Git remotes can be specified with regular expressions matching branch patterns and path patterns. Matches trigger user-specified commands.
How to Build & Run
Prerequisites
Install Rust, then install coverage and pre-commit tools:
# Install cargo-llvm-cov & nightly toolchain for coverage
rustup toolchain install nightly
rustup component add llvm-tools --toolchain nightly
cargo install cargo-llvm-cov
# Install cargo-mutants for mutation testing
cargo install cargo-mutants
# Install prek
cargo install prek
Building & Running
cargo build # Debug build
cargo build --release # Release build
cargo run # Run the CLI binary
CLI Commands
cargo run -- watch-git init # Walks you through creating a config.yml to watch your repositories.
cargo run -- watch-git validate # Validates your config.yml, and tells you what's wrong if there's a problem.
cargo run -- watch-git list # Lists the repositories config.yml tells watch-git to watch.
cargo run -- watch-git start # Starts watch-git watching the repositories specified in config.yml
Testing
Run all unit tests:
cargo test --all-features
- Unit tests: Located in
src/lib.rsanddev-tools/src/bin/cargo-covcheck.rs.
Coverage & Mutation Testing
Branch Coverage
cargo run -p dev-tools --bin cargo-covcheck
Threshold is set in coverage-threshold. Results via cargo +nightly llvm-cov --branch --html.
Mutation Testing
cargo run -p dev-tools --bin cargo-mutcheck
Review mutants.out/missed.txt for surviving mutations; strengthen tests accordingly.
Pre-commit Hooks
Set up hooks in this repository:
prek install
Once set up, these checks run automatically on every commit:
cargo fmt --check(auto-formats on failure)cargo test --all-featurescargo run -p dev-tools --bin cargo-covcheck
Run manually:
prek run --all-files
Contributing
- Format:
cargo fmt - Test:
cargo test --all-features - Verify Coverage & Mutations:
- Coverage:
cargo run -p dev-tools --bin cargo-covcheck - Mutation:
cargo run -p dev-tools --bin cargo-mutcheck
- Coverage:
- Hooks: Ensure
prek run --all-filespasses. - Open a Pull Request with your changes.
Tracing tip
src/macros.rs contains a trace macro that is disabled by default. Replace NO_LOG with LOG to activate this, but don't check that change in.
Workspace Structure
src/- Main library and binarydev-tools/- Helper utilities for coverage and mutation testing