Skip to content

Conversation

@middt
Copy link
Contributor

@middt middt commented Dec 2, 2025

Summary by Sourcery

Exclude .diagram.json files from vNext validation in the build-and-publish workflow while preserving validation failure reporting.

Build:

  • Update build-and-publish GitHub Actions workflow to temporarily rename and skip .diagram.json files during vNext validation, then restore them afterward.

CI:

  • Enhance vNext validation step in GitHub Actions to retain and surface the original validation exit code with more detailed guidance on common validation issues.

@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 2, 2025

Reviewer's Guide

This PR updates the build-and-publish GitHub Actions workflow to temporarily exclude *.diagram.json files from vNext validation by renaming them before the validation step, restoring them afterwards, and improving error reporting for validation failures.

Sequence diagram for updated CI validation and diagram file handling

sequenceDiagram
  participant Dev as Developer
  participant GitHubActions as GitHub_Actions_Workflow
  participant Runner as Workflow_Runner
  participant FS as Repository_Filesystem
  participant Validator as Vnext_Validator

  Dev->>GitHubActions: Push changes / open PR
  GitHubActions->>Runner: Start build_and_publish workflow

  Runner->>FS: Find core/*.diagram.json
  FS-->>Runner: List of diagram files (if any)
  alt Diagram files found
    Runner->>FS: Rename each *.diagram.json to *.diagram.json.skip
  else No diagram files
    Runner-->>Runner: Skip renaming
  end

  Runner->>Validator: vnext validate --resolve-refs
  alt Validation succeeds
    Validator-->>Runner: Exit code 0
    Runner->>FS: Find *.diagram.json.skip and restore to *.diagram.json
    Runner-->>GitHubActions: Continue workflow (validation success)
  else Validation fails
    Validator-->>Runner: Exit code != 0
    Runner->>Runner: Store VALIDATION_EXIT_CODE
    Runner->>FS: Find *.diagram.json.skip and restore to *.diagram.json
    Runner->>Runner: Print detailed validation error hints
    Runner-->>GitHubActions: Exit 1 (fail job)
  end
Loading

Flow diagram for updated vNext validation step in CI workflow

flowchart TD
  subgraph job_validate_vnext["Job validate_vnext in build_and_publish workflow"]
    A_start["Start validation step"] --> B_find_diagrams
    B_find_diagrams["Find *.diagram.json files under core"] --> C_has_diagrams{Any diagram files found?}

    C_has_diagrams -- Yes --> D_rename_loop["For each diagram file: mv file to file.skip"]
    D_rename_loop --> E_run_validation

    C_has_diagrams -- No --> E_run_validation["Run vnext validate --resolve-refs"]

    E_run_validation --> F_validation_ok{Validation successful?}

    F_validation_ok -- Yes --> G_restore_files["Find and restore *.diagram.json.skip back to *.diagram.json"]
    G_restore_files --> H_success["Echo success message and continue workflow"]

    F_validation_ok -- No --> I_capture_exit["Capture validation exit code"]
    I_capture_exit --> G_restore_files
    G_restore_files --> J_error_check{Validation exit code nonzero?}

    J_error_check -- Yes --> K_print_errors["Print detailed validation error guidance"]
    K_print_errors --> L_fail_step["Exit 1 (fail job)"]

    J_error_check -- No --> H_success
  end
Loading

File-Level Changes

Change Details Files
Exclude diagram files from vNext validation by renaming them before running the validator and restoring them afterwards.
  • Add a pre-validation step that finds all '.diagram.json' files under 'core' and renames them with a '.skip' suffix to avoid validation
  • Use defensive checks (find with 2>/dev/null and -n) to handle the case where no diagram files are present
  • Restore previously renamed diagram files after validation by converting '.diagram.json.skip' back to '*.diagram.json'
.github/workflows/build-and-publish.yml
Track vNext validation exit code explicitly and enhance the failure messaging.
  • Introduce VALIDATION_EXIT_CODE variable to capture the exit status of 'vnext validate --resolve-refs' while allowing post-processing steps to run
  • After restoring diagram files, exit with the captured validation code if validation failed
  • Replace the previous single-line failure message with a more detailed, structured explanation of likely validation issues and explicitly note that diagram files are excluded
.github/workflows/build-and-publish.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@middt middt merged commit 79d03f1 into release-v0.0 Dec 2, 2025
1 of 3 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch master

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The use of echo "$DIAGRAM_FILES" | while read file; do ... will split on whitespace and may break for diagram file paths containing spaces; consider using find ... -print0 with while IFS= read -r -d '' file or while IFS= read -r file; do ... done <<< "$DIAGRAM_FILES" to handle arbitrary file names safely.
  • Relying on temporary renames (mv "$file" "${file}.skip") across the entire core tree is a bit brittle (e.g., if a later command exits before the restore loop runs); if possible, limit the scope of the rename to the exact directories validated or adjust the validation command to ignore the diagram files instead of mutating the working tree.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The use of `echo "$DIAGRAM_FILES" | while read file; do ...` will split on whitespace and may break for diagram file paths containing spaces; consider using `find ... -print0` with `while IFS= read -r -d '' file` or `while IFS= read -r file; do ... done <<< "$DIAGRAM_FILES"` to handle arbitrary file names safely.
- Relying on temporary renames (`mv "$file" "${file}.skip"`) across the entire `core` tree is a bit brittle (e.g., if a later command exits before the restore loop runs); if possible, limit the scope of the rename to the exact directories validated or adjust the validation command to ignore the diagram files instead of mutating the working tree.

## Individual Comments

### Comment 1
<location> `.github/workflows/build-and-publish.yml:96-108` </location>
<code_context>

+        # Temporarily rename diagram files to exclude them from validation
+        echo "📋 Excluding diagram files from validation..."
+        DIAGRAM_FILES=$(find core -name "*.diagram.json" -type f 2>/dev/null || true)
+        if [ -n "$DIAGRAM_FILES" ]; then
+          echo "$DIAGRAM_FILES" | while read file; do
+            if [ -f "$file" ]; then
+              mv "$file" "${file}.skip"
</code_context>

<issue_to_address>
**suggestion (bug_risk):** The `echo ... | while read` pattern is brittle for filenames with spaces and can be simplified.

`echo "$DIAGRAM_FILES" | while read file` will split on spaces and special characters, so any diagram path containing them may be processed incorrectly. You can avoid this by iterating directly over `find`’s output and preserving paths:

```sh
find core -name "*.diagram.json" -type f 2>/dev/null | while IFS= read -r file; do
  mv "$file" "${file}.skip"
  echo "  Excluded: $file"
done
```

```suggestion
        # Temporarily rename diagram files to exclude them from validation
        echo "📋 Excluding diagram files from validation..."
        DIAGRAM_FILES=$(find core -name "*.diagram.json" -type f 2>/dev/null || true)
        if [ -n "$DIAGRAM_FILES" ]; then
          find core -name "*.diagram.json" -type f 2>/dev/null | while IFS= read -r file; do
            if [ -f "$file" ]; then
              mv "$file" "${file}.skip"
              echo "  Excluded: $file"
            fi
          done
        else
          echo "  No diagram files found to exclude"
        fi
```
</issue_to_address>

### Comment 2
<location> `.github/workflows/build-and-publish.yml:131-140` </location>
<code_context>
+        # Exit with validation error code if validation failed
</code_context>

<issue_to_address>
**issue (bug_risk):** The comment claims to propagate the original validation exit code, but the script always exits with status 1.

The code always does `exit 1` rather than using `VALIDATION_EXIT_CODE`. If you intend to preserve the `vnext validate` exit code, you could do:

```sh
if [ "$VALIDATION_EXIT_CODE" -ne 0 ]; then
  # ... messages ...
  exit "$VALIDATION_EXIT_CODE"
fi
```

If you instead want to normalize all failures to `1`, please update the comment so it doesn’t imply the original validation code is propagated.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +96 to +108
# Temporarily rename diagram files to exclude them from validation
echo "📋 Excluding diagram files from validation..."
DIAGRAM_FILES=$(find core -name "*.diagram.json" -type f 2>/dev/null || true)
if [ -n "$DIAGRAM_FILES" ]; then
echo "$DIAGRAM_FILES" | while read file; do
if [ -f "$file" ]; then
mv "$file" "${file}.skip"
echo " Excluded: $file"
fi
done
else
echo " No diagram files found to exclude"
fi
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): The echo ... | while read pattern is brittle for filenames with spaces and can be simplified.

echo "$DIAGRAM_FILES" | while read file will split on spaces and special characters, so any diagram path containing them may be processed incorrectly. You can avoid this by iterating directly over find’s output and preserving paths:

find core -name "*.diagram.json" -type f 2>/dev/null | while IFS= read -r file; do
  mv "$file" "${file}.skip"
  echo "  Excluded: $file"
done
Suggested change
# Temporarily rename diagram files to exclude them from validation
echo "📋 Excluding diagram files from validation..."
DIAGRAM_FILES=$(find core -name "*.diagram.json" -type f 2>/dev/null || true)
if [ -n "$DIAGRAM_FILES" ]; then
echo "$DIAGRAM_FILES" | while read file; do
if [ -f "$file" ]; then
mv "$file" "${file}.skip"
echo " Excluded: $file"
fi
done
else
echo " No diagram files found to exclude"
fi
# Temporarily rename diagram files to exclude them from validation
echo "📋 Excluding diagram files from validation..."
DIAGRAM_FILES=$(find core -name "*.diagram.json" -type f 2>/dev/null || true)
if [ -n "$DIAGRAM_FILES" ]; then
find core -name "*.diagram.json" -type f 2>/dev/null | while IFS= read -r file; do
if [ -f "$file" ]; then
mv "$file" "${file}.skip"
echo " Excluded: $file"
fi
done
else
echo " No diagram files found to exclude"
fi

Comment on lines +131 to +140
# Exit with validation error code if validation failed
if [ $VALIDATION_EXIT_CODE -ne 0 ]; then
echo ""
echo "❌ vNext validation failed"
echo "Please check the validation errors above and fix them before proceeding"
echo "=========================================="
echo "Validation errors found in the following areas:"
echo "1. Schema files - Check if schema files are properly formatted"
echo "2. Task files - Check for missing required properties (tags, valid type values)"
echo ""
echo "Common issues to check:"
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): The comment claims to propagate the original validation exit code, but the script always exits with status 1.

The code always does exit 1 rather than using VALIDATION_EXIT_CODE. If you intend to preserve the vnext validate exit code, you could do:

if [ "$VALIDATION_EXIT_CODE" -ne 0 ]; then
  # ... messages ...
  exit "$VALIDATION_EXIT_CODE"
fi

If you instead want to normalize all failures to 1, please update the comment so it doesn’t imply the original validation code is propagated.

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