@@ -3,53 +3,49 @@ name: Validate Regex Patterns
33on :
44 push :
55 paths :
6- - ' regex_patterns/**/*.yml'
7- - ' regex_patterns/**/*.yaml'
8- - ' .github/workflows/regex.yml'
9- - ' scripts/validatePattern.ps1'
6+ - " regex_patterns/**/*.yml"
7+ - " regex_patterns/**/*.yaml"
8+ - " .github/workflows/regex.yml"
9+ - " scripts/validatePattern.ps1"
1010 pull_request :
1111 paths :
12- - ' regex_patterns/**/*.yml'
13- - ' regex_patterns/**/*.yaml'
14- - ' .github/workflows/regex.yml'
15- - ' scripts/validatePattern.ps1'
12+ - " regex_patterns/**/*.yml"
13+ - " regex_patterns/**/*.yaml"
14+ - " .github/workflows/regex.yml"
15+ - " scripts/validatePattern.ps1"
1616 workflow_dispatch :
1717
1818jobs :
19- discover-patterns :
19+ validate :
2020 runs-on : ubuntu-latest
21- outputs :
22- matrix : ${{ steps.set-matrix.outputs.matrix }}
2321 steps :
2422 - uses : actions/checkout@v4
25-
26- - id : set-matrix
27- run : |
28- patterns=$(find regex_patterns -name "*.yml" -o -name "*.yaml" | jq -R -s -c 'split("\n")[:-1] | map({file: ., name: (. | split("/")[-1] | split(".")[0])})')
29- echo "matrix=$patterns" >> $GITHUB_OUTPUT
30- echo "Found patterns: $patterns"
3123
32- validate-pattern :
33- needs : discover-patterns
34- runs-on : ubuntu-latest
35- strategy :
36- fail-fast : false
37- matrix :
38- pattern : ${{ fromJson(needs.discover-patterns.outputs.matrix) }}
39- name : Validate ${{ matrix.pattern.name }}
40- steps :
41- - uses : actions/checkout@v4
42-
4324 - name : Setup PowerShell
4425 run : |
4526 sudo apt-get update
4627 sudo apt-get install -y powershell
47-
48- - name : Validate Pattern
28+
29+ - name : Validate All Patterns
4930 run : |
50- pwsh scripts/validatePattern.ps1 -YamlFilePath "${{ matrix.pattern.file }}"
51-
31+ failed=0
32+ for file in regex_patterns/*.yml regex_patterns/*.yaml; do
33+ if [ -f "$file" ]; then
34+ echo "Validating: $file"
35+ if ! pwsh scripts/validatePattern.ps1 -YamlFilePath "$file"; then
36+ failed=$((failed + 1))
37+ fi
38+ fi
39+ done
40+
41+ if [ $failed -gt 0 ]; then
42+ echo "❌ $failed pattern(s) failed validation"
43+ exit 1
44+ else
45+ echo "✅ All patterns validated successfully"
46+ fi
47+
5248 - name : Run Unit Tests
5349 run : |
54- echo "TODO: Implement unit tests for ${{ matrix.pattern.file }} "
55- # TODO: Add test runner command here
50+ echo "TODO: Implement unit tests for all patterns "
51+ # TODO: Add test runner command here
0 commit comments