Update workflow #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |