Skip to content

Commit a0816ad

Browse files
committed
Route WEB_FEATURES.yml changes to web-features contributors
Fixes #253.
1 parent fe27bce commit a0816ad

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

lib/metadata/find-owners.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
"use strict";
22
var github = require('../github'),
3+
paths = require('./paths'),
34
uniq = require('../uniq'),
45
yaml = require('js-yaml');
56

7+
// https://github.com/web-platform-tests/rfcs/blob/master/rfcs/web_features.md#step-4-adjust-the-wpt-pr-bot-to-handle-reviews-of-the-changes
8+
var webFeaturesReviewers = ['foolip', 'jcscottiii'];
9+
610
function getReviewersFile(path, reviewers) {
711
return github.get("/repos/:owner/:repo/contents/:path", { path: path + "/META.yml" })
812
.then(function(file) {
@@ -36,9 +40,15 @@ function parentDir(path) {
3640
return path.join("/");
3741
}
3842

39-
module.exports = async function(_directories) {
43+
module.exports = async function(filenames) {
44+
// If only WEB_FEATURES.yml files are touched, route the review to
45+
// web-features contributors.
46+
if (filenames.every((filename) => filename.endsWith('/WEB_FEATURES.yml'))) {
47+
return webFeaturesReviewers;
48+
}
49+
4050
var reviewers = [];
41-
var directories = _directories.slice(0);
51+
var directories = paths(filenames).slice(0);
4252
// Reversing the array here keeps compatibility with a previous version of
4353
// this code, which used a recursive structure and called pop() on the
4454
// array each time. This could likely be removed with some investigation.

lib/metadata/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22

33
const getFilenames = require('./filenames'),
4-
paths = require('./paths'),
54
findSpecs = require('./find-specs'),
65
findOwners = require('./find-owners'),
76
findRemovedReviewers = require('./find-removed-reviewers'),
@@ -50,7 +49,6 @@ module.exports = async function getMetadata(number, author, title, content) {
5049
author = author.toLowerCase();
5150

5251
metadata.filenames = await getFilenames(number);
53-
metadata.paths = paths(metadata.filenames);
5452
const fileLabels = labels.fromFiles(metadata.filenames);
5553
metadata.isRoot = metadata.filenames.some(function(path) {
5654
return path.split('/').length == 1;
@@ -63,7 +61,7 @@ module.exports = async function getMetadata(number, author, title, content) {
6361
fileLabels, labels.fromWorkingGroups(metadata.workingGroups)
6462
);
6563

66-
let reviewers = await findOwners(metadata.paths);
64+
let reviewers = await findOwners(metadata.filenames);
6765

6866
const removedReviewers = await findRemovedReviewers(number);
6967
reviewers = reviewers.filter(function(reviewer) {

test/find-owners.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ suite('parse META', function() {
3131

3232
suite('integration', function() {
3333
test('directory contains file', function() {
34-
return findOwners(['resources'])
34+
return findOwners(['resources/testharness.js'])
3535
.then(function(reviewers) {
3636
reviewers.sort();
3737

@@ -40,24 +40,46 @@ suite('integration', function() {
4040
});
4141

4242
test('parent directory contains file', function() {
43-
return findOwners(['2dcontext/scroll'])
43+
return findOwners(['dom/nodes/attributes.html'])
4444
.then(function(reviewers) {
4545
reviewers.sort();
4646

4747
assert.deepEqual(reviewers, [
48-
'AmeliaBR', 'annevk', 'fserb', 'jdashg', 'kenrussell'
48+
'annevk', 'jdm', 'zqzhang'
4949
]);
5050
});
5151
});
5252

5353
test('consolidation of multiple directories', function() {
54-
return findOwners(['resources', '2dcontext'])
54+
return findOwners(['resources/testharness.js', 'dom/nodes/attributes.html'])
5555
.then(function(reviewers) {
5656
reviewers.sort();
5757

5858
assert.deepEqual(reviewers, [
59-
'AmeliaBR', 'annevk', 'ayg', 'fserb', 'gsnedders',
60-
'jdashg', 'jgraham', 'kenrussell'
59+
'annevk', 'ayg', 'gsnedders',
60+
'jdm', 'jgraham', 'zqzhang'
61+
]);
62+
});
63+
});
64+
65+
test('only WEB_FEATURES.yml changes', function() {
66+
return findOwners(['dom/WEB_FEATURES.yml'])
67+
.then(function(reviewers) {
68+
reviewers.sort();
69+
70+
assert.deepEqual(reviewers, [
71+
'foolip', 'jcscottiii'
72+
]);
73+
});
74+
});
75+
76+
test('WEB_FEATURES.yml and test changes', function() {
77+
return findOwners(['dom/WEB_FEATURES.yml', 'dom/nodes/attributes.html'])
78+
.then(function(reviewers) {
79+
reviewers.sort();
80+
81+
assert.deepEqual(reviewers, [
82+
'annevk', 'jdm', 'zqzhang'
6183
]);
6284
});
6385
});

test/get-metadata.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ suite('getMetadata', function() {
5656
],
5757
rootReviewers: [ 'jgraham' ],
5858
filenames: [ 'WebIDL/interfaces.html', 'interfaces/WebIDL.idl' ],
59-
paths: [ 'WebIDL', 'interfaces' ],
6059
labels: [ 'WebIDL', 'interfaces', 'wg-webplatform' ],
6160
isRoot: false,
6261
isWebKitVerified: false,
@@ -167,10 +166,6 @@ suite('getMetadata', function() {
167166
permission: "write"
168167
}
169168
],
170-
paths: [
171-
"svg/coordinate-systems",
172-
"svg/coordinate-systems/parsing",
173-
],
174169
reviewedDownstream: null,
175170
reviewers: [
176171
"ameliabr",
@@ -380,7 +375,6 @@ suite('getMetadata', function() {
380375
'media-source/webm/test-a-1s.webm-manifest.json',
381376
'media-source/webm/test-v-1s-blue.webm',
382377
'media-source/webm/test-v-1s-blue.webm-manifest.json' ],
383-
paths: [ '', 'media-source', 'media-source/mp4', 'media-source/webm' ],
384378
isRoot: true,
385379
specs:
386380
{ 'media-source':

0 commit comments

Comments
 (0)