-
Notifications
You must be signed in to change notification settings - Fork 4
Add support for validating multiple schema files #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ivanauth
wants to merge
3
commits into
authzed:main
Choose a base branch
from
ivanauth:feat/issue-6-multiple-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,72 @@ | ||
| #/bin/bash | ||
| ARGS="" | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Enable recursive globbing for ** patterns (bash 4+) | ||
| # Guard for bash 3.x compatibility (e.g., macOS default) | ||
| shopt -s nullglob | ||
| shopt -s globstar 2>/dev/null || true | ||
|
|
||
| ARGS="" | ||
| [[ $INPUT_FAIL_ON_WARN == "true" ]] && ARGS+=" --fail-on-warn" | ||
|
|
||
| /zed validate $ARGS $INPUT_VALIDATIONFILE | ||
| # Collect all files to validate | ||
| FILES=() | ||
| HAD_INPUT=0 | ||
|
|
||
| # Handle single file input (backward compatibility) | ||
| if [[ -n "$INPUT_VALIDATIONFILE" ]]; then | ||
| HAD_INPUT=1 | ||
| FILES+=("$INPUT_VALIDATIONFILE") | ||
| fi | ||
|
|
||
| # Handle multiple files input | ||
| if [[ -n "$INPUT_VALIDATIONFILES" ]]; then | ||
| HAD_INPUT=1 | ||
| # Replace commas with newlines and process each entry | ||
| # Use printf instead of echo to avoid option interpretation | ||
| while IFS= read -r entry; do | ||
| # Trim leading/trailing whitespace without breaking spaces in paths | ||
| entry="${entry#"${entry%%[![:space:]]*}"}" | ||
| entry="${entry%"${entry##*[![:space:]]}"}" | ||
| [[ -z "$entry" ]] && continue | ||
|
|
||
| # Check if entry contains glob pattern characters | ||
| if [[ "$entry" == *"*"* || "$entry" == *"?"* || "$entry" == *"["* ]]; then | ||
| # Expand glob pattern safely without eval (globstar enabled for ** support) | ||
| # Use an array assignment for safe glob expansion | ||
| expanded=() | ||
| # shellcheck disable=SC2206 | ||
| expanded=($entry) | ||
| for file in "${expanded[@]}"; do | ||
| [[ -f "$file" ]] && FILES+=("$file") | ||
| done | ||
| else | ||
| FILES+=("$entry") | ||
| fi | ||
| done <<< "$(printf '%s\n' "$INPUT_VALIDATIONFILES" | tr ',' '\n')" | ||
| fi | ||
|
|
||
| # Check if we have any files to validate | ||
| if [[ $HAD_INPUT -eq 0 ]]; then | ||
| echo "Error: No validation files provided. Set either 'validationfile' or 'validationfiles' input." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ${#FILES[@]} -eq 0 ]]; then | ||
| echo "Error: No files matched the provided patterns." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Validate each file | ||
| FAILED=0 | ||
| for file in "${FILES[@]}"; do | ||
| echo "Validating $file..." | ||
| # ARGS is intentionally unquoted for word splitting (may be empty or --fail-on-warn) | ||
| # Use -- to prevent filenames starting with - from being interpreted as options | ||
| # shellcheck disable=SC2086 | ||
| if ! /zed validate $ARGS -- "$file"; then | ||
| FAILED=1 | ||
| fi | ||
| done | ||
|
|
||
| exit $FAILED |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thank you