Skip to content

feat: add generated client validation - #30

Open
kriscoleman wants to merge 1 commit into
mainfrom
feat/validate-gen
Open

kriscoleman wants to merge 1 commit into
mainfrom
feat/validate-gen

Conversation

@kriscoleman

@kriscoleman kriscoleman commented Nov 18, 2025 •

Copy link
Copy Markdown
Collaborator

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-generators input: Specify generator types to validate (e.g., ["react", "go"])
  • validate-generators-strict input: Fail workflow if files are out of sync (default: true)
  • validate-generators-output-dir input: Custom output directory for generated files (optional)
  • New outputs: validation-failed, validation-changes, validation-summary

How It Works

When validate-generators is specified, the action:

  1. Runs code generation for each specified generator
  2. Checks if any files were modified
  3. Reports results with actionable remediation steps
  4. Fails the workflow in strict mode (default)

Example Usage

- name: Validate generated clients
  uses: open-feature/action@v1
  with:
    manifest: "flags.json"
    validate-generators: '["react", "go"]'

Test Coverage

Added comprehensive test fixtures and workflow tests including:

  • Sample generated files (Go, React)
  • Modified manifest for drift detection
  • Real-world validation scenarios

Breaking Changes

None - purely additive feature.

@kriscoleman kriscoleman changed the title feat: add generated client validation with improved UX feat: add generated client validation Nov 18, 2025
@kriscoleman
kriscoleman marked this pull request as ready for review November 18, 2025 06:36
@kriscoleman
kriscoleman requested a review from Copilot November 18, 2025 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread action.yml
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)

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))

Suggested change
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))

Copilot uses AI. Check for mistakes.
Comment thread action.yml
# Handle generation failures
if [ -n "$FAILED_GENERATORS" ]; then
VALIDATION_FAILED="true"
FAILED_COUNT=$(echo "$FAILED_GENERATORS" | wc -w | xargs)

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread action.yml
Comment on lines +806 to +808
for gen in $GENERATORS_CLEAN; do
log_info " openfeature generate $gen --manifest $MANIFEST_FOR_GENERATION"
done

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread test-fixtures/README.md
@@ -0,0 +1,54 @@
# Test Fixtures

This directory contains test fixtures, for instance those used for validating the generated client validation feature.

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Removed redundant word 'for instance' - simplified to 'This directory contains test fixtures used for validating the generated client validation feature.'

Suggested change
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.

Copilot uses AI. Check for mistakes.
@kriscoleman
kriscoleman force-pushed the feat/validate-gen branch 3 times, most recently from 0c68135 to bd6e509 Compare November 18, 2025 06:59
@open-feature open-feature deleted a comment from github-actions Bot Nov 18, 2025
@open-feature open-feature deleted a comment from github-actions Bot Nov 18, 2025
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>
@open-feature open-feature deleted a comment from github-actions Bot Nov 18, 2025
@open-feature open-feature deleted a comment from github-actions Bot Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants