Add automated grammar build pipeline and improve CI/CD #9
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: Validate Extensions | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Check upstream-pinned highlight queries | |
| run: bun run scripts/sync-upstream-queries.ts --check | |
| - name: Validate extension manifests | |
| run: bun run scripts/validate.ts | |
| - name: Check manifests.json is up to date | |
| run: | | |
| bun run scripts/generate-manifests.ts | |
| git diff --exit-code manifests.json || (echo "manifests.json is out of date. Run: bun run scripts/generate-manifests.ts" && exit 1) | |
| - name: Check registry.json and index.json are up to date | |
| run: bun run scripts/build-extensions-index.ts --check | |
| - name: Validate grammar-sources.json | |
| run: | | |
| node -e " | |
| const sources = require('./grammar-sources.json'); | |
| const fs = require('fs'); | |
| const dirs = fs.readdirSync('extensions', { withFileTypes: true }) | |
| .filter(d => d.isDirectory()).map(d => d.name); | |
| let errors = 0; | |
| for (const dir of dirs) { | |
| const hasHighlights = fs.existsSync('extensions/' + dir + '/highlights.scm'); | |
| const hasSource = !!sources[dir]; | |
| if (hasHighlights && !hasSource) { | |
| console.warn('Warning: ' + dir + ' has highlights.scm but no entry in grammar-sources.json'); | |
| } | |
| } | |
| for (const [lang, src] of Object.entries(sources)) { | |
| if (!fs.existsSync('extensions/' + lang)) { | |
| console.error('Error: grammar-sources.json references ' + lang + ' but extensions/' + lang + '/ does not exist'); | |
| errors++; | |
| } | |
| } | |
| if (errors > 0) process.exit(1); | |
| console.log('grammar-sources.json: OK (' + Object.keys(sources).length + ' grammars)'); | |
| " |