Contributing to Flint
This guide explains how to contribute to Flint Core.
Getting Started
Section titled “Getting Started”Prerequisites
Section titled “Prerequisites”- Rust (Edition 2024)
- Git
Clone Repository
Section titled “Clone Repository”git clone https://github.com/FlintTestMC/flint-core.gitcd flint-corecargo buildRun Tests
Section titled “Run Tests”cargo testSome tests must run serially:
cargo test -- --test-threads=1Project Structure
Section titled “Project Structure”flint-core/├── src/│ ├── lib.rs # Public API and re-exports│ ├── test_spec.rs # Test schema (JSON DSL)│ ├── traits.rs # Core traits│ ├── runner.rs # Test execution engine│ ├── loader.rs # Test file discovery│ ├── index.rs # Tag-based indexing│ ├── results.rs # Test result types│ ├── timeline.rs # Timeline aggregation│ ├── format.rs # Output formatting│ ├── spatial.rs # Spatial utilities│ └── utils.rs # Helper functions├── Cargo.toml└── README.mdModule Overview
Section titled “Module Overview”test_spec.rs
Section titled “test_spec.rs”Defines the JSON test format:
TestSpec- Complete test definitionBlock- Block state with propertiesActionType- All actions (place, assert, useItemOn, etc.)PlayerSlot,BlockFace- Enums for player/block interactions
traits.rs
Section titled “traits.rs”Core traits that servers implement:
FlintAdapter- Creates test worldsFlintWorld- Block operations and tick executionFlintPlayer- Inventory and item interactions
Helper types:
Item- Stackable inventory itemBlockData- Block state from worldBlockPos- Position type alias
runner.rs
Section titled “runner.rs”The TestRunner executes tests:
- Loads test specifications
- Creates world via adapter
- Executes timeline actions tick by tick
- Collects assertion results
results.rs
Section titled “results.rs”Result types:
TestResult- Single test resultTestSummary- Aggregated resultsAssertFailure- Detailed failure information
format.rs
Section titled “format.rs”Output formatters:
- Compact human-readable output
- Verbose mode
- JSON, TAP, JUnit XML
Code Style
Section titled “Code Style”Formatting
Section titled “Formatting”cargo fmtLinting
Section titled “Linting”cargo clippyAll warnings should be fixed.
Documentation
Section titled “Documentation”- Doc comments for public items
- Examples in doc comments where helpful
- Keep comments concise and accurate
Adding New Features
Section titled “Adding New Features”New Action Type
Section titled “New Action Type”- Add variant to
ActionTypeintest_spec.rs:
#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(tag = "do", rename_all = "snake_case")]pub enum ActionType { // Existing actions...
/// Description of new action NewAction { pos: [i32; 3], some_field: String, },}- Add handler in
runner.rs:
fn execute_action(&self, world: &mut dyn FlintWorld, ...) -> ActionOutcome { match action { // Existing handlers...
ActionType::NewAction { pos, some_field } => { // Implementation ActionOutcome::Action } }}- Add validation in
TestSpec::validate()if needed - Write tests
- Update documentation
New Output Format
Section titled “New Output Format”Add new formatter in format.rs:
pub fn print_my_format(results: &[TestResult], elapsed: Duration) { // Format implementation}Add method to TestSummary in results.rs:
pub fn print_my_format(&self) { format::print_my_format(&self.results, self.elapsed());}Testing
Section titled “Testing”Unit Tests
Section titled “Unit Tests”Each module has a test submodule:
#[cfg(test)]mod tests { use super::*;
#[test] fn test_feature() { // Arrange let input = ...;
// Act let result = function(input);
// Assert assert_eq!(result, expected); }}Serial Tests
Section titled “Serial Tests”Tests that modify environment variables:
use serial_test::serial;
#[test]#[serial]fn test_with_env_vars() { std::env::set_var("INDEX_NAME", "test.json"); // Test logic}Temp Directories
Section titled “Temp Directories”use tempfile::TempDir;
#[test]fn test_file_operations() { let temp_dir = TempDir::new().unwrap(); let test_file = temp_dir.path().join("test.json"); // Create files, run tests, cleanup is automatic}Pull Request Process
Section titled “Pull Request Process”- Fork the repository
- Create branch:
git checkout -b feat/my-feature - Make changes with clear, focused commits
- Run tests:
cargo test - Run lints:
cargo clippy && cargo fmt --check - Push to your fork
- Open PR with clear description
Commit Messages
Section titled “Commit Messages”Follow conventional commits:
feat: add new action type for block breakingfix: correct power level calculation in assertionsdocs: update integration guidetest: add tests for multi-tick actionsrefactor: simplify timeline aggregationPR Description
Section titled “PR Description”## SummaryBrief description of changes
## Changes- Added X- Fixed Y- Updated Z
## TestingHow were these changes tested?
## Breaking ChangesList breaking changes (if applicable)Getting Help
Section titled “Getting Help”- Open an issue for bugs or feature requests
- Join Discord for discussions
- Tag maintainers for PR reviews
License
Section titled “License”Flint Core is MIT licensed. By contributing, you agree to license your contributions under the same terms.