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
24 changes: 13 additions & 11 deletions .github/pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ subSystemLabels:
/^src\/node_bob*/: c++, quic, dont-land-on-v14.x, dont-land-on-v12.x

# don't label python files as c++
/^src\/.+\.py$/: lib / src
/^src\/.+\.py$/: lib / src, needs-ci

# properly label changes to v8 inspector integration-related files
/^src\/inspector_/: c++, inspector
/^src\/inspector_/: c++, inspector, needs-ci

# don't want to label it a c++ update when we're "only" bumping the Node.js version
/^src\/(?!node_version\.h)/: c++
Expand All @@ -54,22 +54,24 @@ subSystemLabels:
# things that edit top-level .md files are always a doc change
/^\w+\.md$/: doc
# different variants of *Makefile and build files
/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles|\.travis\.yml)$/: build
/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/: build
/^vcbuild\.bat$/: build, windows
/^(android-)?configure|node\.gyp|common\.gypi$/: build
/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles|\.travis\.yml)$/: build, needs-ci
/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/: build, needs-ci
/^vcbuild\.bat$/: build, windows, needs-ci
/^(android-)?configure|node\.gyp|common\.gypi$/: build, needs-ci
# more specific tools
/^tools\/gyp/: tools, build
/^tools\/gyp/: tools, build, needs-ci
/^tools\/doc\//: tools, doc
/^tools\/icu\//: tools, intl
/^tools\/icu\//: tools, intl, needs-ci
/^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 Engine
/^tools\/msvs\//: tools, windows, install, needs-ci
/^tools\/[^/]+\.bat$/: tools, windows, needs-ci
/^tools\/make-v8/: tools, V8 Engine, needs-ci
/^tools\/(code_cache|snapshot|v8_gypfiles)/: needs-ci,
/^tools\/build-addons.js/: needs-ci,
# all other tool changes should be marked as such
/^tools\//: tools
/^\.eslint|\.remark|\.editorconfig/: tools
Expand Down
10 changes: 8 additions & 2 deletions lib/resolve-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const yaml = require('js-yaml')

const ciNeededFolderRx = /^(deps|lib|src|test)\//

function parseRegexToLabelsConfig (objectFromYaml) {
return Object.entries(objectFromYaml)
.map(([regexAsString, labelsAsString]) => {
Expand Down Expand Up @@ -86,6 +88,10 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged) {

// by putting matched labels into a map, we avoid duplicate labels
const labelsMap = filepathsChanged.reduce((map, filepath) => {
if (ciNeededFolderRx.test(filepath) && !map['needs-ci']) {
map['needs-ci'] = true
}

const mappedSubSystems = mappedSubSystemsForFile(rxLabelsMap, filepath)

if (!mappedSubSystems) {
Expand All @@ -98,8 +104,8 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged) {
if (hasLibOrSrcChanges(filepathsChanged)) {
if (labelCount.length >= labelsCountLimit) {
for (const label of labelCount) {
// don't delete the c++ label as we always want that if it has matched
if (label !== 'c++') delete map[label]
// don't delete the `c++` or `needs-ci` labels as we always want those if they have matched
if (label !== 'c++' && label !== 'needs-ci') delete map[label]
}
map['lib / src'] = true
// short-circuit
Expand Down
4 changes: 3 additions & 1 deletion test/node-build-label.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ tap.test('label: "build" when build related files has been changed', (t) => {
buildRelatedFiles.forEach((filepath) => {
const labels = resolveLabels([filepath])

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

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

t.notOk(labels.includes('build'))
t.ok(labels.includes('needs-ci'))

t.end()
})
6 changes: 5 additions & 1 deletion test/node-js-subsystem-labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ tap.test('label: lib oddities', (t) => {
const labels = resolveLabels(libFiles)

t.same(labels, [
'needs-ci', // lib/
'debugger', // _debug_agent
'http', // _http_*
'timers', // linklist
Expand All @@ -68,6 +69,7 @@ tap.test('label: lib internals oddities duplicates', (t) => {
const labels = resolveLabels(libFiles)

t.same(labels, [
'needs-ci', // lib/
'lib / src', // bootstrap_node
'timers', // linkedlist
'stream' // internal/streams/
Expand Down Expand Up @@ -116,6 +118,7 @@ tap.test('label: lib/ paths', (t) => {
const expected = /lib\/(_)?(\w+)\.js/.exec(filepath)[2]
const labels = resolveLabels([filepath])

t.same(labels.shift(), 'needs-ci')
t.same(labels, [expected], `${filepath} got "${expected}" label`)
})

Expand All @@ -138,6 +141,7 @@ tap.test('label: lib/internals/ paths', (t) => {
const expected = /lib\/internal\/(\w+)\.js/.exec(filepath)[1]
const labels = resolveLabels([filepath])

t.same(labels.shift(), 'needs-ci')
t.same(labels, [expected], `${filepath} got "${expected}" label`)
})

Expand Down Expand Up @@ -181,7 +185,7 @@ tap.test('label: appropriate labels for files in internal subdirectories', (t) =
'lib/internal/process/next_tick.js'
])

t.same(labels, ['cluster', 'process'])
t.same(labels, ['needs-ci', 'cluster', 'process'])

t.end()
})
Loading