Skip to content

Commit

Permalink
Compute multi-spec repositories automatically (#660)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tidoust authored Aug 2, 2024
1 parent 34184f5 commit ba21462
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
17 changes: 17 additions & 0 deletions src/lib/is-in-multi-spec-repo.js
Original file line number Diff line number Diff line change
@@ -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);
}
12 changes: 4 additions & 8 deletions src/reporting/file-issue-for-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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':
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit ba21462

Please # to comment.