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
2 changes: 1 addition & 1 deletion .github/tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def install_dependencies(venv_dir: Path, script_dir: Path, verbose: bool = False

# Install from template documentation requirements
print_info("Installing template documentation dependencies...")
template_docs_requirements = script_dir.parent.parent / "templates" / "general" / "src" / "doc" / "docs" / "requirements.txt"
template_docs_requirements = script_dir.parent.parent / "templates" / "general" / "doc" / "docs" / "requirements.txt"
if template_docs_requirements.exists():
run_command([str(pip_exe), "install", "-r", str(template_docs_requirements)], verbose=verbose)
else:
Expand Down
99 changes: 59 additions & 40 deletions .github/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,28 @@ def validate_file_structure(self) -> bool:
logger.info("Validating file structure...")
errors = 0

# MkDocs validation (FIX: only check src/doc/mkdocs.yml, NOT root mkdocs.yml)
# MkDocs validation (FIX: only check doc/mkdocs.yml, NOT root mkdocs.yml)
if self.config.mkdocs:
errors += self._check_exists("src/doc/mkdocs.yml", "Doc mkdocs.yml")
errors += self._check_exists("src/doc/docs", "MkDocs source directory")
errors += self._check_exists("doc/mkdocs.yml", "Doc mkdocs.yml")
errors += self._check_exists("doc/docs", "MkDocs source directory")
else:
errors += self._check_not_exists("src/doc", "Documentation directory")
errors += self._check_not_exists("doc", "Documentation directory")
errors += self._check_not_exists(
".github/workflows/deploy-mkdocs.yml", "MkDocs deployment workflow"
)

# VSCode validation
if self.config.vscode:
errors += self._check_exists("src/.vscode/settings.json", "VSCode settings")
errors += self._check_exists("src/.vscode/tasks.json", "VSCode tasks")
errors += self._check_exists(".vscode/settings.json", "VSCode settings")
errors += self._check_exists(".vscode/tasks.json", "VSCode tasks")
if self.config.mkdocs:
errors += self._check_exists(
"src/doc/.vscode/settings.json", "Doc VSCode settings"
"doc/.vscode/settings.json", "Doc VSCode settings"
)
else:
errors += self._check_not_exists("src/.vscode", "VSCode directory")
errors += self._check_not_exists(".vscode", "VSCode directory")
if self.config.mkdocs:
errors += self._check_not_exists("src/doc/.vscode", "Doc VSCode directory")
errors += self._check_not_exists("doc/.vscode", "Doc VSCode directory")

# C library validation
if self.config.build_c_libs:
Expand Down Expand Up @@ -187,7 +187,11 @@ def validate_file_structure(self) -> bool:
errors += self._validate_license_cleanup()

# Essential files validation
errors += self._check_exists("src/Cargo.toml", "Workspace Cargo.toml")
errors += self._check_exists("Cargo.toml", "Workspace Cargo.toml")

# The pre-v1.3.0 layout must be fully vacated after the workspace-root move
for legacy in ("src/Cargo.toml", "src/.cargo", "src/.vscode", "src/doc"):
errors += self._check_not_exists(legacy, f"Legacy layout {legacy}")
errors += self._check_exists(
f"src/{self.config.project_name}/Cargo.toml", "Package Cargo.toml"
)
Expand Down Expand Up @@ -352,7 +356,7 @@ def _validate_fuzz_tasks(self) -> int:
if not self.config.vscode:
return 0

tasks_file = self.project_path / "src/.vscode/tasks.json"
tasks_file = self.project_path / ".vscode/tasks.json"
if not tasks_file.exists():
logger.error("✗ VSCode tasks.json not found for fuzz task validation")
return 1
Expand All @@ -373,6 +377,13 @@ def _validate_fuzz_tasks(self) -> int:
logger.error("✗ tasks.json missing 'List Fuzz Targets' task")
errors += 1

# cargo fuzz needs the folder containing fuzz/, which stays under src/
if "cd src && cargo +nightly fuzz list" not in content:
logger.error(
"✗ 'List Fuzz Targets' must run from src/ (cargo fuzz needs the folder containing fuzz/)"
)
errors += 1

if errors == 0:
logger.debug("✓ Fuzz tasks validation passed")
return errors
Expand Down Expand Up @@ -489,16 +500,16 @@ def validate_builds(self) -> bool:
"""Run cargo check, build, and test."""
logger.info("Validating Rust builds...")

src_dir = self.project_path / "src"
if not src_dir.exists():
logger.error("✗ src/ directory not found")
project_dir = self.project_path
if not (project_dir / "Cargo.toml").exists():
logger.error("✗ Workspace Cargo.toml not found")
return False

# Run cargo check
logger.info("Running cargo check...")
result = subprocess.run(
["cargo", "check"],
cwd=src_dir,
cwd=project_dir,
capture_output=True,
text=True,
encoding="utf-8",
Expand All @@ -514,7 +525,7 @@ def validate_builds(self) -> bool:
logger.info("Running cargo build...")
result = subprocess.run(
["cargo", "build"],
cwd=src_dir,
cwd=project_dir,
capture_output=True,
text=True,
encoding="utf-8",
Expand All @@ -530,7 +541,7 @@ def validate_builds(self) -> bool:
logger.info("Running cargo test...")
result = subprocess.run(
["cargo", "test"],
cwd=src_dir,
cwd=project_dir,
capture_output=True,
text=True,
encoding="utf-8",
Expand All @@ -545,7 +556,7 @@ def validate_builds(self) -> bool:
return True

def validate_v1_1_4_template_updates(self) -> bool:
"""Validate v1.1.4 template changes: format-check job, simplified AGENTS.md, guidance files, verify headers."""
"""Validate v1.1.4 template changes (format-check job, AGENTS.md, guidance files, verify headers) and v1.3.0 workspace-root workflow paths."""
logger.info("Validating v1.1.4 template updates...")
errors = 0

Expand Down Expand Up @@ -583,31 +594,39 @@ def validate_v1_1_4_template_updates(self) -> bool:
if not found_publish_needs:
logger.error("✗ publish-crate needs does not include format-check")
errors += 1

# The workspace manifest lives at the project root since v1.3.0
if "manifest-path: Cargo.toml" not in workflow_text:
logger.error(
"✗ rust.yml manifest-path does not point at root Cargo.toml"
)
errors += 1
for stale in ("manifest-path: src/Cargo.toml", "workspace-path: src"):
if stale in workflow_text:
logger.error(f"✗ rust.yml contains stale workspace path: {stale}")
errors += 1
else:
logger.error("✗ Workflow file not found")
errors += 1

agents_path = self.project_path / "src" / "AGENTS.md"
if agents_path.exists():
agents_text = agents_path.read_text().strip()
expected_lines = [
"After changes, run `.cargo/verify.{sh,ps1}` before returning.",
"If relevant to your review task, read `.cargo/{general,performance,documentation}.md`.",
]
actual_lines = agents_text.splitlines()
if actual_lines != expected_lines:
logger.error(
f"✗ src/AGENTS.md content mismatch. Got {len(actual_lines)} lines: {actual_lines}"
)
agents_path = self.project_path / "src" / "AGENTS.md"
if agents_path.exists():
agents_text = agents_path.read_text()
for line in (
"After changes, run `.llm/verify.{sh,ps1}` before returning.",
"If relevant to your review task, read `.llm/{general,performance,documentation}.md`.",
):
if line not in agents_text:
logger.error(f"✗ src/AGENTS.md missing guidance line: {line}")
errors += 1
else:
logger.error("✗ src/AGENTS.md not found")
errors += 1
else:
logger.error("✗ src/AGENTS.md not found")
errors += 1

guidance_files = [
("src/.cargo/general.md", "# General Rules"),
("src/.cargo/performance.md", "# Performance Rules"),
("src/.cargo/documentation.md", "# Documentation Rules"),
("src/.llm/general.md", "# General Rules"),
("src/.llm/performance.md", "# Performance Rules"),
("src/.llm/documentation.md", "# Documentation Rules"),
]
for rel_path, heading in guidance_files:
file_path = self.project_path / rel_path
Expand All @@ -625,14 +644,14 @@ def validate_v1_1_4_template_updates(self) -> bool:
gitignore_path = self.project_path / ".gitignore"
if gitignore_path.exists():
gitignore_text = gitignore_path.read_text()
if "src/.vscode/local-reviews/" not in gitignore_text:
if ".vscode/local-reviews/" not in gitignore_text:
logger.error("✗ .gitignore missing local-reviews path")
errors += 1
else:
logger.error("✗ .gitignore not found")
errors += 1

for verify_rel in ["src/.cargo/verify.sh", "src/.cargo/verify.ps1"]:
for verify_rel in ["src/.llm/verify.sh", "src/.llm/verify.ps1"]:
verify_path = self.project_path / verify_rel
if verify_path.exists():
verify_text = verify_path.read_text()
Expand Down Expand Up @@ -663,9 +682,9 @@ def validate_mkdocs(self) -> bool:

logger.info("Validating MkDocs build...")

doc_dir = self.project_path / "src/doc"
doc_dir = self.project_path / "doc"
if not doc_dir.exists():
logger.error("✗ src/doc/ directory not found")
logger.error("✗ doc/ directory not found")
return False

# Run mkdocs build --strict
Expand Down
2 changes: 1 addition & 1 deletion docs/features/automated-testing-publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Update your `.vscode/tasks.json` to include the exclusion flags:
}
```

The task automatically runs in the `src/` directory, so you don't need to manually navigate when using VSCode tasks.
The task runs from the project root.

### Semantic Version Checks
Automatically checks if your changes might break code for people who use your library. If you make changes that could break other people's code, you'll need to update your version number. This prevents accidental breaking changes from reaching your users.
Expand Down
7 changes: 2 additions & 5 deletions docs/features/bindings/cpp-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,14 @@ Using VSCode, press `Ctrl+Shift+P` → "Run Task" → Select one of:
Or from command line:

```bash
cd src

# Install cbindgen (one-time setup)
cargo install cbindgen

# Generate C bindings
cbindgen --config ../.github/cbindgen_c.toml --output bindings/c/your-project.h your-project
cbindgen --config .github/cbindgen_c.toml --output src/bindings/c/your-project.h src/your-project

# Generate C++ bindings
cbindgen --config ../.github/cbindgen_cpp.toml --output bindings/cpp/your-project.hpp your-project
cbindgen --config .github/cbindgen_cpp.toml --output src/bindings/cpp/your-project.hpp src/your-project
```

Replace `your-project` with your actual project name. Configuration files are located in `.github/`:
Expand All @@ -454,7 +452,6 @@ When you push a release tag, headers are generated with `cbindgen`, and attached
**Generate headers locally:**

```bash
cd src
cargo build --features c-exports # Generate C/C++ headers
```

Expand Down
1 change: 0 additions & 1 deletion docs/features/bindings/csharp-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ See [C/C++ Bindings - How to Export Functions](cpp-bindings.md#how-to-export-fun
**Generate bindings locally:**

```bash
cd src
cargo build --features c-exports # Generate C# bindings and NuGet package
```

Expand Down
6 changes: 0 additions & 6 deletions docs/features/cross-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ cargo install cross --git https://github.com/cross-rs/cross
Simply replace `cargo` with `cross`:

```bash
cd src

cross build --target x86_64-pc-windows-gnu
# Windows on Linux or macOS
cross test --target x86_64-pc-windows-gnu --release
Expand Down Expand Up @@ -66,8 +64,6 @@ You can use either:
`cross` can be used to test with Wine.

```bash
cd src

# Test Windows binaries on Linux using cross
cross test --target x86_64-pc-windows-gnu --release
cross test --target i686-pc-windows-gnu --release
Expand All @@ -91,7 +87,6 @@ The tests will run in your local WINE installation.
rustup target add x86_64-pc-windows-gnu

# Test Windows binaries on Linux using cargo
cd src
cargo test --target x86_64-pc-windows-gnu --release
```

Expand Down Expand Up @@ -138,7 +133,6 @@ The tests will run in your local WINE installation.

```bash
nix develop
cd src
cargo test --target x86_64-pc-windows-gnu --release
```

Expand Down
2 changes: 1 addition & 1 deletion docs/features/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ cargo install cargo-fuzz
**Initialize fuzzing in your project:**

```bash
cd src # or your project root
cd src # fuzz/ is created in the current directory
cargo fuzz init
```

Expand Down
4 changes: 0 additions & 4 deletions docs/features/miri-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ rustup +nightly component add miri
Run Miri on your tests:

```bash
cd src
cargo +nightly miri test
```

Expand All @@ -141,7 +140,6 @@ Computers store numbers in memory differently:
To test with big-endian emulation via command line:

```bash
cd src
cargo +nightly miri test --target powerpc64-unknown-linux-gnu
```

Expand All @@ -162,14 +160,12 @@ rustup +nightly component add miri
**Run Miri on your tests:**

```bash
cd src
cargo +nightly miri test
```

**Test with big-endian emulation:**

```bash
cd src
cargo +nightly miri test --target powerpc64-unknown-linux-gnu
```

Expand Down
6 changes: 0 additions & 6 deletions docs/features/performance-benchmarking-profiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ The template provides the essential building blocks for benchmarking and profili
Run your first benchmark with a single command:

```bash
cd src
cargo bench
```

Expand All @@ -33,8 +32,6 @@ Open the file in your web browser or right-click → "Show Preview" in VSCode.
Below are some useful additional benchmark commands:

```bash
cd src

# Run a specific benchmark
cargo bench "fib 20"

Expand Down Expand Up @@ -179,7 +176,6 @@ cargo install cargo-flamegraph
**Profile a benchmark:**

```bash
cd src
cargo flamegraph --bench my_benchmark --profile profile -- --bench --profile-time 10 can_decompress_file_Model
# On Windows this requires `sudo cargo`, or administrator command prompt
```
Expand Down Expand Up @@ -245,7 +241,6 @@ Visual Studio 2022 Community Profiler showing CPU usage
Build the benchmark binary without running it:

```bash
cd src
cargo bench --no-run
```

Expand Down Expand Up @@ -336,7 +331,6 @@ criterion_main!(benches);
Run with:

```bash
cd src
cargo bench
```

Expand Down
Loading
Loading