MCPcopy Create free account
hub / github.com/github/gh-aw / validateConcurrencyGroupExpression

Function validateConcurrencyGroupExpression

pkg/workflow/concurrency_validation.go:51–75  ·  view source on GitHub ↗

validateConcurrencyGroupExpression validates the syntax of a custom concurrency group expression. It checks for common syntactic errors that would cause runtime failures: - Unbalanced ${{ }} braces - Missing closing braces - Malformed GitHub Actions expressions - Invalid operator placement Returns

(group string)

Source from the content-addressed store, hash-verified

49//
50// Returns an error if validation fails, nil otherwise.
51func validateConcurrencyGroupExpression(group string) error {
52 if strings.TrimSpace(group) == "" {
53 return NewValidationError(
54 "concurrency",
55 "empty concurrency group expression",
56 "the concurrency group expression is empty or contains only whitespace",
57 "Provide a non-empty concurrency group name or expression. Example: 'my-workflow-${{ github.ref }}'",
58 )
59 }
60
61 concurrencyValidationLog.Printf("Validating concurrency group expression: %s", group)
62
63 // Check for balanced ${{ }} braces
64 if err := validateBalancedBraces(group); err != nil {
65 return err
66 }
67
68 // Extract and validate each GitHub Actions expression within ${{ }}
69 if err := validateExpressionSyntax(group); err != nil {
70 return err
71 }
72
73 concurrencyValidationLog.Print("Concurrency group expression validation passed")
74 return nil
75}
76
77// extractConcurrencyGroupFromYAML extracts the group value from a YAML-formatted concurrency string.
78// The input is expected to be in the format generated by the compiler:

Calls 5

validateBalancedBracesFunction · 0.85
validateExpressionSyntaxFunction · 0.85
PrintMethod · 0.80
NewValidationErrorFunction · 0.70
PrintfMethod · 0.45