|
| 1 | +# Contributing to Canon |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Canon! This document provides guidelines and instructions for contributing. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Go 1.22 or later |
| 10 | +- Node.js 18+ (for running generated TypeScript) |
| 11 | +- npm (for TypeScript dependencies) |
| 12 | + |
| 13 | +### Getting Started |
| 14 | + |
| 15 | +```bash |
| 16 | +# Clone the repository |
| 17 | +git clone https://github.com/WarforgeTech/canon.git |
| 18 | +cd canon |
| 19 | + |
| 20 | +# Build the CLI |
| 21 | +make build |
| 22 | + |
| 23 | +# Run tests |
| 24 | +make test |
| 25 | + |
| 26 | +# Verify everything works |
| 27 | +./bin/canon build examples/hello/hello.canon.json |
| 28 | +``` |
| 29 | + |
| 30 | +## How to Contribute |
| 31 | + |
| 32 | +### Reporting Bugs |
| 33 | + |
| 34 | +1. Check if the bug has already been reported in [Issues](https://github.com/WarforgeTech/canon/issues) |
| 35 | +2. If not, create a new issue using the bug report template |
| 36 | +3. Include steps to reproduce, expected behavior, and actual behavior |
| 37 | + |
| 38 | +### Suggesting Features |
| 39 | + |
| 40 | +1. Check existing issues and discussions for similar ideas |
| 41 | +2. Create a new issue using the feature request template |
| 42 | +3. Describe the use case and why this feature would be valuable |
| 43 | + |
| 44 | +### Submitting Code |
| 45 | + |
| 46 | +1. Fork the repository |
| 47 | +2. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 48 | +3. Make your changes |
| 49 | +4. Run tests (`make test`) |
| 50 | +5. Commit your changes with a clear message |
| 51 | +6. Push to your fork |
| 52 | +7. Open a Pull Request |
| 53 | + |
| 54 | +## Code Style |
| 55 | + |
| 56 | +### Go Code |
| 57 | + |
| 58 | +- Follow standard Go conventions |
| 59 | +- Run `go fmt` before committing |
| 60 | +- Add tests for new functionality |
| 61 | +- Keep functions focused and well-documented |
| 62 | + |
| 63 | +### TypeScript (runtime-ts/) |
| 64 | + |
| 65 | +- Use TypeScript strict mode |
| 66 | +- Document public APIs with JSDoc comments |
| 67 | + |
| 68 | +## Testing |
| 69 | + |
| 70 | +### Running Tests |
| 71 | + |
| 72 | +```bash |
| 73 | +# Run all Go tests |
| 74 | +make test |
| 75 | + |
| 76 | +# Run tests with verbose output |
| 77 | +go test -v ./... |
| 78 | + |
| 79 | +# Run a specific test |
| 80 | +go test -v ./pkg/validate -run TestTypechecking |
| 81 | +``` |
| 82 | + |
| 83 | +### Writing Tests |
| 84 | + |
| 85 | +- Add unit tests for new functions in `*_test.go` files |
| 86 | +- Add integration tests for CLI commands in `cmd/canon/integration_test.go` |
| 87 | +- For Canon programs, add golden tests in the `.canon.json` file |
| 88 | + |
| 89 | +## Pull Request Guidelines |
| 90 | + |
| 91 | +- Keep PRs focused on a single change |
| 92 | +- Update documentation if needed |
| 93 | +- Ensure all tests pass |
| 94 | +- Add tests for new functionality |
| 95 | +- Reference related issues in the PR description |
| 96 | + |
| 97 | +## Project Structure |
| 98 | + |
| 99 | +``` |
| 100 | +canon/ |
| 101 | +├── cmd/canon/ # CLI commands |
| 102 | +├── pkg/ |
| 103 | +│ ├── ir/ # Intermediate representation types |
| 104 | +│ ├── validate/ # Validation (schema, types, effects) |
| 105 | +│ ├── codegen/ # Code generation (TypeScript) |
| 106 | +│ ├── policy/ # OPA/Rego policy engine |
| 107 | +│ └── testing/ # Test runner |
| 108 | +├── runtime-ts/ # TypeScript runtime library |
| 109 | +├── schemas/ # JSON Schema definitions |
| 110 | +├── policies/ # Default Rego policies |
| 111 | +└── examples/ # Example Canon programs |
| 112 | +``` |
| 113 | + |
| 114 | +## Questions? |
| 115 | + |
| 116 | +- Open a [Discussion](https://github.com/WarforgeTech/canon/discussions) for questions |
| 117 | +- Check the [documentation](docs/) for detailed specifications |
| 118 | + |
| 119 | +## License |
| 120 | + |
| 121 | +By contributing, you agree that your contributions will be licensed under the MIT License. |
0 commit comments