Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions .github/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/migration/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
105 changes: 105 additions & 0 deletions docs/migration/v1.4.3.md
Original file line number Diff line number Diff line change
@@ -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
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion templates/general/.github/template-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
reloaded-templates-rust:1.4.2
reloaded-templates-rust:1.4.3
20 changes: 10 additions & 10 deletions templates/general/src/.llm/verify.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions templates/general/src/.llm/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down