Thank you for your interest in contributing to Dampen! This guide will help you get started with development, testing, and submitting changes.
- Rust 1.85 or later (Edition 2024)
- Git
git clone https://github.com/yourusername/dampen.git
cd dampen
cargo build --workspacecargo run -p counter
cargo run -p hello-world
cargo run -p todo-appPlease refer to CLAUDE.md for detailed code style guidelines. Key points:
- Max line width: 100 characters
- No panics: Use
Result<T, E>for all fallible operations - No
.unwrap()or.expect(): Clippy will deny these - Document public APIs: Use
///doc comments - Format before committing: Run
cargo fmt --all
Always run the following checks:
cargo fmt --all # Format code
cargo clippy --workspace -- -D warnings # Lint
cargo test --workspace # Run all testsUnit tests are located in each crate's tests/ directory or inline #[cfg(test)] modules.
# Run all tests
cargo test --workspace
# Run tests for a specific crate
cargo test -p dampen-core
# Run a single test
cargo test test_parse_valid_simple
# Run tests matching a pattern
cargo test parse_Integration tests are in the workspace tests/ directory.
cargo test -p integration-tests
cargo test -p contract-testsVisual regression tests ensure pixel-perfect consistency between Interpreted (dev) and Codegen (prod) modes.
Visual regression tests:
- Render the same UI in both Interpreted and Codegen modes
- Compare the rendered output pixel-by-pixel
- Generate a diff image highlighting any differences
- Fail if the difference exceeds a tolerance threshold (default: 0.001 or 0.1%)
# Run all visual tests
cargo test -p dampen-visual-tests
# Run with verbose output
cargo test -p dampen-visual-tests -- --nocaptureVisual test cases are XML files in tests/visual/cases/. Each test case should focus on a specific feature or widget.
Example: tests/visual/cases/button_with_padding.dampen
<dampen version="1.0">
<Column>
<Button text="Click Me" padding="20" align_x="center" />
</Column>
</dampen>After creating a new test case, generate the baseline images:
# Generate baselines for all test cases
bash scripts/generate_baselines.sh
# Generate baseline for a specific test
bash scripts/generate_baselines.sh tests/visual/cases/button_with_padding.dampenBaselines are stored in tests/visual/baselines/ and should be committed to Git.
When a visual test fails:
- Check the diff image: Located at
tests/visual/diffs/<test_name>_diff.png - Review the actual output: Located at
tests/visual/actual/<test_name>_actual.png - Compare with baseline: Located at
tests/visual/baselines/<test_name>_baseline.png
The diff image highlights differences in red, making it easy to spot discrepancies.
Update baselines when:
- You intentionally changed rendering behavior
- You added new layout features
- You fixed a rendering bug (after verifying the fix is correct)
DO NOT update baselines if:
- The diff shows an unintended regression
- You haven't investigated why the output changed
crates/dampen-visual-tests/
├── src/
│ ├── lib.rs # Core types (VisualTestCase, VisualTestResult)
│ ├── compare.rs # Image comparison logic
│ └── renderer.rs # Headless rendering (future)
└── tests/
└── integration_test.rs # Test runner
tests/visual/
├── cases/ # Test XML files
├── baselines/ # Expected output (PNG)
├── actual/ # Test output (PNG, gitignored)
└── diffs/ # Diff images (PNG, gitignored)
- Keep test cases focused: One feature or widget per test case
- Use descriptive names:
text_with_color.dampen, nottest1.dampen - Test edge cases: Empty text, long text, nested containers, etc.
- Document complex cases: Add comments in XML explaining what's being tested
- Review diffs carefully: Always inspect the diff image before updating baselines
Visual regression tests run automatically on CI. If a test fails:
- Download the diff artifact from the CI logs
- Investigate the difference
- Either fix the code or update the baseline (with justification)
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes: Follow code style guidelines
- Add tests: Ensure your changes are tested
- Run checks:
cargo fmt,cargo clippy,cargo test - Update baselines if needed: For visual changes, regenerate baselines
- Commit with clear messages: Describe what and why
- Push and create PR: Submit your pull request on GitHub
<type>: <short summary>
<detailed description>
Fixes #<issue_number>
Types: feat, fix, docs, test, refactor, chore
Example:
feat: add password attribute support to TextInput
- Added `password` attribute to TextInput widget
- Masks input characters in both Interpreted and Codegen modes
- Updated visual tests with password field test case
- Added backward compatibility for legacy `secure` attribute
Fixes #123
All contributions require code review. Reviewers will check:
- Code quality and style adherence
- Test coverage
- Documentation completeness
- Visual regression test results
- Questions: Open a GitHub Discussion
- Bugs: Open a GitHub Issue
- Feature Requests: Open a GitHub Issue with
[Feature Request]prefix
Thank you for contributing to Dampen!