Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions lib/node-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const subSystemLabelsMap = new Map([

// properly label changes to v8 inspector integration-related files
[/^src\/inspector_/, ['c++', 'v8_inspector', 'dont-land-on-v4.x']],
[/^test\/(?:cctest|inspector)\//, ['test', 'v8_inspector',
'dont-land-on-v4.x']],
// don't want to label it a c++ update when we're "only" bumping the Node.js version
[/^src\/(?!node_version\.h)/, 'c++'],
// meta is a very specific label for things that are policy and or meta-info related
Expand All @@ -44,9 +46,23 @@ const subSystemLabelsMap = new Map([
// different variants of *Makefile and build files
[/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles)$/, 'build'],
[/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/, 'build'],
[/^(configure|node\.gyp|common\.gypi|vcbuild\.bat)$/, 'build'],
// all other tools/ changes should be marked as such
[/^vcbuild\.bat$/, ['build', 'windows']],
[/^configure|node\.gyp|common\.gypi$/, 'build'],
// more specific tools
[/^tools\/gyp/, ['tools', 'build']],
[/^tools\/doc\//, ['tools', 'doc']],
[/^tools\/icu\//, ['tools', 'intl']],
[/^tools\/(?:osx-pkg\.pmdoc|pkgsrc)\//, ['tools', 'macos', 'install']],
[/^tools\/(?:(?:mac)?osx-)/, ['tools', 'macos']],
[/^tools\/test-npm/, ['tools', 'test', 'npm']],
[/^tools\/test/, ['tools', 'test']],
[/^tools\/(?:certdata|mkssldef|mk-ca-bundle)/, ['tools', 'openssl', 'tls']],
[/^tools\/msvs\//, ['tools', 'windows', 'install']],
[/^tools\/[^/]+\.bat$/, ['tools', 'windows']],
[/^tools\/make-v8/, ['tools', 'V8']],
// all other tool changes should be marked as such
[/^tools\//, 'tools'],
[/^\.eslint|\.remark|\.editorconfig/, 'tools'],

/* Dependencies */
// libuv needs an explicit mapping, as the ordinary /deps/ mapping below would
Expand Down Expand Up @@ -80,12 +96,30 @@ const jsSubsystemList = [
]

const exclusiveLabelsMap = new Map([
// more specific tests
[/^test\/addons\//, ['test', 'addons']],
[/^test\/debugger\//, ['test', 'debugger']],
[/^test\/doctool\//, ['test', 'doc', 'tools']],
[/^test\/timers\//, ['test', 'timers']],
[/^test\/pseudo-tty\//, ['test', 'tty']],

[/^test\//, 'test'],

// specific map for modules.md as it should be labeled 'module' not 'modules'
[/^doc\/api\/modules.md$/, ['doc', 'module']],
// automatically tag subsystem-specific API doc changes
[/^doc\/api\/(\w+)\.md$/, ['doc', '$1']],

[/^doc\//, 'doc'],

// more specific benchmarks
[/^benchmark\/buffers\//, ['benchmark', 'buffer']],
[/^benchmark\/(?:arrays|es)\//, ['benchmark', 'V8']],
[/^benchmark\/_http/, ['benchmark', 'http']],
[/^benchmark\/(?:misc|fixtures)\//, 'benchmark'],
[/^benchmark\/streams\//, ['benchmark', 'stream']],
[/^benchmark\/([^/]+)\//, ['benchmark', '$1']],

[/^benchmark\//, 'benchmark']
])

Expand Down Expand Up @@ -127,14 +161,21 @@ function hasAllDocChanges (arr) {
})
}

function hasAllTestChanges (arr) {
return arr.every((val) => {
return /^test\//.test(val)
})
}

function matchExclusiveSubSystem (filepathsChanged) {
const isExclusive = filepathsChanged.every(matchesAnExclusiveLabel)
var labels = matchSubSystemsByRegex(exclusiveLabelsMap, filepathsChanged)

// if there are multiple API doc changes, do not apply subsystem tags for now
if (isExclusive &&
labels.includes('doc') &&
labels.length > 2) {
labels.length > 2 &&
!hasAllTestChanges(filepathsChanged)) {
const nonDocLabels = labels.filter((val) => {
return val !== 'doc'
})
Expand Down
157 changes: 122 additions & 35 deletions test/unit/node-labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ const tap = require('tap')

const nodeLabels = require('../../lib/node-labels')

tap.test('label: "test" when only ./test/ files has been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'test/debugger/test-debugger-pid.js',
'test/debugger/test-debugger-repl-break-in-module.js',
'test/debugger/test-debugger-repl-term.js'
])

t.same(labels, ['test'])

t.end()
})

tap.test('no labels: when ./test/ and ./doc/ files has been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'test/debugger/test-debugger-pid.js',
Expand Down Expand Up @@ -53,17 +41,6 @@ tap.test('label: "doc" when only ./doc/ files has been changed', (t) => {
t.end()
})

tap.test('label: "benchmark" when only ./benchmark/ files has been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'benchmark/http_server_lag.js',
'benchmark/http/check_is_http_token.js'
])

t.same(labels, ['benchmark'])

t.end()
})

tap.test('label: "c++" when ./src/* has been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'src/node.cc'
Expand Down Expand Up @@ -148,7 +125,7 @@ const srcCases = [
[ 'zlib', ['node_zlib.cc'] ]
]
for (const info of srcCases) {
var labels = info[0]
let labels = info[0]
if (!Array.isArray(labels)) {
labels = [labels]
}
Expand Down Expand Up @@ -399,22 +376,12 @@ tap.test('label: no version labels (master)', (t) => {
t.end()
})

tap.test('label: tools label', (t) => {
const labels = nodeLabels.resolveLabels([
'tools/doc/json.js'
])

t.same(labels, ['tools'])

t.end()
})

tap.test('label: build label (windows)', (t) => {
const labels = nodeLabels.resolveLabels([
'vcbuild.bat'
])

t.same(labels, ['build'])
t.same(labels, ['build', 'windows'])

t.end()
})
Expand All @@ -439,3 +406,123 @@ tap.test('label: doc label for non-subsystem API doc changes', (t) => {

t.end()
})

const specificBenchmarks = [
[ [], ['fixtures/alice.html', 'misc/freelist.js'] ],
[ 'assert', ['assert/deepequal-buffer.js'] ],
[ 'buffer', ['buffers/buffer-base64-decode.js'] ],
[ 'child_process', ['child_process/child-process-exec-stdout.js'] ],
[ 'crypto', ['crypto/aes-gcm-throughput.js'] ],
[ 'dgram', ['dgram/bind-params.js'] ],
[ 'domain', ['domain/domain-fn-args.js'] ],
[ 'events', ['events/ee-emit.js'] ],
[ 'fs', ['fs/readfile.js'] ],
[ 'http', ['_http-benchmarkers.js', 'http/simple.js'] ],
[ 'module', ['module/module-loader.js'] ],
[ 'net', ['net/net-c2s.js'] ],
[ 'os', ['os/loadavg.js'] ],
[ 'path', ['path/basename-posix.js'] ],
[ 'process', ['process/memoryUsage.js'] ],
[ 'querystring', ['querystring/querystring-parse.js'] ],
[ 'stream', ['streams/readable-readall.js'] ],
[ 'string_decoder', ['string_decoder/string-decoder.js'] ],
[ 'timers', ['timers/set-immediate-depth.js'] ],
[ 'tls', ['tls/throughput.js'] ],
[ 'url', ['url/url-resolve.js'] ],
[ 'util', ['util/format.js'] ],
[ 'V8', ['arrays/var-int.js', 'es/defaultparams-bench.js'] ],
[ 'vm', ['vm/run-in-context.js'] ]
]
for (const info of specificBenchmarks) {
let labels = info[0]
if (!Array.isArray(labels)) {
labels = ['benchmark', labels]
} else {
labels = ['benchmark'].concat(labels)
}
const files = info[1]
for (const file of files) {
tap.test(`label: "${labels.join('","')}" when ./benchmark/${file} has been changed`, (t) => {
const resolved = nodeLabels.resolveLabels([`benchmark/${file}`])

t.same(resolved, labels)

t.end()
})
}
}

const moreTools = [
'.eslintignore', '.editorconfig', '.eslintrc.yaml', '.remarkrc'
]
for (const file of moreTools) {
tap.test(`label: "tools" when ${file} has been changed`, (t) => {
const resolved = nodeLabels.resolveLabels([`${file}`])

t.same(resolved, ['tools'])

t.end()
})
}

const specificTests = [
[ 'addons', ['addons/async-hello-world/binding.cc'] ],
[ 'debugger', ['debugger/test-debugger-repl.js'] ],
[ ['doc', 'tools'], ['doctool/test-doctool-html.js'] ],
[ 'timers', ['timers/test-timers-reliability.js'] ],
[ 'tty', ['pseudo-tty/stdin-setrawmode.js'] ]
]
for (const info of specificTests) {
let labels = info[0]
if (!Array.isArray(labels)) {
labels = ['test', labels]
} else {
labels = ['test'].concat(labels)
}
const files = info[1]
for (const file of files) {
tap.test(`label: "${labels.join('","')}" when ./test/${file} has been changed`, (t) => {
const resolved = nodeLabels.resolveLabels([`test/${file}`])

t.same(resolved, labels)

t.end()
})
}
}

const specificTools = [
[ 'build', ['gyp/gyp_main.py', 'gyp_node.py'] ],
[ 'doc', ['doc/generate.js'] ],
[ 'intl', ['icu/icu-generate.gyp'] ],
[ 'macos',
['macosx-firewall.sh',
'osx-codesign.sh' ] ],
[ ['macos', 'install'],
['osx-pkg.pmdoc/index.xml.tmpl',
'pkgsrc/description' ] ],
[ ['test', 'npm'], ['test-npm.sh', 'test-npm-package.js'] ],
[ ['test'], ['test.py'] ],
[ ['openssl', 'tls'], ['certdata.txt', 'mkssldef.py', 'mk-ca-bundle.pl'] ],
[ ['windows'], ['sign.bat'] ],
[ ['windows', 'install'], ['msvs/msi/product.wxs'] ],
[ ['V8'], ['make-v8.sh'] ]
]
for (const info of specificTools) {
let labels = info[0]
if (!Array.isArray(labels)) {
labels = ['tools', labels]
} else {
labels = ['tools'].concat(labels)
}
const files = info[1]
for (const file of files) {
tap.test(`label: "${labels.join('","')}" when ./tools/${file} has been changed`, (t) => {
const resolved = nodeLabels.resolveLabels([`tools/${file}`])

t.same(resolved, labels)

t.end()
})
}
}