3.3 KiB
3.3 KiB
Contributing to RelSpec
Thank you for your interest in contributing to RelSpec.
Development Setup
Prerequisites
- Go 1.21 or higher
- Git
- (Optional) golangci-lint for linting
- (Optional) Docker for database testing
Getting Started
- Clone the repository:
git clone https://github.com/wdevs/relspecgo.git
cd relspecgo
- Install dependencies:
go mod download
- Run tests:
go test ./...
- Build the project:
go build -o relspec ./cmd/relspec
Project Structure
relspecgo/
├── cmd/ # CLI application entry point
├── pkg/
│ ├── readers/ # Input format readers (XML, JSON, DCTX, DB, GORM, Bun)
│ ├── writers/ # Output format writers (GORM, Bun, JSON, YAML)
│ ├── models/ # Internal data models for relations
│ └── transform/ # Transformation and validation logic
├── examples/ # Usage examples and sample files
├── tests/ # Integration tests
└── .claude/ # Claude Code configuration and commands
Adding New Readers
To add a new input format reader:
- Create a new file in
pkg/readers/(e.g.,myformat_reader.go) - Implement the
Readerinterface:
type Reader interface {
Read(source string) (*models.Schema, error)
}
- Add tests in
pkg/readers/myformat_reader_test.go - Register the reader in the CLI
Adding New Writers
To add a new output format writer:
- Create a new file in
pkg/writers/(e.g.,myformat_writer.go) - Implement the
Writerinterface:
type Writer interface {
Write(schema *models.Schema, destination string) error
}
- Add tests in
pkg/writers/myformat_writer_test.go - Register the writer in the CLI
Code Style
- Follow standard Go conventions
- Use
gofmtfor formatting - Run
go vetto check for issues - Use meaningful variable and function names
- Add comments for exported functions and types
Testing
- Write unit tests for all new functionality
- Aim for >80% code coverage
- Use table-driven tests where appropriate
- Include both positive and negative test cases
Running Tests
# All tests
go test ./...
# With coverage
go test -cover ./...
# Verbose output
go test -v ./...
# Specific package
go test ./pkg/readers/...
Committing Changes
- Write clear, descriptive commit messages
- Follow conventional commits format:
type(scope): description- Types: feat, fix, docs, test, refactor, chore
- Example:
feat(readers): add PostgreSQL support
- Keep commits focused and atomic
- Reference issues in commit messages when applicable
Pull Request Process
- Create a feature branch from
master - Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Update documentation if needed
- Submit a pull request with a clear description
Claude Code Commands
This project includes Claude Code slash commands for common tasks:
/test- Run all tests/build- Build the binary/lint- Run linters/coverage- Generate coverage report
Questions or Issues?
- Open an issue for bugs or feature requests
- Start a discussion for questions or ideas
- Check existing issues before creating new ones
License
By contributing to RelSpec, you agree that your contributions will be licensed under the Apache License 2.0.