-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (106 loc) · 4.09 KB
/
sync-keywords.yml
File metadata and controls
124 lines (106 loc) · 4.09 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Sync Keyword Registry
on:
push:
branches: [main, dev]
paths:
- 'data/keywords.yaml'
- '.github/workflows/sync-keywords.yml'
- '.github/scripts/sync-keywords.py'
pull_request:
branches: [main]
paths:
- 'data/keywords.yaml'
jobs:
validate-keywords:
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
pull-requests: write
steps:
- name: Checkout tree-sitter-multilingual
uses: actions/checkout@v4
with:
path: tree-sitter-multilingual
- name: Checkout multilingual reference
uses: actions/checkout@v4
with:
repository: multilingualprogramming/multilingual
path: multilingual
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install pyyaml
- name: Validate keyword sync
id: sync
run: |
python tree-sitter-multilingual/.github/scripts/sync-keywords.py \
--reference multilingual/multilingualprogramming/resources/usm/keywords.json \
--target tree-sitter-multilingual/data/keywords.yaml \
--report sync-report.json
continue-on-error: true
- name: Check validation results
id: check
if: always() && hashFiles('sync-report.json') != ''
run: |
python tree-sitter-multilingual/.github/scripts/check-sync-results.py sync-report.json
- name: Upload sync report
if: always() && hashFiles('sync-report.json') != ''
uses: actions/upload-artifact@v4
with:
name: keyword-sync-report
path: sync-report.json
- name: Comment on PR with results
if: github.event_name == 'pull_request' && always() && hashFiles('sync-report.json') != ''
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = JSON.parse(fs.readFileSync('sync-report.json', 'utf8'));
let comment = '## Keyword Registry Sync Report\n\n';
if (report.status === 'success') {
comment += 'All keywords are in sync with the reference implementation.\n\n';
} else {
comment += 'Keyword registry sync issues detected.\n\n';
}
if (report.missing_constructs && report.missing_constructs.length > 0) {
comment += '### Missing Constructs\n';
comment += '```\n';
report.missing_constructs.forEach(c => {
comment += `${c}\n`;
});
comment += '```\n\n';
}
if (report.language_mismatches && report.language_mismatches.length > 0) {
comment += '### Language Mismatches\n';
comment += `Found ${report.language_mismatches.length} mismatches:\n`;
comment += '```\n';
report.language_mismatches.slice(0, 10).forEach(m => {
comment += `${m.construct} (${m.language}): expected '${m.expected}', got '${m.actual}'\n`;
});
if (report.language_mismatches.length > 10) {
comment += `... and ${report.language_mismatches.length - 10} more\n`;
}
comment += '```\n\n';
}
if (report.missing_languages && report.missing_languages.length > 0) {
comment += '### Missing Language Support\n';
comment += '```\n';
report.missing_languages.forEach(l => {
comment += `${l.construct}: missing ${l.languages.join(', ')}\n`;
});
comment += '```\n\n';
}
comment += `**Coverage**: ${report.coverage || 'N/A'}%\n`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Fail if validation failed
if: steps.sync.outcome == 'failure'
run: exit 1