logs.gokuls.in

1 pull request merged across 1 repo

bahdotsh/wrkflw

Finish the module split started in earlier commits: lift the watcher's

main loop + git-state cache into dedicated modules, extract the CLI's

Run/Watch arms into sibling command modules, and collapse a copy-pasted

pull_request + no base-branch rejection into a single shared helper.

While at it, fix a silent-skip hole where persistent workflow-rescan

failures were logged at debug level — a non-verbose user would never

see their new workflow being ignored session-long. Bumped to warning.

Watcher crate

  • New git_state.rsCachedGitState + GitStateCache owning the TTL-bounded (branch, tag) mutex.
  • New reactor.rs — lifted run_loop, evaluate_and_execute, refresh_trigger_cache_async, canonicalize_changed_paths out of WorkflowWatcher as private free functions.
  • WorkflowWatcher::run is now a 3-line forward to reactor::run_loop.
  • cached_git_state kept as a #[cfg(test)] method shim (two staleness tests pin through it).
  • watcher.rs: 2071 → 1218 lines (~300 non-test).

wrkflw binary

  • New prefilter.rsPrefilterDecision, PrefilterRequest, run_trigger_prefilter, build_event_context, apply_base_branch, effective_strict_filter, all 7 prefilter_tests.
  • New validate_event_requires_base_branch helper shared between the run and watch commands — previously each had its own inline copy of the rejection/warning text.
  • New run_workflow_cmd.rs / watch_cmd.rs — Run and Watch arm bodies moved into sibling modules with RunCtx / WatchCtx structs.
  • main.rs: 2039 → 937 lines.

Bug fix

  • Escalated persistent workflow-rescan failures from debugwarning (was silent-skip against a stale workflow-files snapshot, directly under a comment calling out the hazard).

Test plan

  • cargo test --workspace — 46/46 watcher tests pass, 7/7 prefilter tests pass, everything else green
  • cargo clippy --workspace -- -D warnings — clean
  • cargo fmt --all --check — clean
  • Public API unchanged (WorkflowWatcher, WatcherConfig, WatchEvent, ShutdownSignal, DEFAULT_MAX_CONCURRENT_EXECUTIONS re-exports preserved)
  • Manual smoke: cargo run -- run .github/workflows/build.yml --event push --diff
  • Manual smoke: cargo run -- watch --event pull_request --base-branch main
  • Manual smoke: trigger a rescan failure (chmod 000 .github/workflows mid-session) and confirm the new warning surfaces