Skip to content

Commit ad5bc96

Browse files
committed
docs: updates after openapi client patterns and further contributor guides
updates contributing guide to include development setup, available make commands, new generators, testing, remote operations, ci/cd pipeline, and lefthook setup. it also removes the old contributing guide. updates design docs to describe remote flag synchronization and architecture patterns. Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
1 parent 9b90212 commit ad5bc96

File tree

5 files changed

+1008
-12
lines changed

5 files changed

+1008
-12
lines changed

CONTRIBUTING.md

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,71 @@
22

33
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.
44

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+
570
## Contributing New Generators
671

772
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
62127

63128
For more information on the integration testing framework, see [Integration Testing](./docs/integration-testing.md).
64129

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+
65178
## Setting Up Lefthook
66179

67180
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:
92205

93206
The pre-push hook is configured to run the following checks:
94207

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.
97215

98216
### Running Hooks Manually
99217

DESIGN.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,53 @@ Benefits of the code generation approach:
2121
- **Modular and Extensible Design**: Create a format that allows for future extensions and modularization of flags.
2222
- **Language Agnostic**: Support multiple programming languages through a common flag manifest format.
2323
- **Provider Independence**: Work with any feature flag provider that can be adapted to the OpenFeature API.
24+
- **Remote Flag Synchronization**: Enable bidirectional synchronization with remote flag management services through a standardized API.
2425

2526
## Non-Goals
2627

2728
- **Full Provider Integration**: The initial scope does not include creating tools to convert provider-specific configurations to the new flag manifest format.
2829
- **Validation of Flag Configs**: The project will not initially focus on validating flag configurations for consistency with the flag manifest.
2930
- **General-Purpose Configuration**: The project will not aim to create a general-purpose configuration tool for feature flags beyond the scope of the code generation tool.
3031
- **Runtime Flag Management**: The CLI is not intended to replace provider SDKs for runtime flag evaluation.
32+
33+
## Architecture Patterns
34+
35+
### OpenAPI Client Pattern
36+
37+
The CLI uses an OpenAPI-driven architecture for all remote operations. This pattern provides several benefits:
38+
39+
#### Benefits
40+
41+
1. **Type Safety**: Generated clients from OpenAPI specs ensure compile-time checking of API requests and responses
42+
2. **Self-Documenting**: The OpenAPI specification serves as both implementation guide and documentation
43+
3. **Provider Agnostic**: Any service implementing the Manifest Management API can integrate with the CLI
44+
4. **Maintainability**: Changes to the API are made in one place (the spec) and propagate to all consumers
45+
5. **Extensibility**: New endpoints and operations can be added without breaking existing functionality
46+
47+
#### Implementation
48+
49+
The pattern follows this architecture:
50+
51+
```
52+
OpenAPI Spec (api/v0/sync.yaml)
53+
54+
Generated Client (internal/api/client/*.gen.go)
55+
56+
Wrapper Client (internal/api/sync/client.go)
57+
58+
CLI Commands (internal/cmd/pull.go, push.go)
59+
```
60+
61+
For detailed implementation guidelines, see the [OpenAPI Client Pattern documentation](./docs/openapi-client-pattern.md).
62+
63+
### Code Generation Pattern
64+
65+
The CLI generates strongly-typed flag accessors for multiple languages. This pattern:
66+
67+
1. **Parses** the flag manifest JSON/YAML
68+
2. **Validates** the flag configurations against the schema
69+
3. **Transforms** the data into language-specific structures
70+
4. **Generates** code using Go templates
71+
5. **Formats** the output according to language conventions
72+
73+
Each generator follows a consistent interface, making it easy to add support for new languages.

Makefile

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ help:
1515
@echo " generate-api - Generate API clients from OpenAPI specs"
1616
@echo " generate-docs - Generate documentation"
1717
@echo " generate-schema - Generate schema"
18-
@echo " verify-generate - Check if generated files are up to date"
18+
@echo " verify-generate - Check if all generated files are up to date"
1919
@echo " fmt - Format Go code"
20-
@echo " ci - Run all CI checks locally (lint, test, verify-generate)"
20+
@echo " ci - Run all CI checks locally (fmt, lint, test, verify-generate)"
2121

2222
.PHONY: build
2323
build:
@@ -110,15 +110,31 @@ lint-fix:
110110
@echo "Linting with auto-fix completed successfully!"
111111

112112
.PHONY: verify-generate
113-
verify-generate: generate
114-
@echo "Checking for uncommitted changes after generation..."
115-
@if [ ! -z "$$(git status --porcelain)" ]; then \
116-
echo "Error: Generation produced diff. Please run 'make generate' and commit the results."; \
117-
git diff; \
113+
verify-generate:
114+
@echo "Checking if all generated files are up-to-date..."
115+
@make generate-api > /dev/null 2>&1
116+
@if [ ! -z "$$(git diff --name-only internal/api/client/)" ]; then \
117+
echo "❌ OpenAPI client needs regeneration"; \
118+
echo " Run: make generate-api"; \
119+
git diff --stat internal/api/client/; \
118120
exit 1; \
119121
fi
120-
@echo "All generated files are up to date!"
122+
@make generate-docs > /dev/null 2>&1
123+
@if [ ! -z "$$(git diff --name-only docs/)" ]; then \
124+
echo "❌ Documentation needs regeneration"; \
125+
echo " Run: make generate-docs"; \
126+
git diff --stat docs/; \
127+
exit 1; \
128+
fi
129+
@make generate-schema > /dev/null 2>&1
130+
@if [ ! -z "$$(git diff --name-only schema/)" ]; then \
131+
echo "❌ Schema needs regeneration"; \
132+
echo " Run: make generate-schema"; \
133+
git diff --stat schema/; \
134+
exit 1; \
135+
fi
136+
@echo "✅ All generated files are up-to-date!"
121137

122138
.PHONY: ci
123-
ci: lint test verify-generate
124-
@echo "All CI checks passed successfully!"
139+
ci: fmt lint test verify-generate
140+
@echo "All CI checks passed successfully!"

0 commit comments

Comments
 (0)