Repository navigation
feat: add generated client validation - #30
kriscoleman wants to merge 1 commit into
Conversation
fab0a7c to
95369ca
Compare
95369ca to
87d1c41
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a generated client validation feature to ensure that type-safe OpenFeature clients remain synchronized with flag manifests. When developers modify flag manifests but forget to regenerate client code, this feature detects the drift in CI workflows.
Key Changes:
- New validation inputs (
validate-generators,validate-generators-strict,validate-generators-output-dir) to configure client generation validation - New validation outputs (
validation-failed,validation-changes,validation-summary) to report validation results - Automated PR comments with remediation steps when generated files are out of sync
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| action.yml | Adds validation inputs/outputs and implements core validation logic with git diff checking |
| README.md | Documents the new validation feature with usage examples and configuration options |
| .github/workflows/test.yml | Adds comprehensive test scenarios for validation feature including multi-generator support |
| test-fixtures/test-manifest-modified.json | Provides a modified manifest for testing drift detection |
| test-fixtures/README.md | Documents test fixture structure and usage patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| log_info "📝 Files that need to be regenerated:" | ||
|
|
||
| # Get all changed files | ||
| CHANGED_FILES=$(git diff --name-only 2>/dev/null; git diff --cached --name-only 2>/dev/null | sort -u) |
There was a problem hiding this comment.
The sort -u command only applies to the second git diff --cached command, not both commands. This should use process substitution or combine the outputs before sorting: CHANGED_FILES=$(sort -u <(git diff --name-only 2>/dev/null) <(git diff --cached --name-only 2>/dev/null))
| CHANGED_FILES=$(git diff --name-only 2>/dev/null; git diff --cached --name-only 2>/dev/null | sort -u) | |
| CHANGED_FILES=$(sort -u <(git diff --name-only 2>/dev/null) <(git diff --cached --name-only 2>/dev/null)) |
| # Handle generation failures | ||
| if [ -n "$FAILED_GENERATORS" ]; then | ||
| VALIDATION_FAILED="true" | ||
| FAILED_COUNT=$(echo "$FAILED_GENERATORS" | wc -w | xargs) |
There was a problem hiding this comment.
The failed count logic doesn't account for leading/trailing whitespace in FAILED_GENERATORS. If FAILED_GENERATORS is empty or contains only whitespace, this will return '0' correctly, but the variable name suggests it should handle a space-separated list. Consider using array-based counting instead: FAILED_COUNT=${#FAILED_GENERATORS_ARRAY[@]} where the array is populated during the loop.
| for gen in $GENERATORS_CLEAN; do | ||
| log_info " openfeature generate $gen --manifest $MANIFEST_FOR_GENERATION" | ||
| done |
There was a problem hiding this comment.
The remediation command uses $MANIFEST_FOR_GENERATION which might be $LOCAL_MANIFEST_PATH, a temporary path that won't exist in the user's local environment. Consider using ${{ inputs.manifest }} consistently in user-facing messages as shown in line 842.
| @@ -0,0 +1,54 @@ | |||
| # Test Fixtures | |||
|
|
|||
| This directory contains test fixtures, for instance those used for validating the generated client validation feature. | |||
There was a problem hiding this comment.
[nitpick] Removed redundant word 'for instance' - simplified to 'This directory contains test fixtures used for validating the generated client validation feature.'
| This directory contains test fixtures, for instance those used for validating the generated client validation feature. | |
| This directory contains test fixtures used for validating the generated client validation feature. |
0c68135 to
bd6e509
Compare
Adds a new feature to validate generated OpenFeature clients, ensuring they are up-to-date with the flag manifest. This prevents developers from using clients out of sync with their flag definitions. The feature includes: - Generation of clients using the OpenFeature CLI - Detection of uncommitted changes after generation - Reporting of out-of-sync files - Optional PR comments and workflow failure Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
bd6e509 to
290ba51
Compare
Why we need this/What this does
Sometimes teams may want to know if their generated clients are out of sync with their manifests.
For instance right now in my project we generate react and go clients, I want to the action to be able to tell me if our flags manifest is mutated but our generated clients aren't in-sync.
Theis PR adds validation to ensure generated OpenFeature clients stay in sync with flag manifests. When developers modify flag manifests but forget to regenerate client code, this feature catches it in CI.
What's New
validate-generatorsinput: Specify generator types to validate (e.g.,["react", "go"])validate-generators-strictinput: Fail workflow if files are out of sync (default:true)validate-generators-output-dirinput: Custom output directory for generated files (optional)validation-failed,validation-changes,validation-summaryHow It Works
When
validate-generatorsis specified, the action:Example Usage
Test Coverage
Added comprehensive test fixtures and workflow tests including:
Breaking Changes
None - purely additive feature.