Skip to content

Commit 737094c

Browse files
aduh95phillipj
authored andcommitted
feat: add needs-ci label
1 parent 37a9a63 commit 737094c

File tree

4 files changed

+75
-62
lines changed

4 files changed

+75
-62
lines changed

lib/node-labels.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const ciNeededFolderRx = /^(deps|lib|src|test)\//
34
// order of entries in this map *does* matter for the resolved labels
45
// earlier entries override later entries
56
const subSystemLabelsMap = new Map([
@@ -37,10 +38,10 @@ const subSystemLabelsMap = new Map([
3738
[/^src\/node_bob*/, ['c++', 'quic', 'dont-land-on-v14.x', 'dont-land-on-v12.x']],
3839

3940
// don't label python files as c++
40-
[/^src\/.+\.py$/, 'lib / src'],
41+
[/^src\/.+\.py$/, ['lib / src', 'needs-ci']],
4142

4243
// properly label changes to v8 inspector integration-related files
43-
[/^src\/inspector_/, ['c++', 'inspector']],
44+
[/^src\/inspector_/, ['c++', 'inspector', 'needs-ci']],
4445

4546
// don't want to label it a c++ update when we're "only" bumping the Node.js version
4647
[/^src\/(?!node_version\.h)/, 'c++'],
@@ -51,22 +52,24 @@ const subSystemLabelsMap = new Map([
5152
// things that edit top-level .md files are always a doc change
5253
[/^\w+\.md$/, 'doc'],
5354
// different variants of *Makefile and build files
54-
[/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles|\.travis\.yml)$/, 'build'],
55-
[/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/, 'build'],
56-
[/^vcbuild\.bat$/, ['build', 'windows']],
57-
[/^(android-)?configure|node\.gyp|common\.gypi$/, 'build'],
55+
[/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles|\.travis\.yml)$/, ['build', 'needs-ci']],
56+
[/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/, ['build', 'needs-ci']],
57+
[/^vcbuild\.bat$/, ['build', 'windows', 'needs-ci']],
58+
[/^(android-)?configure|node\.gyp|common\.gypi$/, ['build', 'needs-ci']],
5859
// more specific tools
59-
[/^tools\/gyp/, ['tools', 'build']],
60+
[/^tools\/gyp/, ['tools', 'build', 'needs-ci']],
6061
[/^tools\/doc\//, ['tools', 'doc']],
61-
[/^tools\/icu\//, ['tools', 'intl']],
62+
[/^tools\/icu\//, ['tools', 'intl', 'needs-ci']],
6263
[/^tools\/(?:osx-pkg\.pmdoc|pkgsrc)\//, ['tools', 'macos', 'install']],
6364
[/^tools\/(?:(?:mac)?osx-)/, ['tools', 'macos']],
6465
[/^tools\/test-npm/, ['tools', 'test', 'npm']],
6566
[/^tools\/test/, ['tools', 'test']],
6667
[/^tools\/(?:certdata|mkssldef|mk-ca-bundle)/, ['tools', 'openssl', 'tls']],
67-
[/^tools\/msvs\//, ['tools', 'windows', 'install']],
68-
[/^tools\/[^/]+\.bat$/, ['tools', 'windows']],
69-
[/^tools\/make-v8/, ['tools', 'V8 Engine']],
68+
[/^tools\/msvs\//, ['tools', 'windows', 'install', 'needs-ci']],
69+
[/^tools\/[^/]+\.bat$/, ['tools', 'windows', 'needs-ci']],
70+
[/^tools\/make-v8/, ['tools', 'V8 Engine', 'needs-ci']],
71+
[/^tools\/(code_cache|snapshot|v8_gypfiles)/, 'needs-ci'],
72+
[/^tools\/build-addons.js/, 'needs-ci'],
7073
// all other tool changes should be marked as such
7174
[/^tools\//, 'tools'],
7275
[/^\.eslint|\.remark|\.editorconfig/, 'tools'],
@@ -239,6 +242,10 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLabels) {
239242
const labelCount = []
240243
// by putting matched labels into a map, we avoid duplicate labels
241244
const labelsMap = filepathsChanged.reduce((map, filepath) => {
245+
if (ciNeededFolderRx.test(filepath) && !map['needs-ci']) {
246+
map['needs-ci'] = true
247+
}
248+
242249
const mappedSubSystems = mappedSubSystemsForFile(rxLabelsMap, filepath)
243250

244251
if (!mappedSubSystems) {
@@ -251,8 +258,8 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLabels) {
251258
if (limitLabels && hasLibOrSrcChanges(filepathsChanged)) {
252259
if (labelCount.length >= 4) {
253260
for (const label of labelCount) {
254-
// don't delete the c++ label as we always want that if it has matched
255-
if (label !== 'c++') delete map[label]
261+
// don't delete the `c++` or `needs-ci` labels as we always want those if they have matched
262+
if (label !== 'c++' && label !== 'needs-ci') delete map[label]
256263
}
257264
map['lib / src'] = true
258265
// short-circuit

test/unit/node-build-label.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ tap.test('label: "build" when build related files has been changed', (t) => {
2424
buildRelatedFiles.forEach((filepath) => {
2525
const labels = nodeLabels.resolveLabels([ filepath ])
2626

27-
t.same(labels, ['build'], filepath + ' got "build" label')
27+
t.ok(labels.includes('build'), filepath + ' should have "build" label')
28+
t.ok(labels.includes('needs-ci'), filepath + ' should have "needs-ci" label')
2829
})
2930

3031
t.end()
@@ -36,6 +37,7 @@ tap.test('labels: not "build" when Makefile in ./deps has been changed', (t) =>
3637
])
3738

3839
t.notOk(labels.includes('build'))
40+
t.ok(labels.includes('needs-ci'))
3941

4042
t.end()
4143
})

test/unit/node-js-subsystem-labels.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tap.test('label: lib oddities', (t) => {
3838
const labels = nodeLabels.resolveLabels(libFiles, false)
3939

4040
t.same(labels, [
41+
'needs-ci', // lib/
4142
'debugger', // _debug_agent
4243
'http', // _http_*
4344
'timers', // linklist
@@ -62,6 +63,7 @@ tap.test('label: lib internals oddities duplicates', (t) => {
6263
const labels = nodeLabels.resolveLabels(libFiles)
6364

6465
t.same(labels, [
66+
'needs-ci', // lib/
6567
'lib / src', // bootstrap_node
6668
'timers', // linkedlist
6769
'stream' // internal/streams/
@@ -108,6 +110,7 @@ tap.test('label: lib normal without "lib / src" limiting', (t) => {
108110

109111
const labels = nodeLabels.resolveLabels(libFiles, false)
110112

113+
t.same(labels.shift(), 'needs-ci')
111114
t.same(labels, libFiles.map((path) => /lib\/(_)?(\w+)\.js/.exec(path)[2]))
112115

113116
t.end()
@@ -127,6 +130,7 @@ tap.test('label: lib internals without "lib / src" limiting', (t) => {
127130

128131
const labels = nodeLabels.resolveLabels(libFiles, false)
129132

133+
t.same(labels.shift(), 'needs-ci')
130134
t.same(labels, libFiles.map((path) => /lib\/internal\/(\w+)\.js/.exec(path)[1]))
131135

132136
t.end()
@@ -169,7 +173,7 @@ tap.test('label: appropriate labels for files in internal subdirectories', (t) =
169173
'lib/internal/process/next_tick.js'
170174
], false)
171175

172-
t.same(labels, ['cluster', 'process'])
176+
t.same(labels, ['needs-ci', 'cluster', 'process'])
173177

174178
t.end()
175179
})

0 commit comments

Comments
 (0)