From c6459470dac4583ed32dc64586f071f5a2b7c653 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Mon, 19 Feb 2018 22:28:47 -0500 Subject: [PATCH 1/4] Remove an outdated TODO --- utils/issue-format-bot/lib/labeler.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/issue-format-bot/lib/labeler.js b/utils/issue-format-bot/lib/labeler.js index f82a8d64cd3f..df18ac47ab6b 100644 --- a/utils/issue-format-bot/lib/labeler.js +++ b/utils/issue-format-bot/lib/labeler.js @@ -8,8 +8,6 @@ module.exports = function label(context, data, alexa) { const alexaPosition = alexa.data.indexOf(data.domain); const labels = []; - // TODO remove existing labels in case of edits - if (alexaPosition === -1) { return; } else if (alexaPosition < 100) { From d50437c6815592d4e6de496a8984ea915cf50f6c Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Mon, 19 Feb 2018 23:29:36 -0500 Subject: [PATCH 2/4] Have the bot label issues by type Ref #14616 --- .github/ISSUE_TEMPLATE.md | 1 + utils/issue-format-bot/.eslintrc.json | 1 - utils/issue-format-bot/lib/labeler.js | 23 +++++++-- utils/issue-format-bot/lib/parse.js | 2 +- utils/issue-format-bot/test/labeler-test.js | 48 +++++++++++++++---- .../issue-format-bot/test/lib/handlerutil.js | 2 +- 6 files changed, 61 insertions(+), 16 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ba89d09a6c9e..da54bb3494ba 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -9,6 +9,7 @@ [//]: # (Leave in the line that best describes the issue you are reporting.) Type: ruleset issue +Type: ruleset enhancement Type: new ruleset Type: code issue Type: feature request diff --git a/utils/issue-format-bot/.eslintrc.json b/utils/issue-format-bot/.eslintrc.json index da3ef079033a..7e41908676ac 100644 --- a/utils/issue-format-bot/.eslintrc.json +++ b/utils/issue-format-bot/.eslintrc.json @@ -120,7 +120,6 @@ "error", "never" ], - "object-property-newline": "error", "one-var": "off", "one-var-declaration-per-line": "error", "prefer-arrow-callback": "error", diff --git a/utils/issue-format-bot/lib/labeler.js b/utils/issue-format-bot/lib/labeler.js index df18ac47ab6b..cefb17a29c44 100644 --- a/utils/issue-format-bot/lib/labeler.js +++ b/utils/issue-format-bot/lib/labeler.js @@ -1,15 +1,23 @@ -// Copyright 2017 AJ Jordan, AGPLv3+ +// Copyright 2017-2018 AJ Jordan, AGPLv3+ 'use strict'; const alexaLabels = ['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m']; +const typeLabels = ['bug', 'enhancement', 'ruleset-bug', 'ruleset-enhancement', 'new-ruleset']; +const typeToLabel = { + 'code issue': 'bug', + 'feature request': 'enhancement', + 'ruleset issue': 'ruleset-bug', + 'ruleset enhancement': 'ruleset-enhancement', + 'new ruleset': 'new-ruleset' +}; module.exports = function label(context, data, alexa) { const alexaPosition = alexa.data.indexOf(data.domain); const labels = []; if (alexaPosition === -1) { - return; + // Do nothing, we still need to label the type } else if (alexaPosition < 100) { labels.push('top-100'); } else if (alexaPosition < 1000) { @@ -22,8 +30,15 @@ module.exports = function label(context, data, alexa) { labels.push('top-1m'); } - // Every Alexa label *except* our new one - const toRemove = alexaLabels.filter(label => label !== labels[0]); + const typeLabel = typeToLabel[data.type] || null; + if (typeLabel) { + labels.push(typeLabel); + } + + // Every Alexa label *except* our new one, and the same for type labels + const toRemove = alexaLabels.filter(label => label !== labels[0] || '') + .concat(typeLabels.filter(label => label !== typeLabel)); // eslint-disable-line indent + toRemove.forEach(label => { const removalParams = context.issue({name: label}); // This is racy with addLabels() but honestly who cares diff --git a/utils/issue-format-bot/lib/parse.js b/utils/issue-format-bot/lib/parse.js index b4b52b157960..0dfea902a738 100644 --- a/utils/issue-format-bot/lib/parse.js +++ b/utils/issue-format-bot/lib/parse.js @@ -13,7 +13,7 @@ const strip = require('strip-markdown'), decode = (new Entities()).decode; // XXX should type validation be moved to the validator module? -const validTypes = ['ruleset issue', 'new ruleset', 'code issue', 'feature request', 'other']; +const validTypes = ['ruleset issue', 'ruleset enhancement', 'new ruleset', 'code issue', 'feature request', 'other']; // XXX the Error API in this module is pretty funky and could use a better design diff --git a/utils/issue-format-bot/test/labeler-test.js b/utils/issue-format-bot/test/labeler-test.js index 5f494f517d14..235be85b20dd 100644 --- a/utils/issue-format-bot/test/labeler-test.js +++ b/utils/issue-format-bot/test/labeler-test.js @@ -1,4 +1,4 @@ -// Copyright 2017 AJ Jordan, AGPLv3+ +// Copyright 2017-2018 AJ Jordan, AGPLv3+ 'use strict'; @@ -40,13 +40,13 @@ function addLabelsCalledOnce(err, context) { assert.isTrue(context.github.issues.addLabels.calledOnce); } -function assertWhichLabel(label) { +function assertWhichLabels(labels) { return function(err, context) { const args = context.github.issues.addLabels.args[0]; assert.isObject(args[0]); assert.isArray(args[0].labels); - assert.deepEqual(args[0].labels, [label]); + assert.deepEqual(args[0].labels.sort(), labels.sort()); }; } @@ -62,7 +62,7 @@ vows.describe('issue labeler module').addBatch(setup( topic: function(labeler) { const context = makeContext.issue(); // XXX should we test on the boundaries of different labels instead of in the middle? - labeler(context, {domain: 'domain10.com'}, alexa); + labeler(context, {type: 'new ruleset', domain: 'domain10.com'}, alexa); return context; }, teardown: resetSpies, @@ -70,15 +70,15 @@ vows.describe('issue labeler module').addBatch(setup( assert.ifError(err); }, 'it adds labels to the issue only once': addLabelsCalledOnce, - 'the label was the top-100 label': assertWhichLabel('top-100'), - 'all other labels were removed': assertOtherLabelsRemoved(['top-1k', 'top-10k', 'top-100k', 'top-1m']) + 'the labels were the top-100 and new-ruleset labels': assertWhichLabels(['top-100', 'new-ruleset']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-1k', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement', 'ruleset-bug', 'ruleset-enhancement']) } )).addBatch(setup( 'and we pass it an issue in the top 1,000 domains', { topic: function(labeler) { const context = makeContext.issue(); // XXX should we test on the boundaries of different labels instead of in the middle? - labeler(context, {domain: 'domain500.com'}, alexa); + labeler(context, {type: 'new ruleset', domain: 'domain500.com'}, alexa); return context; }, teardown: resetSpies, @@ -86,7 +86,37 @@ vows.describe('issue labeler module').addBatch(setup( assert.ifError(err); }, 'it adds labels to the issue only once': addLabelsCalledOnce, - 'the label was the top-1k label': assertWhichLabel('top-1k'), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-10k', 'top-100k', 'top-1m']) + 'the labels were the top-1k and new-ruleset labels': assertWhichLabels(['top-1k', 'new-ruleset']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement', 'ruleset-bug', 'ruleset-enhancement']) + } +)).addBatch(setup( + 'and we pass it a codebase issue', { + topic: function(labeler) { + const context = makeContext.issue(); + labeler(context, {type: 'code issue'}, alexa); + return context; + }, + teardown: resetSpies, + 'it works': function(err) { + assert.ifError(err); + }, + 'it adds labels to the issue only once': addLabelsCalledOnce, + 'the label was the bug label': assertWhichLabels(['bug']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset-bug', 'ruleset-enhancement', 'new-ruleset']) + } +)).addBatch(setup( + 'and we pass it a codebase issue with a domain', { + topic: function(labeler) { + const context = makeContext.issue(); + labeler(context, {type: 'code issue'}, alexa); + return context; + }, + teardown: resetSpies, + 'it works': function(err) { + assert.ifError(err); + }, + 'it adds labels to the issue only once': addLabelsCalledOnce, + 'the label was the bug label': assertWhichLabels(['bug']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset-bug', 'ruleset-enhancement', 'new-ruleset']) } )).export(module); diff --git a/utils/issue-format-bot/test/lib/handlerutil.js b/utils/issue-format-bot/test/lib/handlerutil.js index 3cee354bc473..c12ae1dbb913 100644 --- a/utils/issue-format-bot/test/lib/handlerutil.js +++ b/utils/issue-format-bot/test/lib/handlerutil.js @@ -143,7 +143,7 @@ function correctNewRuleset(issueText, text) { assert.isObject(args[0]); assert.isArray(args[0].labels); - assert.deepEqual(args[0].labels, ['top-100']); + assert.deepEqual(args[0].labels.sort(), ['top-100', 'new-ruleset'].sort()); } }; From 916b53dee9d2c0a3f0d9e245aafb716e00b4ba23 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Tue, 20 Mar 2018 23:15:27 -0400 Subject: [PATCH 3/4] Lump all ruleset issues into one label --- .github/ISSUE_TEMPLATE.md | 1 - utils/issue-format-bot/lib/labeler.js | 7 +++---- utils/issue-format-bot/lib/parse.js | 2 +- utils/issue-format-bot/test/labeler-test.js | 12 ++++++------ utils/issue-format-bot/test/lib/handlerutil.js | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index da54bb3494ba..ba89d09a6c9e 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -9,7 +9,6 @@ [//]: # (Leave in the line that best describes the issue you are reporting.) Type: ruleset issue -Type: ruleset enhancement Type: new ruleset Type: code issue Type: feature request diff --git a/utils/issue-format-bot/lib/labeler.js b/utils/issue-format-bot/lib/labeler.js index cefb17a29c44..38c36264c1e0 100644 --- a/utils/issue-format-bot/lib/labeler.js +++ b/utils/issue-format-bot/lib/labeler.js @@ -3,13 +3,12 @@ 'use strict'; const alexaLabels = ['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m']; -const typeLabels = ['bug', 'enhancement', 'ruleset-bug', 'ruleset-enhancement', 'new-ruleset']; +const typeLabels = ['bug', 'enhancement', 'ruleset']; const typeToLabel = { 'code issue': 'bug', 'feature request': 'enhancement', - 'ruleset issue': 'ruleset-bug', - 'ruleset enhancement': 'ruleset-enhancement', - 'new ruleset': 'new-ruleset' + 'ruleset issue': 'ruleset', + 'new ruleset': 'ruleset' }; module.exports = function label(context, data, alexa) { diff --git a/utils/issue-format-bot/lib/parse.js b/utils/issue-format-bot/lib/parse.js index 0dfea902a738..b4b52b157960 100644 --- a/utils/issue-format-bot/lib/parse.js +++ b/utils/issue-format-bot/lib/parse.js @@ -13,7 +13,7 @@ const strip = require('strip-markdown'), decode = (new Entities()).decode; // XXX should type validation be moved to the validator module? -const validTypes = ['ruleset issue', 'ruleset enhancement', 'new ruleset', 'code issue', 'feature request', 'other']; +const validTypes = ['ruleset issue', 'new ruleset', 'code issue', 'feature request', 'other']; // XXX the Error API in this module is pretty funky and could use a better design diff --git a/utils/issue-format-bot/test/labeler-test.js b/utils/issue-format-bot/test/labeler-test.js index 235be85b20dd..2f83dfaa08f2 100644 --- a/utils/issue-format-bot/test/labeler-test.js +++ b/utils/issue-format-bot/test/labeler-test.js @@ -70,8 +70,8 @@ vows.describe('issue labeler module').addBatch(setup( assert.ifError(err); }, 'it adds labels to the issue only once': addLabelsCalledOnce, - 'the labels were the top-100 and new-ruleset labels': assertWhichLabels(['top-100', 'new-ruleset']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-1k', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement', 'ruleset-bug', 'ruleset-enhancement']) + 'the labels were the top-100 and ruleset labels': assertWhichLabels(['top-100', 'ruleset']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-1k', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement']) } )).addBatch(setup( 'and we pass it an issue in the top 1,000 domains', { @@ -86,8 +86,8 @@ vows.describe('issue labeler module').addBatch(setup( assert.ifError(err); }, 'it adds labels to the issue only once': addLabelsCalledOnce, - 'the labels were the top-1k and new-ruleset labels': assertWhichLabels(['top-1k', 'new-ruleset']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement', 'ruleset-bug', 'ruleset-enhancement']) + 'the labels were the top-1k and ruleset labels': assertWhichLabels(['top-1k', 'ruleset']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement']) } )).addBatch(setup( 'and we pass it a codebase issue', { @@ -102,7 +102,7 @@ vows.describe('issue labeler module').addBatch(setup( }, 'it adds labels to the issue only once': addLabelsCalledOnce, 'the label was the bug label': assertWhichLabels(['bug']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset-bug', 'ruleset-enhancement', 'new-ruleset']) + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset']) } )).addBatch(setup( 'and we pass it a codebase issue with a domain', { @@ -117,6 +117,6 @@ vows.describe('issue labeler module').addBatch(setup( }, 'it adds labels to the issue only once': addLabelsCalledOnce, 'the label was the bug label': assertWhichLabels(['bug']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset-bug', 'ruleset-enhancement', 'new-ruleset']) + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset']) } )).export(module); diff --git a/utils/issue-format-bot/test/lib/handlerutil.js b/utils/issue-format-bot/test/lib/handlerutil.js index c12ae1dbb913..45a583c5f933 100644 --- a/utils/issue-format-bot/test/lib/handlerutil.js +++ b/utils/issue-format-bot/test/lib/handlerutil.js @@ -143,7 +143,7 @@ function correctNewRuleset(issueText, text) { assert.isObject(args[0]); assert.isArray(args[0].labels); - assert.deepEqual(args[0].labels.sort(), ['top-100', 'new-ruleset'].sort()); + assert.deepEqual(args[0].labels.sort(), ['top-100', 'ruleset'].sort()); } }; From 9e232b957c405ca569bb9ba4f34d9a68ce37eafb Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Wed, 16 May 2018 01:09:56 -0700 Subject: [PATCH 4/4] Adjust bot labelling to match production As noted in https://github.com/EFForg/https-everywhere/pull/14698#issuecomment-374874270, the omnibus `ruleset` label has been removed. Therefore undo some of the earlier changes and instead use `ruleset-bug` and `new-ruleset` again. `ruleset-enhancement` is not used since as noted in https://github.com/EFForg/https-everywhere/pull/14698#discussion_r172719280, this can be too much overhead for contributors. --- utils/issue-format-bot/lib/labeler.js | 6 +++--- utils/issue-format-bot/test/labeler-test.js | 12 ++++++------ utils/issue-format-bot/test/lib/handlerutil.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/utils/issue-format-bot/lib/labeler.js b/utils/issue-format-bot/lib/labeler.js index 38c36264c1e0..f0159016b2c9 100644 --- a/utils/issue-format-bot/lib/labeler.js +++ b/utils/issue-format-bot/lib/labeler.js @@ -3,12 +3,12 @@ 'use strict'; const alexaLabels = ['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m']; -const typeLabels = ['bug', 'enhancement', 'ruleset']; +const typeLabels = ['bug', 'enhancement', 'ruleset-bug', 'new-ruleset']; const typeToLabel = { 'code issue': 'bug', 'feature request': 'enhancement', - 'ruleset issue': 'ruleset', - 'new ruleset': 'ruleset' + 'ruleset issue': 'ruleset-bug', + 'new ruleset': 'new-ruleset' }; module.exports = function label(context, data, alexa) { diff --git a/utils/issue-format-bot/test/labeler-test.js b/utils/issue-format-bot/test/labeler-test.js index 2f83dfaa08f2..b4ca10a57572 100644 --- a/utils/issue-format-bot/test/labeler-test.js +++ b/utils/issue-format-bot/test/labeler-test.js @@ -70,8 +70,8 @@ vows.describe('issue labeler module').addBatch(setup( assert.ifError(err); }, 'it adds labels to the issue only once': addLabelsCalledOnce, - 'the labels were the top-100 and ruleset labels': assertWhichLabels(['top-100', 'ruleset']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-1k', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement']) + 'the labels were the top-100 and ruleset labels': assertWhichLabels(['top-100', 'new-ruleset']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-1k', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement', 'ruleset-bug']) } )).addBatch(setup( 'and we pass it an issue in the top 1,000 domains', { @@ -86,8 +86,8 @@ vows.describe('issue labeler module').addBatch(setup( assert.ifError(err); }, 'it adds labels to the issue only once': addLabelsCalledOnce, - 'the labels were the top-1k and ruleset labels': assertWhichLabels(['top-1k', 'ruleset']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement']) + 'the labels were the top-1k and ruleset labels': assertWhichLabels(['top-1k', 'new-ruleset']), + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-10k', 'top-100k', 'top-1m', 'bug', 'enhancement', 'ruleset-bug']) } )).addBatch(setup( 'and we pass it a codebase issue', { @@ -102,7 +102,7 @@ vows.describe('issue labeler module').addBatch(setup( }, 'it adds labels to the issue only once': addLabelsCalledOnce, 'the label was the bug label': assertWhichLabels(['bug']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset']) + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset-bug', 'new-ruleset']) } )).addBatch(setup( 'and we pass it a codebase issue with a domain', { @@ -117,6 +117,6 @@ vows.describe('issue labeler module').addBatch(setup( }, 'it adds labels to the issue only once': addLabelsCalledOnce, 'the label was the bug label': assertWhichLabels(['bug']), - 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset']) + 'all other labels were removed': assertOtherLabelsRemoved(['top-100', 'top-1k', 'top-10k', 'top-100k', 'top-1m', 'enhancement', 'ruleset-bug', 'new-ruleset']) } )).export(module); diff --git a/utils/issue-format-bot/test/lib/handlerutil.js b/utils/issue-format-bot/test/lib/handlerutil.js index 45a583c5f933..c12ae1dbb913 100644 --- a/utils/issue-format-bot/test/lib/handlerutil.js +++ b/utils/issue-format-bot/test/lib/handlerutil.js @@ -143,7 +143,7 @@ function correctNewRuleset(issueText, text) { assert.isObject(args[0]); assert.isArray(args[0].labels); - assert.deepEqual(args[0].labels.sort(), ['top-100', 'ruleset'].sort()); + assert.deepEqual(args[0].labels.sort(), ['top-100', 'new-ruleset'].sort()); } };