Fix flat YAML highlighter depth/position bugs (#23, #24) + a depth-wi… #61
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: README auto-regen | |
| # Auto-refreshes the two generated regions of README.md and commits them back to master in a | |
| # SINGLE commit: | |
| # - the cross-language bug ledger (<!-- issues:start/end -->), via `npm run bench:issues` | |
| # (test/issue-table.ts) — Monogram's DERIVED grammars vs each hand-written OFFICIAL one on | |
| # real reported bugs across TS / TSX / HTML / CSS / JS + Vue. Corpus-free: in-repo issue | |
| # cases + the official grammars only. | |
| # - the per-language alignment table (<!-- coverage:start/end -->), via | |
| # `node test/coverage-table.ts --write` — Monogram's parser vs the OFFICIAL parser over a | |
| # real corpus (agree · covered) plus the derived-vs-official highlighter axis. Needs the four | |
| # pinned corpora below, cloned to the fixed /tmp paths the adapters hard-code. | |
| # | |
| # Both grade against the official grammars, so every one must be present or the run refuses to | |
| # write (issue-table.ts aborts on a partial table; coverage-table.ts exits non-zero rather than | |
| # clobber a cell with "—"). A failure in either regen aborts the job before the commit, so the | |
| # README is never left half-updated. Vue's official grammars are VENDORED at test/fixtures/vue-official/. | |
| # | |
| # Determinism: same inputs → same README. The official grammars are pinned at a VS Code tag; the | |
| # four corpora are pinned to commits (the TS tests/cases count alone swings the parser numbers). | |
| # Bump a pin deliberately to re-baseline. | |
| # | |
| # No infinite loop: the bot commit touches only README.md, which is NOT in the paths filter, so | |
| # it can't re-trigger ([skip ci] is a backstop). One workflow = one committer = no push race. | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| # Grammar models + every generator the parser/derived grammars are built from. | |
| - '*.ts' | |
| - 'src/**' | |
| # The derived grammars both axes grade. | |
| - '*.tmLanguage.json' | |
| # The ledger grader + per-language issue-case data + the Vue harness/fixtures. | |
| - 'test/issue-table.ts' | |
| - 'test/issue-cases.ts' | |
| - 'test/tsx-issue-cases.ts' | |
| - 'test/html-issue-cases.ts' | |
| - 'test/vue-issue-cases.ts' | |
| - 'test/vue-grammar-harness.ts' | |
| - 'test/fixtures/vue-official/**' | |
| # The coverage metric harness. | |
| - 'test/src-coverage*.ts' | |
| - 'test/scope-gap*.ts' | |
| - 'test/coverage-table.ts' | |
| - '.github/workflows/readme-bench.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: readme-auto-regen-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # Pinned VS Code tag whose bundled grammars are the "official" baseline (TS/TSX/HTML/CSS/JS/JSX). | |
| OFFICIAL_TM_TAG: '1.96.0' | |
| # Corpus pins (commits) for the coverage table's parser axis. Bump to re-baseline. | |
| TS_REPO_SHA: '6fbce89821d93a5b761581d9ac540455f38e9acb' | |
| TEST262_SHA: '05bb032907160d66c212589d345fa0e335e2738c' | |
| YAML_SUITE_SHA: 'da267a5c4782e7361e82889e76c0dc7df0e1e870' | |
| REDCMD_SHA: '1ae4e9d32f42878270b7c8593d18bee7d618e59f' | |
| jobs: | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Node 24+ runs the .ts sources directly (native type stripping) — no build, no tsx. | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| - run: npm ci | |
| - name: Fetch pinned official VS Code grammars (TS / TSX / HTML / CSS / JS / JSX) | |
| run: | | |
| set -euo pipefail | |
| base="https://raw.githubusercontent.com/microsoft/vscode/${OFFICIAL_TM_TAG}/extensions" | |
| curl -fsSL "$base/typescript-basics/syntaxes/TypeScript.tmLanguage.json" -o /tmp/official-ts.json | |
| curl -fsSL "$base/typescript-basics/syntaxes/TypeScriptReact.tmLanguage.json" -o /tmp/official-tsx.json | |
| curl -fsSL "$base/html/syntaxes/html.tmLanguage.json" -o /tmp/official-html.json | |
| curl -fsSL "$base/css/syntaxes/css.tmLanguage.json" -o /tmp/official-css.json | |
| curl -fsSL "$base/javascript/syntaxes/JavaScript.tmLanguage.json" -o /tmp/official-js.json | |
| curl -fsSL "$base/javascript/syntaxes/JavaScriptReact.tmLanguage.json" -o /tmp/official-jsx.json | |
| - name: Clone pinned corpora to the fixed /tmp paths the coverage adapters read | |
| run: | | |
| set -euo pipefail | |
| # Pinned-SHA, shallow, sparse: only the subtree each adapter walks. fetch-by-SHA works | |
| # because every pin is a commit reachable from the repo's default branch. | |
| pinclone() { # $1=dir $2=url $3=sha $4=sparse-subdir | |
| rm -rf "$1"; mkdir -p "$1" | |
| git -C "$1" init -q | |
| git -C "$1" remote add origin "$2" | |
| git -C "$1" config core.sparseCheckout true | |
| printf '%s/\n' "$4" > "$1/.git/info/sparse-checkout" | |
| git -C "$1" fetch -q --depth 1 --filter=blob:none origin "$3" | |
| git -C "$1" checkout -q FETCH_HEAD | |
| } | |
| pinclone /tmp/ts-repo https://github.com/microsoft/TypeScript "$TS_REPO_SHA" tests/cases | |
| pinclone /tmp/test262 https://github.com/tc39/test262 "$TEST262_SHA" test/language | |
| pinclone /tmp/yaml-test-suite https://github.com/yaml/yaml-test-suite "$YAML_SUITE_SHA" src | |
| pinclone /tmp/redcmd-yaml https://github.com/RedCMD/YAML-Syntax-Highlighter "$REDCMD_SHA" syntaxes | |
| - name: Regenerate the bug ledger (issues region) | |
| env: | |
| MONOGRAM_OFFICIAL_TM: /tmp/official-ts.json | |
| MONOGRAM_OFFICIAL_TSX: /tmp/official-tsx.json | |
| MONOGRAM_OFFICIAL_HTML: /tmp/official-html.json | |
| MONOGRAM_OFFICIAL_CSS: /tmp/official-css.json | |
| MONOGRAM_OFFICIAL_JS: /tmp/official-js.json | |
| run: npm run bench:issues | |
| - name: Regenerate the coverage table (coverage region) | |
| env: | |
| MONOGRAM_OFFICIAL_TS: /tmp/official-ts.json | |
| MONOGRAM_OFFICIAL_TSX: /tmp/official-tsx.json | |
| MONOGRAM_OFFICIAL_JS: /tmp/official-js.json | |
| MONOGRAM_OFFICIAL_JSX: /tmp/official-jsx.json | |
| MONOGRAM_OFFICIAL_HTML: /tmp/official-html.json | |
| MONOGRAM_OFFICIAL_YAML: /tmp/redcmd-yaml/syntaxes/yaml.tmLanguage.json | |
| run: node test/coverage-table.ts --write | |
| - name: Commit the refreshed README (if it changed) | |
| run: | | |
| set -euo pipefail | |
| if git diff --quiet -- README.md; then | |
| echo "README already current — nothing to commit." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git commit -m "chore: refresh README ledger + coverage table [skip ci]" | |
| git push |