-
Notifications
You must be signed in to change notification settings - Fork 2
feat: enhanced input validation and error handling #79
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
Merged
Conversation
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
- Add comprehensive input validation with helpful error messages - Validate required inputs (commands, dir, node_version) - Check node_version format and cache values - Verify directory existence and package.json presence - Add detailed error handling for command failures - Provide troubleshooting steps and debug information - Add comprehensive validation test suite - Test 7 different validation failure scenarios - Improve user experience with clear error messages
- Remove manual input validation checks - Add native pattern validation for node_version (regex: ^[0-9]+(\.[0-9]+)*$) - Add native pattern validation for cache (regex: ^(npm|yarn|pnpm)$) - Simplify validation tests to focus on error handling scenarios - Let GitHub Actions handle required input validation natively - Keep only essential error handling for command failures and directory checks
- Change single quotes to double quotes for consistency - Fixes potential YAML parsing issues with regex pattern
- GitHub Actions doesn't support pattern validation in input schema - Remove incorrect pattern parameters for node_version and cache - GitHub Actions only supports required, default, and description for inputs - Input validation would need to be done manually in action code if needed
- Clean up formatting by removing trailing spaces - No functional changes, just code style improvements
- Add parentheses around commands input to handle multi-line commands properly - Fixes 'syntax error near unexpected token' when commands contain newlines - Commands like 'npm ci\nnpm run test:cov' now execute correctly in bash if statement
- Add pattern validation for node_version: '^[0-9]+(\.[0-9]+)*$' - Add pattern validation for cache: '^(npm|yarn|pnpm)$' - Follows same pattern as bcgov/action-deployer-openshift - GitHub Actions does support pattern validation in action.yml - Provides native input validation before action execution
- Add sonar_token pattern: ^[a-zA-Z0-9]{20,}$ (alphanumeric, min 20 chars) - Add diff_branch pattern: ^[a-zA-Z0-9._/-]+$ (valid branch names) - Add repository pattern: ^[a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+$ (owner/repo format) - Add branch pattern: ^[a-zA-Z0-9._/-]*$ (valid branch names, allows empty) - Provides comprehensive input validation before action execution - Follows same patterns as bcgov/action-deployer-openshift
- Add dir pattern: ^[a-zA-Z0-9._/-]+$ (valid directory paths) - Allows alphanumeric, hyphens, underscores, dots, forward slashes - Prevents spaces and special characters that could cause shell issues - Supports common directory structures: frontend, src/components, .github - Completes pattern validation coverage for all practical inputs
703033a
to
5e23676
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds a new
triggered
output to the action and enhances error handling with better debugging information.🚀 New Features
Triggered Output
triggered
output that exposessteps.diff.outputs.triggered
Enhanced Error Handling
🛠️ Input Validation
Pattern Validation
Added regex pattern validation for:
^[0-9]+(\.[0-9]+)*$
(e.g., '18', '20', '22')^(npm|yarn|pnpm)$
(package manager validation)^[a-zA-Z0-9._/-]+$
(directory path validation)^[a-zA-Z0-9]{20,}$
(minimum 20 characters)^[a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+$
(owner/repo format)^[a-zA-Z0-9._/-]+$
(branch name validation)🧪 Testing
Trigger Behavior Verification
Test Strategy
triggered
output works correctly📈 Benefits
🔍 Example Usage