|
2 | 2 |
|
3 | 3 | Thank you for your interest in contributing to the OpenFeature CLI! This document provides guidelines and instructions to help you get started with contributing to the project. Whether you're fixing a bug, adding a new feature, or improving documentation, your contributions are greatly appreciated. |
4 | 4 |
|
| 5 | +## Development Setup |
| 6 | + |
| 7 | +1. **Prerequisites**: |
| 8 | + - Go 1.23 or later |
| 9 | + - Make |
| 10 | + - golangci-lint (will be auto-installed by make commands) |
| 11 | + |
| 12 | +2. **Clone the repository**: |
| 13 | + ```bash |
| 14 | + git clone https://github.com/open-feature/cli.git |
| 15 | + cd cli |
| 16 | + ``` |
| 17 | + |
| 18 | +3. **Build the project**: |
| 19 | + ```bash |
| 20 | + make build |
| 21 | + ``` |
| 22 | + |
| 23 | +4. **Run tests**: |
| 24 | + ```bash |
| 25 | + make test |
| 26 | + ``` |
| 27 | + |
| 28 | +5. **Run all CI checks locally**: |
| 29 | + ```bash |
| 30 | + make ci |
| 31 | + ``` |
| 32 | + |
| 33 | + This will format code, run linting, execute tests, and verify all generated files are up-to-date. |
| 34 | + |
| 35 | +## Available Make Commands |
| 36 | + |
| 37 | +The project includes a comprehensive Makefile with the following commands: |
| 38 | + |
| 39 | +```bash |
| 40 | +make help # Show all available commands |
| 41 | +make build # Build the CLI binary |
| 42 | +make install # Install the CLI to your system |
| 43 | +make lint # Run golangci-lint |
| 44 | +make lint-fix # Run golangci-lint with auto-fix |
| 45 | +make test # Run unit tests |
| 46 | +make test-integration # Run all integration tests |
| 47 | +make generate # Generate all code (API clients, docs, schema) |
| 48 | +make generate-api # Generate API clients from OpenAPI specs |
| 49 | +make generate-docs # Generate documentation |
| 50 | +make generate-schema # Generate schema |
| 51 | +make verify-generate # Check if all generated files are up to date |
| 52 | +make fmt # Format Go code |
| 53 | +make ci # Run all CI checks locally (fmt, lint, test, verify-generate) |
| 54 | +``` |
| 55 | + |
| 56 | +### Before Submitting a PR |
| 57 | + |
| 58 | +Run the following command to ensure your changes will pass CI: |
| 59 | + |
| 60 | +```bash |
| 61 | +make ci |
| 62 | +``` |
| 63 | + |
| 64 | +This command will: |
| 65 | +- Format your code |
| 66 | +- Run the linter |
| 67 | +- Execute all tests |
| 68 | +- Verify all generated files are up-to-date |
| 69 | + |
5 | 70 | ## Contributing New Generators |
6 | 71 |
|
7 | 72 | We welcome contributions for new generators to extend the functionality of the OpenFeature CLI. Below are the steps to contribute a new generator: |
@@ -62,6 +127,54 @@ make test-csharp-dagger |
62 | 127 |
|
63 | 128 | For more information on the integration testing framework, see [Integration Testing](./docs/integration-testing.md). |
64 | 129 |
|
| 130 | +## Contributing to Remote Operations |
| 131 | + |
| 132 | +The CLI uses an OpenAPI-driven architecture for remote flag synchronization. If you're contributing to the remote operations (pull/push commands) or API specifications: |
| 133 | + |
| 134 | +### Modifying the OpenAPI Specification |
| 135 | + |
| 136 | +1. **Edit the specification**: Update the OpenAPI spec at `api/v0/sync.yaml` |
| 137 | +2. **Regenerate the client**: Run `make generate-api` to regenerate the client code |
| 138 | +3. **Update the wrapper**: Modify `internal/api/sync/client.go` if needed |
| 139 | +4. **Test your changes**: Add or update tests in `internal/api/sync/` |
| 140 | + |
| 141 | +### Adding New Remote Operations |
| 142 | + |
| 143 | +1. **Define in OpenAPI**: Add the new operation to `api/v0/sync.yaml` |
| 144 | +2. **Regenerate**: Run `make generate-api` |
| 145 | +3. **Implement wrapper method**: Add the method in `internal/api/sync/client.go` |
| 146 | +4. **Create/update command**: Add or modify commands in `internal/cmd/` |
| 147 | +5. **Add tests**: Include unit tests and integration tests |
| 148 | +6. **Update documentation**: Update relevant documentation including command docs |
| 149 | + |
| 150 | +### API Compatibility |
| 151 | + |
| 152 | +When modifying the OpenAPI specification: |
| 153 | + |
| 154 | +- **Backwards Compatibility**: Ensure changes don't break existing integrations |
| 155 | +- **Versioning**: Use proper API versioning (currently v0) |
| 156 | +- **Documentation**: Update the specification descriptions and examples |
| 157 | +- **Schema Validation**: Ensure all request/response schemas are properly defined |
| 158 | + |
| 159 | +For detailed information about the OpenAPI client pattern, see the [OpenAPI Client Pattern documentation](./docs/openapi-client-pattern.md). |
| 160 | + |
| 161 | +## CI/CD Pipeline |
| 162 | + |
| 163 | +The project uses GitHub Actions for continuous integration. The following workflows run automatically: |
| 164 | + |
| 165 | +### PR Validation Workflow |
| 166 | +- **Generated Files Check**: Ensures all generated files (OpenAPI client, docs, schema) are up-to-date |
| 167 | +- **Format Check**: Verifies all Go code is properly formatted |
| 168 | +- **Tests**: Runs all unit tests |
| 169 | +- **Integration Tests**: Runs language-specific integration tests |
| 170 | + |
| 171 | +### PR Test Workflow |
| 172 | +- **Unit Tests**: Runs all unit tests |
| 173 | +- **Integration Tests**: Runs Dagger-based integration tests for all supported languages |
| 174 | + |
| 175 | +### PR Lint Workflow |
| 176 | +- **golangci-lint**: Runs comprehensive linting with golangci-lint v1.64 |
| 177 | + |
65 | 178 | ## Setting Up Lefthook |
66 | 179 |
|
67 | 180 | To streamline the setup of Git hooks for this project, we utilize [Lefthook](https://github.com/evilmartians/lefthook). Lefthook automates pre-commit and pre-push checks, ensuring consistent enforcement of best practices across the team. These checks include code formatting, documentation generation, and running tests. |
@@ -92,8 +205,13 @@ The pre-commit hook is configured to run the following check: |
92 | 205 |
|
93 | 206 | The pre-push hook is configured to run the following checks: |
94 | 207 |
|
95 | | -1. **Documentation Generation**: Runs `make generate-docs` to ensure documentation is up-to-date. If any changes are detected, the push will be blocked until the changes are committed. |
96 | | -2. **Tests**: Executes `make test` to verify that all tests pass. If any tests fail, the push will be blocked. |
| 208 | +1. **Generated Files Check**: Verifies all generated files are up-to-date: |
| 209 | + - **OpenAPI Client**: Ensures `internal/api/client/` is current with the OpenAPI spec |
| 210 | + - **Documentation**: Ensures `docs/` is current with the latest command structure |
| 211 | + - **Schema**: Ensures `schema/` files are up-to-date |
| 212 | +2. **Tests**: Executes `make test` to verify that all tests pass |
| 213 | + |
| 214 | +If any of these checks fail, the push will be blocked. Run `make generate` to update all generated files and commit the changes. |
97 | 215 |
|
98 | 216 | ### Running Hooks Manually |
99 | 217 |
|
|
0 commit comments