Skip to content

Commit b5d669a

Browse files
phillipjtargos
authored andcommitted
build: label PRs with GitHub Action instead of nodejs-github-bot
Main goal of using a GitHub Action for labelling PRs has been to move the mapping between files changed -> label into a configuration file local to the nodejs/node repository. Previously any changes to that mapping meant having to grasp the nodejs/github-bot project, open a PR with the neccessary changes, get approval from its maintainers before those changes finally got pushed to production. The logic involved in using the file paths / label configuration and resolving the labels to be applied, has been moved into a custom GitHub Action project: nodejs/node-pr-labeler. Aside from removing the external dependency the nodejs-github-bot is in practise, it also reduces the bar for contributors since the resulting project is a lot smaller and less complex than nodejs/github-bot. PR-URL: #38301 Fixes: nodejs/github-bot#294 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 451a93d commit b5d669a

File tree

2 files changed

+209
-0
lines changed

2 files changed

+209
-0
lines changed

.github/label-pr-config.yml

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
## Order of entries in this map *does* matter for the resolved labels
2+
## earlier entries override later entries
3+
subSystemLabels:
4+
# src subsystems
5+
/^src\/async-wrap/: c++, async_wrap
6+
/^src\/(?:base64|node_buffer|string_)/: c++, buffer
7+
/^src\/cares/: c++, cares
8+
/^src\/(?:process_wrap|spawn_)/: c++, child_process
9+
/^src\/(?:node_)?crypto/: c++, crypto
10+
/^src\/(?:debug-|node_debug)/: c++, debugger
11+
/^src\/udp_/: c++, dgram
12+
/^src\/(?:fs_|node_file|node_stat_watcher)/: c++, fs
13+
/^src\/node_http_parser/: c++, http_parser
14+
/^src\/node_i18n/: c++, intl
15+
/^src\/uv\./: c++, libuv
16+
/^src\/(?:connect(?:ion)?|pipe|tcp)_/: c++, net
17+
/^src\/node_os/: c++, os
18+
/^src\/(?:node_main|signal_)/: c++, process
19+
/^src\/timer_/: c++, timers
20+
/^src\/(?:CNNICHashWhitelist|node_root_certs|tls_)/: c++, tls
21+
/^src\/tty_/: c++, tty
22+
/^src\/node_url/: c++, url-whatwg
23+
/^src\/node_util/: c++, util
24+
/^src\/(?:node_v8|v8abbr)/: c++, V8 Engine
25+
/^src\/node_contextify/: c++, vm
26+
/^src\/.*win32.*/: c++, windows
27+
/^src\/node_zlib/: c++, zlib
28+
/^src\/tracing/: c++, tracing
29+
/^src\/node_api/: c++, n-api
30+
/^src\/node_http2/: c++, http2, dont-land-on-v6.x
31+
/^src\/node_report/: c++, report
32+
/^src\/node_wasi/: c++, wasi
33+
/^src\/node_worker/: c++, worker
34+
/^src\/quic\/*/: c++, quic, dont-land-on-v14.x, dont-land-on-v12.x
35+
/^src\/node_bob*/: c++, quic, dont-land-on-v14.x, dont-land-on-v12.x
36+
37+
# don't label python files as c++
38+
/^src\/.+\.py$/: lib / src, needs-ci
39+
40+
# properly label changes to v8 inspector integration-related files
41+
/^src\/inspector_/: c++, inspector, needs-ci
42+
43+
# don't want to label it a c++ update when we're "only" bumping the Node.js version
44+
/^src\/(?!node_version\.h)/: c++
45+
# BUILDING.md should be marked as 'build' in addition to 'doc'
46+
/^BUILDING\.md$/: build, doc
47+
# meta is a very specific label for things that are policy and or meta-info related
48+
/^([A-Z]+$|CODE_OF_CONDUCT|ROADMAP|WORKING_GROUPS|GOVERNANCE|CHANGELOG|\.mail|\.git.+)/: meta
49+
# things that edit top-level .md files are always a doc change
50+
/^\w+\.md$/: doc
51+
# different variants of *Makefile and build files
52+
/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles|\.travis\.yml)$/: build, needs-ci
53+
/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/: build, needs-ci
54+
/^vcbuild\.bat$/: build, windows, needs-ci
55+
/^(android-)?configure|node\.gyp|common\.gypi$/: build, needs-ci
56+
# more specific tools
57+
/^tools\/gyp/: tools, build, needs-ci
58+
/^tools\/doc\//: tools, doc
59+
/^tools\/icu\//: tools, intl, needs-ci
60+
/^tools\/(?:osx-pkg\.pmdoc|pkgsrc)\//: tools, macos, install
61+
/^tools\/(?:(?:mac)?osx-)/: tools, macos
62+
/^tools\/test-npm/: tools, test, npm
63+
/^tools\/test/: tools, test
64+
/^tools\/(?:certdata|mkssldef|mk-ca-bundle)/: tools, openssl, tls
65+
/^tools\/msvs\//: tools, windows, install, needs-ci
66+
/^tools\/[^/]+\.bat$/: tools, windows, needs-ci
67+
/^tools\/make-v8/: tools, V8 Engine, needs-ci
68+
/^tools\/(code_cache|snapshot|v8_gypfiles)/: needs-ci,
69+
/^tools\/build-addons.js/: needs-ci,
70+
# all other tool changes should be marked as such
71+
/^tools\//: tools
72+
/^\.eslint|\.remark|\.editorconfig/: tools
73+
74+
## Dependencies
75+
# libuv needs an explicit mapping, as the ordinary /deps/ mapping below would
76+
# end up as libuv changes labeled with "uv" (which is a non-existing label)
77+
/^deps\/uv\//: libuv
78+
/^deps\/v8\/tools\/gen-postmortem-metadata\.py/: V8 Engine, post-mortem
79+
/^deps\/v8\//: V8 Engine
80+
/^deps\/uvwasi\//: wasi
81+
/^deps\/nghttp2\/nghttp2\.gyp/: build, http2, dont-land-on-v6.x
82+
/^deps\/nghttp2\//: http2, dont-land-on-v6.x
83+
/^deps\/ngtcp2\//: quic, dont-land-on-v14.x, dont-land-on-v12.x
84+
/^deps\/nghttp3\//: quic, dont-land-on-v14.x, dont-land-on-v12.x
85+
/^deps\/([^/]+)/: $1
86+
87+
## JS subsystems
88+
# Oddities first
89+
/^lib\/(punycode|\w+\/freelist|sys\.js)/: ''
90+
/^lib\/constants\.js$/: lib / src
91+
/^lib\/_(debug_agent|debugger)\.js$/: debugger
92+
/^lib(\/\w+)?\/(_)?link(ed)?list/: timers
93+
/^lib\/\w+\/bootstrap_node/: lib / src
94+
/^lib\/\w+\/v8_prof_/: tools
95+
/^lib\/\w+\/socket_list/: net
96+
/^lib\/\w+\/streams$/: stream
97+
/^lib\/.*http2/: http2, dont-land-on-v6.x
98+
/^lib\/worker_threads.js$/: worker
99+
/^lib\/internal\/url\.js$/: url-whatwg
100+
/^lib\/internal\/modules\/esm/: ES Modules
101+
/^lib\/internal\/quic\/*/: quic, dont-land-on-v14.x, dont-land-on-v12.x
102+
103+
# All other lib/ files map directly
104+
/^lib\/_(\w+)_\w+\.js?$/: $1 # e.g. _(stream)_wrap
105+
/^lib(\/internal)?\/(\w+)\.js?$/: $2 # other .js files
106+
/^lib\/internal\/(\w+)(?:\/|$)/: $1 # internal subfolders
107+
108+
exlusiveLabels:
109+
# more specific tests
110+
/^test\/addons\//: test, addons
111+
/^test\/debugger\//: test, debugger
112+
/^test\/doctool\//: test, doc, tools
113+
/^test\/timers\//: test, timers
114+
/^test\/pseudo-tty\//: test, tty
115+
/^test\/inspector\//: test, inspector
116+
/^test\/cctest\/test_inspector/: test, inspector
117+
/^test\/cctest\/test_url/: test, url-whatwg
118+
/^test\/addons-napi\//: test, n-api
119+
/^test\/async-hooks\//: test, async_hooks
120+
/^test\/report\//: test, report
121+
/^test\/fixtures\/es-module/: test, ES Modules
122+
/^test\/es-module\//: test, ES Modules
123+
124+
/^test\//: test
125+
126+
# specific map for webcrypto.md as it should be labeled 'crypto'
127+
/^doc\/api\/webcrypto.md$/: doc, crypto
128+
# specific map for modules.md as it should be labeled 'module' not 'modules'
129+
/^doc\/api\/modules.md$/: doc, module
130+
# specific map for esm.md as it should be labeled 'ES Modules' not 'esm'
131+
/^doc\/api\/esm.md$/: doc, ES Modules
132+
# n-api is treated separately since it is not a JS core module but is still
133+
# considered a subsystem of sorts
134+
/^doc\/api\/n-api.md$/: doc, n-api
135+
# quic
136+
/^doc\/api\/quic.md$/: doc, quic, dont-land-on-v14.x, dont-land-on-v12.x
137+
# add worker label to PRs that affect doc/api/worker_threads.md
138+
/^doc\/api\/worker_threads.md$/: doc, worker
139+
# automatically tag JS subsystem-specific API doc changes
140+
/^doc\/api\/(\w+)\.md$/: doc, $1
141+
# add deprecations label to PRs that affect doc/api/deprecations.md
142+
/^doc\/api\/deprecations.md$/: doc, deprecations
143+
144+
/^doc\//: doc
145+
146+
# more specific benchmarks
147+
/^benchmark\/buffers\//: benchmark, buffer
148+
/^benchmark\/(?:arrays|es)\//: benchmark, V8 Engine
149+
/^benchmark\/_http/: benchmark, http
150+
/^benchmark\/(?:misc|fixtures)\//: benchmark
151+
/^benchmark\/streams\//: benchmark, stream
152+
/^benchmark\/([^/]+)\//: benchmark, $1
153+
154+
/^benchmark\//: benchmark
155+
156+
allJsSubSystems:
157+
- assert
158+
- async_hooks
159+
- buffer
160+
- child_process
161+
- cluster
162+
- console
163+
- crypto
164+
- debugger
165+
- dgram
166+
- dns
167+
- domain
168+
- events
169+
- esm
170+
- fs
171+
- http
172+
- https
173+
- http2
174+
- module
175+
- net
176+
- os
177+
- path
178+
- process
179+
- querystring
180+
- quic
181+
- readline
182+
- repl
183+
- report
184+
- stream
185+
- string_decoder
186+
- timers
187+
- tls
188+
- tty
189+
- url
190+
- util
191+
- v8
192+
- vm
193+
- wasi
194+
- worker
195+
- zlib

.github/workflows/label-pr.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Label PRs
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
label:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: node/node-pr-labeler@v1
13+
with:
14+
configuration-path: .github/label-pr-config.yml

0 commit comments

Comments
 (0)