Visual Studio Code, rebuilt in Rust
Rust
docs(readme): count open milestone work in the coverage chart
rokartur18d910d63a1b
diff --git a/README.md b/README.mdindex b367f255e5a..861e2c465df 100644--- a/README.md+++ b/README.md@@ -44,13 +44,14 @@ Release builds of both with default settings and the same built-in extensions, A## Coverage<!-- coverage:start -->-**435 of the 435 parts of VS Code 1.148.0 the port covers match upstream 1:1 (100%).** 155 more are left out on purpose. A part is one upstream folder: a feature, a service or a built-in extension, counted from [port/ledger.md](port/ledger.md).+**465 of 550 items done (84%).** 435 of the 435 parts of VS Code 1.148.0 the port covers match upstream 1:1. 85 work items are still open: 7 for Linux, 35 for Windows, 43 for the VS Code 1.148.0 uplift. 155 more parts are left out on purpose. A part is one upstream folder: a feature, a service or a built-in extension; a work item is one row of a milestone's work (Linux, Windows, the uplift). Both are counted from [port/ledger.md](port/ledger.md).```mermaid-%%{init: {"theme": "base", "themeVariables": {"pie1": "#2da44e", "pie2": "#d4a72c", "pie3": "#8c959f", "pieStrokeColor": "#ffffff", "pieOuterStrokeColor": "#ffffff", "pieSectionTextColor": "#ffffff", "pieLegendTextColor": "#8c959f", "pieTitleTextColor": "#8c959f"}}}%%+%%{init: {"theme": "base", "themeVariables": {"pie1": "#2da44e", "pie2": "#d4a72c", "pie3": "#cf222e", "pie4": "#8c959f", "pieStrokeColor": "#ffffff", "pieOuterStrokeColor": "#ffffff", "pieSectionTextColor": "#ffffff", "pieLegendTextColor": "#8c959f", "pieTitleTextColor": "#8c959f"}}}%%pie showData"Matches VS Code 1:1" : 435"Works, with open gaps" : 0+ "Work items still open" : 85"Left out on purpose" : 155```@@ -74,6 +75,12 @@ pie showData"Matches 1:1" means upstream's tests or a named check against VS Code pass. No part works with open gaps.+| Milestone work | Done | Open | Progress |+|---|---:|---:|---|+| M21 uplift | 11 | 43 | `████░░░░░░░░░░░░░░░░` 20% |+| M24 Windows | 1 | 35 | `░░░░░░░░░░░░░░░░░░░░` 2% |+| M23 Linux | 18 | 7 | `██████████████░░░░░░` 72% |+</details><!-- coverage:end -->diff --git a/port/tools/readme-coverage.test.ts b/port/tools/readme-coverage.test.tsindex c901981ae87..410e777bb5f 100644--- a/port/tools/readme-coverage.test.ts+++ b/port/tools/readme-coverage.test.ts@@ -3,7 +3,7 @@ import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } fimport { tmpdir } from 'node:os';import { join } from 'node:path';-function coverageBlock(units: string[]) {+function coverageBlock(units: string[], work: string[] = []) {const root = mkdtempSync(join(tmpdir(), 'readme-coverage-test-'));mkdirSync(join(root, 'port/tools'), { recursive: true });mkdirSync(join(root, 'upstream'));@@ -12,7 +12,7 @@ function coverageBlock(units: string[]) {}writeFileSync(join(root, 'upstream/package.json'), '{"version": "1.148.0"}');writeFileSync(join(root, 'README.md'), '<!-- coverage:start -->\n<!-- coverage:end -->\n');- writeFileSync(join(root, 'port/ledger.md'), ['# Port ledger', '', '## Units', '', '| unit | area | milestone | status | gaps | check |', '|---|---|---|---|---|---|', ...units].join('\n'));+ writeFileSync(join(root, 'port/ledger.md'), ['# Port ledger', '', '## Work', '', ...work, '', '## Units', '', '| unit | area | milestone | status | gaps | check |', '|---|---|---|---|---|---|', ...units].join('\n'));const run = Bun.spawnSync(['bun', join(root, 'port/tools/readme-coverage.ts')], { env: { ...process.env, VSCODE_SRC: 'upstream' } });expect(run.exitCode).toBe(0);const readme = readFileSync(join(root, 'README.md'), 'utf8');@@ -22,7 +22,7 @@ function coverageBlock(units: string[]) {test('with every covered part verified, the block names no open parts', () => {const readme = coverageBlock(['| a | port feature | M1 | verified | | check |', '| b | port feature | | removed | | why |']);- expect(readme).toContain('**1 of the 1 parts of VS Code 1.148.0 the port covers match upstream 1:1 (100%).** 1 more are left out on purpose.');+ expect(readme).toContain('**1 of 1 items done (100%).** 1 of the 1 parts of VS Code 1.148.0 the port covers match upstream 1:1. 1 more parts are left out on purpose.');expect(readme).toContain('No part works with open gaps.');expect(readme).not.toContain('The other 0');expect(readme).not.toMatch(/\n\.\n/);@@ -33,3 +33,11 @@ test('an open part is listed with its gap count', () => {expect(readme).toContain('The other one works, with open gaps listed below.');expect(readme).toContain('`b` 1.');});++test('open milestone work rows keep the total below 100%', () => {+ const readme = coverageBlock(['| a | port feature | M1 | verified | | check |'], ['| M23 Linux | a.rs:1 | done | [linux S] x | |', '| M23 Linux | b.rs:1 | open | [linux S] y | |', '| M24 Windows | c.rs:1 | in progress | [windows M] z | |']);+ expect(readme).toContain('**2 of 4 items done (50%).**');+ expect(readme).toContain('2 work items are still open: 1 for Linux, 1 for Windows.');+ expect(readme).toContain('"Work items still open" : 2');+ expect(readme).toContain('| M23 Linux | 1 | 1 |');+});diff --git a/port/tools/readme-coverage.ts b/port/tools/readme-coverage.tsindex 95df5f5da75..ca84b7f3246 100755--- a/port/tools/readme-coverage.ts+++ b/port/tools/readme-coverage.ts@@ -1,5 +1,6 @@#!/usr/bin/env bun-// Writes the coverage block of README.md (between the `coverage` markers) from port/ledger.md's Units table.+// Writes the coverage block of README.md (between the `coverage` markers) from port/ledger.md's Units table+// and the milestone work rows of its Work table (`| M23 Linux | ...`), so open platform and uplift work counts too.// Run after a ledger recount: bun port/tools/readme-coverage.tsimport { readFileSync, writeFileSync } from 'node:fs';import { join } from 'node:path';@@ -24,7 +25,33 @@ const areaNames: Record<string, string> = {const empty = () => ({ verified: 0, ported: 0, stub: 0, todo: 0, removed: 0, 'n/a': 0 });const areas = new Map<string, ReturnType<typeof empty>>();const openRows: { id: string; gaps: number }[] = [];-const units = readFileSync(join(root, 'port/ledger.md'), 'utf8').split('\n## Units')[1];+const workNames: Record<string, string> = {+ 'M21 uplift': 'the VS Code 1.148.0 uplift',+ 'M23 Linux': 'Linux',+ 'M24 Windows': 'Windows',+};+const ledger = readFileSync(join(root, 'port/ledger.md'), 'utf8');+const [work, units] = ledger.split('\n## Units');+const workItems = new Map<string, { done: number; open: number }>();+for (const line of work.split('\n')) {+ const cells = line.split(' | ');+ if (!/^\| M\d+ /.test(line) || cells.length < 5) {+ continue;+ }+ const milestone = cells[0].slice(2);+ if (!(milestone in workNames)) {+ throw new Error(`readme-coverage.ts has no plain name for the ledger work rows "${milestone}"`);+ }+ const counts = workItems.get(milestone) ?? { done: 0, open: 0 };+ counts[cells[2] === 'done' ? 'done' : 'open']++;+ workItems.set(milestone, counts);+}+let workDone = 0;+let workOpen = 0;+for (const counts of workItems.values()) {+ workDone += counts.done;+ workOpen += counts.open;+}for (const line of units.split('\n')) {const cells = line.split(' | ');if (!line.startsWith('| ') || cells.length < 6 || cells[3] === 'status' || cells[3].startsWith('-')) {@@ -60,14 +87,17 @@ const bar = (c: typeof total) => {return `\`${'█'.repeat(filled)}${'░'.repeat(20 - filled)}\` ${percent(c)}%`;};+const itemsDone = total.verified + workDone;+const items = inScope(total) + workDone + workOpen;const lines = [- `**${total.verified} of the ${inScope(total)} parts of VS Code ${version} the port covers match upstream 1:1 (${percent(total)}%).** ${otherParts(inScope(total) - total.verified)}${leftOut(total)} more are left out on purpose. A part is one upstream folder: a feature, a service or a built-in extension, counted from [port/ledger.md](port/ledger.md).`,+ `**${itemsDone} of ${items} items done (${Math.floor((itemsDone / items) * 100)}%).** ${total.verified} of the ${inScope(total)} parts of VS Code ${version} the port covers match upstream 1:1. ${otherParts(inScope(total) - total.verified)}${openWork()}${leftOut(total)} more parts are left out on purpose. A part is one upstream folder: a feature, a service or a built-in extension; a work item is one row of a milestone's work (Linux, Windows, the uplift). Both are counted from [port/ledger.md](port/ledger.md).`,'','```mermaid',- `%%{init: {"theme": "base", "themeVariables": {"pie1": "#2da44e", "pie2": "#d4a72c", "pie3": "#8c959f", "pieStrokeColor": "#ffffff", "pieOuterStrokeColor": "#ffffff", "pieSectionTextColor": "#ffffff", "pieLegendTextColor": "#8c959f", "pieTitleTextColor": "#8c959f"}}}%%`,+ `%%{init: {"theme": "base", "themeVariables": {"pie1": "#2da44e", "pie2": "#d4a72c", "pie3": "#cf222e", "pie4": "#8c959f", "pieStrokeColor": "#ffffff", "pieOuterStrokeColor": "#ffffff", "pieSectionTextColor": "#ffffff", "pieLegendTextColor": "#8c959f", "pieTitleTextColor": "#8c959f"}}}%%`,'pie showData',` "Matches VS Code 1:1" : ${total.verified}`,` "Works, with open gaps" : ${inScope(total) - total.verified}`,+ ` "Work items still open" : ${workOpen}`,` "Left out on purpose" : ${leftOut(total)}`,'```','',@@ -85,6 +115,10 @@ openRows.sort((a, b) => b.gaps - a.gaps || a.id.localeCompare(b.id));if (openRows.length > 0) {lines.push('', openRows.map(row => `\`${row.id}\` ${row.gaps}`).join(', ') + '.');}+lines.push('', '| Milestone work | Done | Open | Progress |', '|---|---:|---:|---|');+for (const [milestone, c] of [...workItems].sort((a, b) => b[1].open - a[1].open)) {+ lines.push(`| ${milestone} | ${c.done} | ${c.open} | ${workBar(c.done, c.done + c.open)} |`);+}lines.push('', '</details>');const readmePath = join(root, 'README.md');@@ -96,6 +130,20 @@ if (!readme.includes(start) || !readme.includes(end)) {}writeFileSync(readmePath, readme.slice(0, readme.indexOf(start) + start.length) + '\n' + lines.join('\n') + '\n' + readme.slice(readme.indexOf(end)));+function workBar(done: number, all: number) {+ const percent = Math.floor((done / all) * 100);+ const filled = Math.floor(percent / 5);+ return `\`${'█'.repeat(filled)}${'░'.repeat(20 - filled)}\` ${percent}%`;+}++function openWork() {+ if (workOpen === 0) {+ return '';+ }+ const parts = [...workItems].filter(([, c]) => c.open > 0).map(([milestone, c]) => `${c.open} for ${workNames[milestone]}`);+ return `${workOpen} work items are still open: ${parts.join(', ')}. `;+}+function otherParts(count: number) {if (count === 0) {return '';