validateExpressionSyntax validates the syntax of expressions within ${{ }}
(group string)
| 84 | |
| 85 | // validateExpressionSyntax validates the syntax of expressions within ${{ }} |
| 86 | func validateExpressionSyntax(group string) error { |
| 87 | matches := expressionBracesPattern.FindAllStringSubmatch(group, -1) |
| 88 | |
| 89 | expressionValidationLog.Printf("Found %d expression(s) to validate", len(matches)) |
| 90 | |
| 91 | for _, match := range matches { |
| 92 | if len(match) < 2 { |
| 93 | continue |
| 94 | } |
| 95 | |
| 96 | exprContent := strings.TrimSpace(match[1]) |
| 97 | if exprContent == "" { |
| 98 | return NewValidationError( |
| 99 | "expression", |
| 100 | "empty expression content", |
| 101 | "found empty expression '${{ }}' in: "+group, |
| 102 | "Provide a valid GitHub Actions expression inside '${{ }}'. Example: '${{ github.ref }}'", |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | // Check for common syntax errors |
| 107 | if err := validateExpressionContent(exprContent, group); err != nil { |
| 108 | return err |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | // validateExpressionContent validates the content inside ${{ }} |
| 116 | func validateExpressionContent(expr string, fullGroup string) error { |
no test coverage detected