Thank you for your interest in contributing to HealthQL! This document provides guidelines and information for contributors.
- Be respectful and inclusive
- Welcome newcomers and help them get started
- Focus on constructive feedback
- Assume good intentions
- Xcode 15.0+
- Swift 6.0+
- macOS 13.0+
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/HealthQL.git cd HealthQL - Run tests to verify setup:
swift test
- Create a feature branch from
main:git checkout -b feature/your-feature-name
- Use descriptive branch names:
feature/add-blood-pressure-supportfix/parser-handles-empty-inputdocs/update-readme-examples
- Write tests first - We follow TDD. Write failing tests before implementation.
- Keep changes focused - One feature or fix per PR.
- Follow existing patterns - Match the code style of surrounding code.
- Update documentation - If adding features, update README and code comments.
- Use Swift's standard naming conventions
- Keep functions focused and small
- Add documentation comments for public APIs:
/// Parses a SQL query string into a HealthQuery IR /// - Parameter query: The SQL query string /// - Returns: The compiled HealthQuery /// - Throws: LexerError, ParserError, or CompilerError public static func parse(_ query: String) throws -> HealthQuery
- Use meaningful variable names
- Prefer clarity over brevity
Follow conventional commits format:
type(scope): description
[optional body]
[optional footer]
Types:
feat- New featurefix- Bug fixdocs- Documentation onlytest- Adding or updating testsrefactor- Code change that neither fixes a bug nor adds a featurechore- Maintenance tasks
Examples:
feat(parser): add support for BETWEEN operator
fix(executor): handle empty result sets correctly
docs: add examples for workout queries
test: add edge case tests for date parsing
- All new code must have tests
- Run the full test suite before submitting:
swift test - Aim for meaningful test coverage, not just line coverage
- Test edge cases and error conditions
Test naming convention:
@Test("Parser handles empty WHERE clause")
func parserEmptyWhere() throws {
// ...
}- All tests pass (
swift test) - Code follows project style
- Documentation is updated if needed
- Commit messages follow convention
- Branch is up to date with
main
Include:
- What - Brief description of changes
- Why - Motivation or issue being fixed
- How - Approach taken (if not obvious)
- Testing - How you tested the changes
Example:
## Summary
Add support for the HAVING clause in aggregation queries.
## Motivation
Closes #42. Users need to filter aggregated results.
## Changes
- Added HAVING token to lexer
- Extended parser to handle HAVING after GROUP BY
- Added `having` field to HealthQuery IR
- Updated executor to apply HAVING predicates
## Testing
- Added 5 new parser tests for HAVING syntax
- Added 3 integration tests for execution- Submit PR against
main - Automated tests will run
- Maintainer will review
- Address feedback if needed
- PR will be merged when approved
To add a new HealthKit type:
- Schema - Add to
QuantityTypeorCategoryTypeenum inSources/HealthQL/Core/ - Compiler - Update table name mapping in
Sources/HealthQLParser/Compiler.swift - Handler - Ensure handler supports the new type
- Tests - Add parser and execution tests
- Docs - Update README with new type
- Lexer - Add new tokens in
Sources/HealthQLParser/Lexer.swift - AST - Add node types in
Sources/HealthQLParser/AST.swift - Parser - Implement parsing in
Sources/HealthQLParser/Parser.swift - Compiler - Add IR generation in
Sources/HealthQLParser/Compiler.swift - IR - Extend
HealthQueryif needed inSources/HealthQL/Core/IR.swift - Executor - Implement execution in
Sources/HealthQL/Executor/ - Tests - Add comprehensive tests at each layer
Include:
- HealthQL version
- iOS/macOS version
- Minimal reproduction case
- Expected vs actual behavior
- Error messages or logs
Include:
- Use case description
- Proposed syntax (if applicable)
- Examples of how it would work
- Open a GitHub Discussion for questions
- Check existing issues before creating new ones
- Tag issues appropriately (
bug,enhancement,question)
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to HealthQL!