From ba21462f6ca0d9bdecca4a1354a98f338870ef2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Daoust?= Date: Fri, 2 Aug 2024 15:04:24 +0200 Subject: [PATCH] Compute multi-spec repositories automatically (#660) The list of multi-spec repositories was hardcoded and slightly outdated. The update now computes that list automatically from the data present in the results of the crawl (which comes from browser-specs). Compared to the previous list, the new logic misses `w3c/woff` because it voluntarily skips repositories that contain multiple versions of the same spec to avoid false positives. It adds: https://github.com/httpwg/http-extensions https://github.com/immersive-web/real-world-geometry https://github.com/w3c/aria https://github.com/w3c/encrypted-media https://github.com/w3c/gamepad https://github.com/w3c/reporting https://github.com/w3c/webcodecs https://github.com/WebAssembly/threads https://github.com/WebBluetoothCG/web-bluetooth https://github.com/WICG/nav-speculation https://github.com/WICG/shape-detection-api https://github.com/WICG/WebApiDevice Some of them contain one "main" spec and side specs that we will probably ignore for some time, but then it does not hurt to prefix issues with the spec's shortname in such cases, even if the targeted spec is somewhat obvious. --- src/lib/is-in-multi-spec-repo.js | 17 +++++++++++++++++ src/reporting/file-issue-for-review.js | 12 ++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 src/lib/is-in-multi-spec-repo.js diff --git a/src/lib/is-in-multi-spec-repo.js b/src/lib/is-in-multi-spec-repo.js new file mode 100644 index 00000000..afc8af30 --- /dev/null +++ b/src/lib/is-in-multi-spec-repo.js @@ -0,0 +1,17 @@ +/** + * Return true if the given spec is maintained in a GitHub repository shared + * with other specs. + * + * The function takes as input a list of crawled specs, typically the list + * of specs in the `index.json` file of a crawled report. That list contains + * data from browser-specs about the specs, allowing the function to answer + * the request. + */ +export default function (spec, specs) { + if (!spec.nightly?.repository) { + return false; + } + return !!specs.find(s => + s.nightly?.repository === spec.nightly.repository && + s.series.shortname !== spec.series.shortname); +} \ No newline at end of file diff --git a/src/reporting/file-issue-for-review.js b/src/reporting/file-issue-for-review.js index d8b4515e..0d797fbe 100644 --- a/src/reporting/file-issue-for-review.js +++ b/src/reporting/file-issue-for-review.js @@ -5,6 +5,7 @@ import { loadCrawlResults } from '../lib/util.js'; import studyBackrefs from '../lib/study-backrefs.js'; import studyReferences from '../lib/study-refs.js'; +import isInMultiSpecRepository from '../lib/is-in-multi-spec-repo.js'; import loadJSON from '../lib/load-json.js'; import path from 'node:path'; import fs from 'node:fs/promises'; @@ -25,13 +26,8 @@ const octokit = new Octokit({ // log: console }); -// based on `jq .[].nightly.repository index.json |sort|uniq -c|sort -rn|less` -// in browser-specs -// TODO: automate it? -const multiSpecRepos = ['w3c/csswg-drafts', 'w3c/fxtf-drafts', 'w3c/svgwg', 'KhronosGroup/WebGL', 'httpwg/httpwg.github.io', 'w3c/css-houdini-drafts', 'WebAssembly/spec', 'w3c/woff', 'w3c/mediacapture-handle', 'w3c/epub-specs', 'gpuweb/gpuweb'].map(r => 'https://github.com/' + r); - -function issueWrapper (spec, anomalies, anomalyType) { - const titlePrefix = (multiSpecRepos.includes(spec.nightly.repository)) ? `[${spec.shortname}] ` : ''; +function issueWrapper (spec, anomalies, anomalyType, crawl) { + const titlePrefix = isInMultiSpecRepository(spec, crawl.ed) ? `[${spec.shortname}] ` : ''; let anomalyReport = ''; let title = ''; switch (anomalyType) { case 'brokenLinks': @@ -186,7 +182,7 @@ for (const anomalyType of anomalyTypes) { } // if not, we create the file, add it in a branch // and submit it as a pull request to the repo - const { title, content: issueReportContent } = issueWrapper(spec, specAnomalies, anomalyType); + const { title, content: issueReportContent } = issueWrapper(spec, specAnomalies, anomalyType, crawl); if (updateMode) { if (existingReportContent) { const existingAnomalies = existingReportContent.split('\n').filter(l => l.startsWith('* [ ] ')).map(l => l.slice(6));