Skip to content

Commit 9bee22b

Browse files
Copilottschm
andauthored
feat: include hypothesis-test HTML report in book (#759)
* Initial plan * Initial plan for hypothesis-test report in book Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> * Add hypothesis-test report to book Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> Co-authored-by: Thomas Schmelzer <thomas.schmelzer@gmail.com>
1 parent 679bc20 commit 9bee22b

File tree

2 files changed

+166
-1
lines changed

2 files changed

+166
-1
lines changed

.rhiza/make.d/book.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ BOOK_SECTIONS := \
4242
"Test Report|_tests/html-report/report.html|tests/html-report/report.html|_tests/html-report|tests/html-report" \
4343
"Benchmarks|_tests/benchmarks/report.html|tests/benchmarks/report.html|_tests/benchmarks|tests/benchmarks" \
4444
"Stress Tests|_tests/stress/report.html|tests/stress/report.html|_tests/stress|tests/stress" \
45+
"Hypothesis Tests|_tests/hypothesis/report.html|tests/hypothesis/report.html|_tests/hypothesis|tests/hypothesis" \
4546
"Notebooks|_marimushka/index.html|marimushka/index.html|_marimushka|marimushka" \
4647
"Official Documentation|_mkdocs/index.html|docs/index.html|_mkdocs|docs"
4748

@@ -51,7 +52,7 @@ BOOK_SECTIONS := \
5152
# 1. Aggregates API docs, coverage, test reports, notebooks, and MkDocs site into _book.
5253
# 2. Generates links.json to define the book structure.
5354
# 3. Uses 'minibook' to compile the final HTML site.
54-
book:: test benchmark stress docs marimushka mkdocs-build ## compile the companion book
55+
book:: test benchmark stress hypothesis-test docs marimushka mkdocs-build ## compile the companion book
5556
@printf "${BLUE}[INFO] Building combined documentation...${RESET}\n"
5657
@rm -rf _book && mkdir -p _book
5758

REPOSITORY_ANALYSIS.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,3 +841,167 @@ def setup_rhiza_git_repo()
841841
- Document autouse fixtures and their impact
842842
- Add architecture diagram showing fixture dependencies
843843
- Clarify stress test acceptance criteria
844+
845+
---
846+
847+
## 2026-02-21 — Comprehensive Analysis Entry
848+
849+
### Summary
850+
851+
The **Rhiza** repository is a sophisticated Python project template system ("living templates") that enables continuous synchronization of configuration, CI/CD workflows, and development tooling across projects. The codebase demonstrates production-grade engineering with well-structured Makefiles, comprehensive testing (property-based, stress, benchmark, integration), dual CI/CD support (GitHub Actions + GitLab CI), and a modular book/documentation generation system using Marimo notebooks. The architecture is mature, with clear separation of concerns between template management (`.rhiza/`), project tests (`tests/`), and documentation (`book/`, `docs/`).
852+
853+
**Core Value Proposition:** Unlike one-time project generators (cookiecutter, copier), Rhiza provides continuous template synchronization via `.rhiza/template.yml` configuration, allowing projects to selectively pull updates over time while maintaining control.
854+
855+
### Strengths
856+
857+
#### Architecture & Organization
858+
- **Clean separation**: `.rhiza/` contains 16 modular `.mk` files (test.mk, book.mk, marimo.mk, docs.mk, etc.), each focused on a single concern
859+
- **Template bundles**: `template-bundles.yml` defines composable sets (core, tests, github, docker) for flexible template selection
860+
- **Multi-platform CI**: Parallel GitHub Actions (`.github/workflows/`) and GitLab CI (`.gitlab-ci.yml`) configurations with consistent job definitions
861+
- **Makefile design**: Double-colon rules allow hook extension (`pre-sync::`, `post-sync::`); color-coded output; help generation from inline comments
862+
863+
#### Testing Infrastructure (7/10 - see detailed breakdown in prior entry)
864+
- **Property-based tests**: Hypothesis integration (`.rhiza/requirements/tests.txt` specifies `hypothesis>=6.150.0`) with dedicated `make hypothesis-test` target
865+
- **Stress testing**: `tests/stress/` directory with separate marker (`@pytest.mark.stress`) and `make stress` target
866+
- **Benchmark tests**: `tests/benchmarks/` using pytest-benchmark with HTML report generation (`make benchmark`)
867+
- **Test organization**: Structured into `tests/{property,stress,benchmarks,integration,api,structure,security,sync,deps,utils}` directories
868+
- **Comprehensive coverage**: HTML coverage reports (`_tests/html-coverage`), test reports (`_tests/html-report/report.html`), hypothesis reports (`_tests/hypothesis/report.html`)
869+
- **Fixture hierarchy**: `.rhiza/tests/conftest.py` provides `git_repo` and `setup_rhiza_git_repo()` for isolated test environments
870+
871+
#### Hypothesis Testing Implementation
872+
- **Dedicated target**: `.rhiza/make.d/test.mk:103-118` defines `hypothesis-test` target with:
873+
- `--hypothesis-show-statistics` flag for detailed output
874+
- `--hypothesis-seed=0` for reproducibility
875+
- `-m "hypothesis or property"` marker filtering
876+
- HTML report generation to `_tests/hypothesis/report.html`
877+
- **Example test**: `tests/property/test_makefile_properties.py` demonstrates property-based testing with `@given(st.lists(st.integers() | st.floats()))`
878+
- **Documentation**: `docs/TESTS.md` (298 lines) provides comprehensive guidance on writing property-based tests, including best practices and troubleshooting
879+
- **CI integration**: Hypothesis tests run as part of `make test` (line 23-47 in test.mk) during GitHub Actions `rhiza_ci.yml` workflow
880+
881+
#### Book & Documentation System
882+
- **Marimo notebooks**: `book/marimo/notebooks/rhiza.py` showcases interactive reactive notebooks with inline PEP 723 dependencies
883+
- **Marimushka export**: `.rhiza/make.d/marimo.mk:45-67` exports Marimo notebooks to static HTML using `marimushka>=0.3.3`
884+
- **Book compilation**: `.rhiza/make.d/book.mk:54-105` aggregates 7 sections (API, Coverage, Test Report, Benchmarks, Stress Tests, Notebooks, Official Documentation) into unified `_book/` via `minibook`
885+
- **Declarative sections**: `BOOK_SECTIONS` variable (lines 39-46) defines structure as pipe-delimited tuples with source/target paths
886+
- **MkDocs integration**: `.rhiza/make.d/docs.mk:72-82` builds MkDocs sites with Material theme (`mkdocs-material<10.0`)
887+
- **API docs**: `pdoc` integration with docformat detection (google/numpy/sphinx) from `ruff.toml` or fallback to google
888+
- **CI workflow**: `.github/workflows/rhiza_marimo.yml` discovers and validates all notebooks in parallel matrix jobs
889+
890+
#### Test Report & HTML Generation
891+
- **HTML test reports**: `pytest-html>=4.0` dependency generates `_tests/html-report/report.html` (test.mk line 40, 47)
892+
- **Coverage HTML**: `--cov-report=html:_tests/html-coverage` generates browsable coverage reports (test.mk line 37)
893+
- **Benchmark reports**: Custom `rhiza-tools>=0.2.3 analyze-benchmarks` generates `_tests/benchmarks/report.html` (test.mk line 83)
894+
- **Hypothesis reports**: `--html=_tests/hypothesis/report.html` generates property-based test reports (test.mk line 117)
895+
- **Stress reports**: `--html=_tests/stress/report.html` for stress test results (test.mk line 148)
896+
- **Book aggregation**: All reports copied to `_book/tests/` structure for unified documentation site
897+
898+
#### Dependency Management
899+
- **UV-first**: `uv>=0.10.4` used throughout; `UV_BIN` and `UVX_BIN` variables for consistency
900+
- **Version matrix**: `make version-matrix` uses `rhiza-tools>=0.2.2` to extract Python versions from `pyproject.toml` for CI matrix generation
901+
- **Constrained versions**: `pyproject.toml` dev dependencies use ranges (e.g., `marimo>=0.18.0,<1.0`) with rationale comments
902+
- **Security scanning**: `make security` runs `pip-audit` and `bandit` (test.mk lines 63-67)
903+
904+
#### CI/CD Configuration
905+
- **GitHub Actions workflows**:
906+
- `rhiza_ci.yml`: Matrix testing across Python 3.11-3.14, runs `make test`
907+
- `rhiza_marimo.yml`: Discovers and validates Marimo notebooks in parallel
908+
- `rhiza_validate.yml`: Validates Rhiza configuration
909+
- `rhiza_release.yml`: Release automation
910+
- **GitLab CI**: `.gitlab-ci.yml` includes parallel workflows from `.gitlab/workflows/` with 4 stages (`.pre`, `build`, `test`, `deploy`)
911+
- **No hypothesis-specific workflow**: Property-based tests run as part of standard `make test` in CI (appropriate design decision)
912+
913+
### Weaknesses
914+
915+
#### Hypothesis Testing Gaps
916+
- **Missing dedicated CI workflow**: No separate GitHub Actions workflow for hypothesis testing (unlike benchmarks); runs only via `make test`
917+
- **Limited example coverage**: Only one example test (`test_sort_correctness_using_properties`) demonstrating hypothesis usage
918+
- **No project-specific property tests**: `tests/property/test_makefile_properties.py` tests generic Python behavior (list sorting), not Makefile/template-specific invariants
919+
- **Unused hypothesis-test target**: `make hypothesis-test` target exists but not invoked in CI workflows or documentation as standalone command
920+
- **No hypothesis configuration**: Missing `[tool.hypothesis]` section in `pyproject.toml` for project-wide settings (seed, max_examples, deadline)
921+
922+
#### Book/Documentation Concerns
923+
- **Single notebook**: Only `book/marimo/notebooks/rhiza.py` exists; limited demonstration of Marimo capabilities for a showcase
924+
- **Complex book build**: `.rhiza/make.d/book.mk:54-105` has 52 lines of shell logic for section aggregation; could be refactored to Python script
925+
- **Missing sections handling**: `make book` silently skips missing sections with `[WARN]` messages; no validation that minimum required sections exist
926+
- **Template complexity**: `minibook` invocation (lines 97-102) requires Python one-liner to convert JSON, fragile if links.json malformed
927+
- **No book validation**: No tests verify book structure, links.json validity, or that all sections are generated correctly
928+
929+
#### Testing & Report Generation
930+
- **HTML report dependencies**: `_tests/` directory not committed; reports lost between CI runs (expected, but no artifact upload in `rhiza_ci.yml`)
931+
- **Coverage threshold**: `COVERAGE_FAIL_UNDER ?= 90` but no source folder defined in `.rhiza/make.d/test.mk` (relies on `SOURCE_FOLDER` from parent Makefile)
932+
- **Benchmark CI missing**: No GitHub Actions workflow for benchmarks despite comprehensive `make benchmark` target and documentation
933+
- **Test isolation**: `tests/stress/` and `tests/benchmarks/` directories exist at project level but unclear if they test template or project code
934+
- **Duplicate test structure**: Both `tests/` and `.rhiza/tests/` hierarchies; `.rhiza/tests/` has 70+ files while `tests/` has only 5 files
935+
936+
#### Directory Structure Confusion
937+
- **Overlapping test directories**:
938+
- `tests/property/` (project-level, 1 file)
939+
- `tests/benchmarks/` (project-level, 2 files)
940+
- `tests/stress/` (project-level, 2 files)
941+
- `.rhiza/tests/api/`, `.rhiza/tests/integration/`, `.rhiza/tests/stress/`, etc. (template-level, 60+ files)
942+
- **Unclear ownership**: Documentation doesn't clearly explain when tests should go in `tests/` vs `.rhiza/tests/`
943+
- **Book structure**: `book/marimo/notebooks/` (only 1 notebook) suggests more planned but not present
944+
945+
#### Makefile & Configuration
946+
- **Variable dependencies**: `SOURCE_FOLDER` referenced but not defined in `.rhiza/rhiza.mk` or `.rhiza/make.d/test.mk`; assumed to come from parent Makefile
947+
- **MARIMO_FOLDER undefined**: `marimo.mk` uses `${MARIMO_FOLDER}` but no default defined (assumed `marimo` from `rhiza_marimo.yml:45`)
948+
- **BOOK_TITLE/SUBTITLE undefined**: `book.mk:98-99` uses these variables without defaults or documentation
949+
- **Color code duplication**: Color variables (`BLUE`, `RED`, `GREEN`, etc.) defined in `.rhiza/rhiza.mk` lines 8-14 but potentially redefined elsewhere
950+
951+
### Risks / Technical Debt
952+
953+
#### Maintainability
954+
1. **Double test hierarchy complexity**: Maintaining parallel `tests/` and `.rhiza/tests/` increases cognitive load; new contributors unclear where to add tests
955+
2. **Shell complexity in Makefiles**: Book building, Marimushka export, docs generation all use complex shell scripting; difficult to debug and test
956+
3. **Implicit variable contracts**: Many Makefiles assume variables set elsewhere (SOURCE_FOLDER, MARIMO_FOLDER, BOOK_TITLE); brittle if parent Makefile changes
957+
4. **No Makefile tests**: Despite `tests/api/test_makefile_api.py` in `.rhiza/tests/`, no tests for `make book`, `make marimushka`, or `make hypothesis-test`
958+
959+
#### CI/CD
960+
1. **No artifact preservation**: HTML reports generated but not uploaded as GitHub Actions artifacts; debugging CI failures requires local reproduction
961+
2. **Matrix explosion risk**: `rhiza_ci.yml` tests 4 Python versions; if more Make targets added, CI time will increase linearly
962+
3. **GitLab/GitHub drift**: Maintaining parallel CI definitions risks divergence; no validation they stay in sync
963+
4. **Hardcoded versions**: `uv@0.10.4` in workflows; if `.rhiza/.rhiza-version` changes, workflows may use stale version
964+
965+
#### Documentation
966+
1. **Hypothesis testing underutilized**: Extensive infrastructure (`make hypothesis-test`, docs, dependencies) but minimal actual usage (1 example test)
967+
2. **Book system over-engineered**: 7 section types, custom minibook templates, complex aggregation—all for a repository with minimal source code
968+
3. **Missing getting-started**: `docs/TESTS.md` is comprehensive but lacks simple "run your first hypothesis test" tutorial
969+
4. **Stale documentation risk**: `docs/TESTS.md` documents hypothesis features extensively; if implementation changes, docs may not update
970+
971+
#### Security & Quality
972+
1. **Mocked UV in tests**: `.rhiza/tests/conftest.py` likely mocks UV binary; integration tests may miss real UV behavior
973+
2. **Bandit exclusions**: `make security` runs bandit with `-c pyproject.toml` but no `[tool.bandit]` section visible in provided `pyproject.toml`
974+
3. **No dependency scanning**: `pip-audit` runs but no automated PR generation for vulnerabilities (unlike Renovate for version updates)
975+
4. **Template sync conflicts**: `make sync` uses `--force` flag (rhiza.mk:101); could overwrite local changes if not careful
976+
977+
### Score
978+
979+
**7/10** — Solid, production-ready template system with minor gaps in hypothesis testing utilization and documentation structure
980+
981+
**Rationale:**
982+
- **+3**: Exceptional Makefile architecture, comprehensive CI/CD dual support, modular template system
983+
- **+2**: Strong testing infrastructure with property/stress/benchmark separation, detailed test documentation
984+
- **+1**: Innovative book compilation system, Marimo notebook integration, UV-first dependency management
985+
- **+1**: Security scanning, code quality enforcement, mature fixture design
986+
- **-1**: Hypothesis testing infrastructure underutilized (1 example test, no project-specific property tests)
987+
- **-1**: Overlapping test directory structure causes confusion (tests/ vs .rhiza/tests/)
988+
- **-1**: Shell complexity in Makefiles increases maintenance burden, no artifact preservation in CI
989+
- **-1**: Book system over-engineered for current content volume (1 notebook, minimal source code)
990+
991+
**Would be 8-9 if:**
992+
- Project-specific hypothesis tests existed (e.g., property-based tests for template synchronization logic, Makefile target parsing)
993+
- Clear documentation explaining `tests/` vs `.rhiza/tests/` ownership model
994+
- Shell logic in book.mk, marimo.mk refactored to Python scripts with unit tests
995+
- GitHub Actions workflows upload HTML reports as artifacts
996+
- Hypothesis configuration defined in `pyproject.toml` with project-wide settings
997+
- Additional Marimo notebooks demonstrate real-world template usage patterns
998+
999+
**Would be 9-10 if:**
1000+
- Hypothesis tests coverage >30 tests across template logic, Makefile parsing, sync operations
1001+
- Book system simplified or justified with substantial documentation content
1002+
- Automated validation ensures GitHub/GitLab CI stay in sync
1003+
- Integration tests use real UV rather than mocks (or document mock limitations)
1004+
- `make book` validates minimum required sections before compilation
1005+
1006+
**Current state appropriate for:** A mature template repository that prioritizes modularity, multi-platform support, and comprehensive documentation infrastructure. The hypothesis testing foundation is excellent but underutilized; adding 10-20 property-based tests for core template logic would significantly increase confidence. The dual test hierarchy (tests/ vs .rhiza/tests/) needs architectural documentation to clarify intent.
1007+

0 commit comments

Comments
 (0)