diff --git a/.github/tests/test_template.py b/.github/tests/test_template.py index 852b449..1ed4055 100755 --- a/.github/tests/test_template.py +++ b/.github/tests/test_template.py @@ -211,8 +211,8 @@ def validate_file_structure(self) -> bool: # Template version marker: every release bumps this deliberately. marker = self.project_path / ".github" / "template-version.txt" if marker.exists(): - if marker.read_text().strip() != "reloaded-templates-rust:1.4.2": - logger.error("✗ template-version.txt does not match 1.4.2") + if marker.read_text().strip() != "reloaded-templates-rust:1.4.3": + logger.error("✗ template-version.txt does not match 1.4.3") errors += 1 else: logger.error("✗ template-version.txt not found") @@ -644,7 +644,7 @@ def validate_builds(self) -> bool: return True def validate_v1_1_4_template_updates(self) -> bool: - """Validate v1.1.4 template updates (format-check job, AGENTS.md, verify headers) plus v1.3.0 workflow paths and v1.4.2 guidance/lint pins.""" + """Validate v1.1.4 template updates (format-check job, AGENTS.md, verify headers) plus v1.3.0 workflow paths, v1.4.2 lint pins and the v1.4.3 verify order.""" logger.info("Validating v1.1.4 template updates...") errors = 0 @@ -758,30 +758,42 @@ def validate_v1_1_4_template_updates(self) -> bool: logger.error("✗ .gitignore not found") errors += 1 - # v1.4.2: tidy runs last, after the publish dry-run. + # v1.4.3: file-altering steps (fmt, tidy) run first, before the build. verify_scripts = [ - ("src/.llm/verify.sh", "run_cmd rust-llm-tidy"), - ("src/.llm/verify.ps1", 'Invoke-LoggedCommand "rust-llm-tidy"'), + ( + "src/.llm/verify.sh", + "run_cmd rust-llm-tidy", + "run_cmd cargo fmt", + "run_cmd cargo build", + ), + ( + "src/.llm/verify.ps1", + 'Invoke-LoggedCommand "rust-llm-tidy"', + 'Invoke-LoggedCommand "cargo" @("fmt"', + 'Invoke-LoggedCommand "cargo" @("build"', + ), ] - for verify_rel, invocation in verify_scripts: + for verify_rel, tidy_step, fmt_step, build_step in verify_scripts: verify_path = self.project_path / verify_rel if verify_path.exists(): verify_text = verify_path.read_text() for fragment in ( "Script is relative to git repo root; search if not found", - invocation, + tidy_step, "cargo install rust-llm-tidy-cli", ): if fragment not in verify_text: logger.error(f"✗ {verify_rel} missing: {fragment}") errors += 1 - dry_run = verify_text.find("--dry-run") - if dry_run == -1 or verify_text.find(invocation) < dry_run: - logger.error( - f"✗ {verify_rel} tidy step must follow the publish dry-run" - ) - errors += 1 + build_index = verify_text.find(build_step) + for step_name, step in (("formatting", fmt_step), ("tidy", tidy_step)): + step_index = verify_text.find(step) + if step_index == -1 or step_index > build_index: + logger.error( + f"✗ {verify_rel} {step_name} step must precede the build" + ) + errors += 1 else: logger.error(f"✗ {verify_rel} not found") errors += 1 diff --git a/docs/migration/about.md b/docs/migration/about.md index 7aa71f0..f8214ca 100644 --- a/docs/migration/about.md +++ b/docs/migration/about.md @@ -24,6 +24,7 @@ For information about migrating between template versions, see the following gui - **[v1.4.0]** - Add rust-llm-tidy CI: auto-tidies changed files on pull requests - **[v1.4.1]** - Remove root `AGENTS.md` shim, move style rule to `.llm/general.md` - **[v1.4.2]** - Slim `.llm` guidance, tidy in verify, `core` over `std` lint +- **[v1.4.3]** - Verify scripts run the file-altering steps first [v1.0.0]: v1.0.0.md [v1.0.1]: v1.0.1.md @@ -38,3 +39,4 @@ For information about migrating between template versions, see the following gui [v1.4.0]: v1.4.0.md [v1.4.1]: v1.4.1.md [v1.4.2]: v1.4.2.md +[v1.4.3]: v1.4.3.md diff --git a/docs/migration/v1.4.3.md b/docs/migration/v1.4.3.md new file mode 100644 index 0000000..d38ae50 --- /dev/null +++ b/docs/migration/v1.4.3.md @@ -0,0 +1,105 @@ +# Migration to v1.4.3 + +From `v1.4.2` to `v1.4.3`. + +Runs the file-altering verify steps first: + +- Moves `cargo fmt` and `rust-llm-tidy` to the top of `.llm/verify.{sh,ps1}`. +- Every later step now checks the formatted and tidied files, so a passing run leaves no unverified edits. + +## 1. Reorder `.llm/verify.sh` + +Remove the formatting and tidy steps from the end: + +```diff + echo "Docs..." + run_cmd env RUSTDOCFLAGS="-D warnings" cargo doc --workspace --all-features --no-deps --document-private-items --quiet + +- echo "Formatting..." +- run_cmd cargo fmt --all --quiet +- + echo "Publish dry-run..." + run_cmd cargo publish --dry-run --allow-dirty --quiet --workspace + +- echo "Tidy..." +- if command -v rust-llm-tidy >/dev/null 2>&1; then +- run_cmd rust-llm-tidy +- else +- echo "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" +- fi +- + if [ "$EXIT_CODE" -eq 0 ]; then +``` + +Add them at the top, before the build: + +```diff + return 0 + } + ++ echo "Formatting..." ++ run_cmd cargo fmt --all --quiet ++ ++ echo "Tidy..." ++ if command -v rust-llm-tidy >/dev/null 2>&1; then ++ run_cmd rust-llm-tidy ++ else ++ echo "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" ++ fi ++ + echo "Building..." + run_cmd cargo build --workspace --all-features --all-targets --quiet +``` + +## 2. Reorder `.llm/verify.ps1` + +Remove the formatting and tidy steps from the end: + +```diff + Write-Host "Docs..." + $env:RUSTDOCFLAGS = "-D warnings" + try { + Invoke-LoggedCommand "cargo" @("doc", "--workspace", "--all-features", "--no-deps", "--document-private-items", "--quiet") + } finally { + $env:RUSTDOCFLAGS = $originalRustdocFlags + } + +- Write-Host "Formatting..." +- Invoke-LoggedCommand "cargo" @("fmt", "--all", "--quiet") +- + Write-Host "Publish dry-run..." + Invoke-LoggedCommand "cargo" @("publish", "--dry-run", "--allow-dirty", "--quiet", "--workspace") + +- Write-Host "Tidy..." +- if (Get-Command rust-llm-tidy -ErrorAction SilentlyContinue) { +- Invoke-LoggedCommand "rust-llm-tidy" @() +- } else { +- Write-Host "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" +- } + } finally { +``` + +Add them at the top, before the build: + +```diff + try { ++ Write-Host "Formatting..." ++ Invoke-LoggedCommand "cargo" @("fmt", "--all", "--quiet") ++ ++ Write-Host "Tidy..." ++ if (Get-Command rust-llm-tidy -ErrorAction SilentlyContinue) { ++ Invoke-LoggedCommand "rust-llm-tidy" @() ++ } else { ++ Write-Host "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" ++ } ++ + Write-Host "Building..." + Invoke-LoggedCommand "cargo" @("build", "--workspace", "--all-features", "--all-targets", "--quiet") +``` + +## 3. Update the template version marker + +```diff +-reloaded-templates-rust:1.4.2 ++reloaded-templates-rust:1.4.3 +``` diff --git a/mkdocs.yml b/mkdocs.yml index 1a79369..38c00bc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -93,5 +93,6 @@ nav: - To v1.4.0: migration/v1.4.0.md - To v1.4.1: migration/v1.4.1.md - To v1.4.2: migration/v1.4.2.md + - To v1.4.3: migration/v1.4.3.md - License: https://reloaded-project.github.io/Reloaded.MkDocsMaterial.Themes.R2/Pages/license.html - How to Document: https://reloaded-project.github.io/Reloaded.MkDocsMaterial.Themes.R2/Pages/contributing.html diff --git a/templates/general/.github/template-version.txt b/templates/general/.github/template-version.txt index c69c592..71b5cc3 100644 --- a/templates/general/.github/template-version.txt +++ b/templates/general/.github/template-version.txt @@ -1 +1 @@ -reloaded-templates-rust:1.4.2 +reloaded-templates-rust:1.4.3 diff --git a/templates/general/src/.llm/verify.ps1 b/templates/general/src/.llm/verify.ps1 index de2a2d7..03432b4 100644 --- a/templates/general/src/.llm/verify.ps1 +++ b/templates/general/src/.llm/verify.ps1 @@ -58,6 +58,16 @@ function Invoke-LoggedCommand { } try { + Write-Host "Formatting..." + Invoke-LoggedCommand "cargo" @("fmt", "--all", "--quiet") + + Write-Host "Tidy..." + if (Get-Command rust-llm-tidy -ErrorAction SilentlyContinue) { + Invoke-LoggedCommand "rust-llm-tidy" @() + } else { + Write-Host "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" + } + Write-Host "Building..." Invoke-LoggedCommand "cargo" @("build", "--workspace", "--all-features", "--all-targets", "--quiet") @@ -75,18 +85,8 @@ try { $env:RUSTDOCFLAGS = $originalRustdocFlags } - Write-Host "Formatting..." - Invoke-LoggedCommand "cargo" @("fmt", "--all", "--quiet") - Write-Host "Publish dry-run..." Invoke-LoggedCommand "cargo" @("publish", "--dry-run", "--allow-dirty", "--quiet", "--workspace") - - Write-Host "Tidy..." - if (Get-Command rust-llm-tidy -ErrorAction SilentlyContinue) { - Invoke-LoggedCommand "rust-llm-tidy" @() - } else { - Write-Host "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" - } } finally { $env:RUSTDOCFLAGS = $originalRustdocFlags Set-Location $originalDir diff --git a/templates/general/src/.llm/verify.sh b/templates/general/src/.llm/verify.sh index e8c6432..3b26af3 100755 --- a/templates/general/src/.llm/verify.sh +++ b/templates/general/src/.llm/verify.sh @@ -33,6 +33,16 @@ run_cmd() { return 0 } +echo "Formatting..." +run_cmd cargo fmt --all --quiet + +echo "Tidy..." +if command -v rust-llm-tidy >/dev/null 2>&1; then + run_cmd rust-llm-tidy +else + echo "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" +fi + echo "Building..." run_cmd cargo build --workspace --all-features --all-targets --quiet @@ -45,19 +55,9 @@ run_cmd cargo clippy --workspace --all-features --quiet -- -D warnings echo "Docs..." run_cmd env RUSTDOCFLAGS="-D warnings" cargo doc --workspace --all-features --no-deps --document-private-items --quiet -echo "Formatting..." -run_cmd cargo fmt --all --quiet - echo "Publish dry-run..." run_cmd cargo publish --dry-run --allow-dirty --quiet --workspace -echo "Tidy..." -if command -v rust-llm-tidy >/dev/null 2>&1; then - run_cmd rust-llm-tidy -else - echo "Skipping; rust-llm-tidy not installed. Install: cargo install rust-llm-tidy-cli" -fi - if [ "$EXIT_CODE" -eq 0 ]; then echo "All checks passed!" else