-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (72 loc) · 2.37 KB
/
Copy pathvalidate.yml
File metadata and controls
85 lines (72 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Validate Entities
on:
pull_request:
branches: [main]
paths:
- '_staging/**'
- '_patterns/**'
- '_lighthouses/**'
jobs:
validate:
runs-on: ubuntu-latest
name: Validate Pattern and Lighthouse Files
permissions:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install pyyaml
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
_staging/**/*.md
_patterns/**/*.md
_lighthouses/**/*.md
- name: Validate changed files
if: steps.changed-files.outputs.any_changed == 'true'
run: |
echo "Validating changed entity files..."
ERRORS=0
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "Checking: $file"
if ! python3 scripts/validate_entity.py "$file"; then
ERRORS=$((ERRORS + 1))
fi
done
if [ $ERRORS -gt 0 ]; then
echo "❌ Validation failed with $ERRORS file(s) having errors"
exit 1
else
echo "✅ All files validated successfully"
fi
- name: Post validation summary
if: always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const changedFiles = '${{ steps.changed-files.outputs.all_changed_files }}'.split(' ').filter(f => f);
let summary = '## Pattern Engine Validation Report\n\n';
summary += `**Files checked:** ${changedFiles.length}\n\n`;
if (changedFiles.length > 0) {
summary += '### Validated Files\n';
changedFiles.forEach(f => {
summary += `- \`${f}\`\n`;
});
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: summary
});