mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-18 14:56:50 +02:00
Compare commits
1923 Commits
n8n@2.39.7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2dc2f9ce5 | ||
|
|
84943adc6c | ||
|
|
ff975f1b9e | ||
|
|
936349a9c7 | ||
|
|
842ec5b62d | ||
|
|
ec074519d9 | ||
|
|
6f3b397a1e | ||
|
|
21221adc78 | ||
|
|
532e8ef930 | ||
|
|
24621ad4ca | ||
|
|
8ee5cf1845 | ||
|
|
7f16040253 | ||
|
|
ddc97694b5 | ||
|
|
eaf47cfe39 | ||
|
|
986b82fa28 | ||
|
|
76cce99626 | ||
|
|
f34c093f08 | ||
|
|
158152496a | ||
|
|
1f223c85f8 | ||
|
|
6a015ecb18 | ||
|
|
033ec05bff | ||
|
|
dd79a610c5 | ||
|
|
a63a8edb55 | ||
|
|
f5dc06f753 | ||
|
|
b78913f75d | ||
|
|
dfec6dee81 | ||
|
|
f92b4c11d6 | ||
|
|
5120d25cbc | ||
|
|
a6719b8db7 | ||
|
|
7001886432 | ||
|
|
a906d2fdfc | ||
|
|
683fd11259 | ||
|
|
1b02863c00 | ||
|
|
d0cb582163 | ||
|
|
ea98bd0600 | ||
|
|
1405d4a351 | ||
|
|
f84413516a | ||
|
|
333a010112 | ||
|
|
b7b3d72737 | ||
|
|
5a3fc39972 | ||
|
|
d460eb28ca | ||
|
|
4a5fdd5b68 | ||
|
|
e7f0607bf1 | ||
|
|
64d8a3ad19 | ||
|
|
c70b5d49b3 | ||
|
|
c28d130c6c | ||
|
|
ca9661c091 | ||
|
|
a94f5dc8b7 | ||
|
|
fffea4c0c0 | ||
|
|
14e633d481 | ||
|
|
575eb6fa43 | ||
|
|
3ea0a3da98 | ||
|
|
fed8b1ec69 | ||
|
|
eba25caa70 | ||
|
|
fe3627914a | ||
|
|
aba5258930 | ||
|
|
aadbb7c498 | ||
|
|
8bee1eeb20 | ||
|
|
2eab299dfa | ||
|
|
fc9f9575e2 | ||
|
|
116a81e06e | ||
|
|
b36f6c0baf | ||
|
|
fa88c3e251 | ||
|
|
8120328661 | ||
|
|
1ee29b2875 | ||
|
|
f553331100 | ||
|
|
1a6b6a65d4 | ||
|
|
88a2426947 | ||
|
|
f5febab84d | ||
|
|
dde9871497 | ||
|
|
cc83b5bd77 | ||
|
|
1ea18e9ef9 | ||
|
|
1ba56b6579 | ||
|
|
baa38dbdc6 | ||
|
|
601f6ac0da | ||
|
|
e29c3a4085 | ||
|
|
447fc866bb | ||
|
|
860f1273eb | ||
|
|
deed9a2f32 | ||
|
|
a32c652c09 | ||
|
|
1903d53bc0 | ||
|
|
131e9c8679 | ||
|
|
236220b248 | ||
|
|
af0202d840 | ||
|
|
adc6d35388 | ||
|
|
b2b2a8641a | ||
|
|
952b1e73b2 | ||
|
|
f596162dc7 | ||
|
|
378847ae1e | ||
|
|
9e3b52cbbb | ||
|
|
054288e488 | ||
|
|
c839d6cd49 | ||
|
|
154cd63bbc | ||
|
|
3c447b42a7 | ||
|
|
1659fa3737 | ||
|
|
9806798e89 | ||
|
|
cdeb405948 | ||
|
|
e45a65a9bf | ||
|
|
b68bd3129b | ||
|
|
e8ded61fe1 | ||
|
|
d046047dd0 | ||
|
|
f483ebd9d1 | ||
|
|
fddef57734 | ||
|
|
ba97e46afc | ||
|
|
4cb7a6ee3d | ||
|
|
8ed8607a52 | ||
|
|
67c1981f2f | ||
|
|
a8880cb449 | ||
|
|
d411a44be0 | ||
|
|
0c0b38e3cb | ||
|
|
315e0a5377 | ||
|
|
efd4e21aad | ||
|
|
bab83634ce | ||
|
|
d6c9b9fba3 | ||
|
|
b36befcb75 | ||
|
|
ed2500ffb2 | ||
|
|
9c0b546a30 | ||
|
|
07595a0007 | ||
|
|
1e67d0315d | ||
|
|
338b0ca3fd | ||
|
|
48edbef643 | ||
|
|
5d79c16f51 | ||
|
|
40094e363b | ||
|
|
e2529a8494 | ||
|
|
50c4ced224 | ||
|
|
b7a5500d16 | ||
|
|
f6b24d0ae9 | ||
|
|
3c7dcf902d | ||
|
|
fbe743b9df | ||
|
|
f5924004ca | ||
|
|
b270d48686 | ||
|
|
3277f8c3b5 | ||
|
|
a57c8f3aba | ||
|
|
dcd312c5a9 | ||
|
|
a6d5b4de3f | ||
|
|
3968a60bf7 | ||
|
|
17fb3c0e17 | ||
|
|
b965e90307 | ||
|
|
38135e1f83 | ||
|
|
616062487a | ||
|
|
1950434a27 | ||
|
|
b3e8b7d9ce | ||
|
|
56eac665c3 | ||
|
|
8bc7161ab1 | ||
|
|
57e26feda4 | ||
|
|
9c42a76b1a | ||
|
|
ae374e79ab | ||
|
|
ef8d61bda7 | ||
|
|
caeaff7230 | ||
|
|
a3f47117cf | ||
|
|
9a524e7c21 | ||
|
|
adedbbf560 | ||
|
|
4eb63d6f41 | ||
|
|
b6d39e2d30 | ||
|
|
7920e6cf6b | ||
|
|
76c43094cd | ||
|
|
898701b05b | ||
|
|
f63111202f | ||
|
|
633eacaae6 | ||
|
|
1b0cdd5998 | ||
|
|
578eea403d | ||
|
|
7c38974070 | ||
|
|
d68ad7e97b | ||
|
|
0650b9cce0 | ||
|
|
df7b3a19c6 | ||
|
|
de42c9515d | ||
|
|
d26f914e3d | ||
|
|
8b5ea6d9e0 | ||
|
|
bfd4885026 | ||
|
|
3800bce812 | ||
|
|
aae8eb63d7 | ||
|
|
0b4c99f10d | ||
|
|
066480d8db | ||
|
|
b8780d8fee | ||
|
|
e47940eecd | ||
|
|
e3b2603d7b | ||
|
|
726a5829c8 | ||
|
|
54f1670791 | ||
|
|
b3e8634c83 | ||
|
|
1643a8598b | ||
|
|
9498088256 | ||
|
|
da3491fc87 | ||
|
|
d83f95b377 | ||
|
|
46761a60a9 | ||
|
|
ccf42e3213 | ||
|
|
94bdf85a8a | ||
|
|
29de1c63ae | ||
|
|
92f8eb51b3 | ||
|
|
146d7804af | ||
|
|
88de3cac20 | ||
|
|
04f4afe3dc | ||
|
|
6924027e93 | ||
|
|
ef183e632d | ||
|
|
ed1c1e561a | ||
|
|
a3a014422f | ||
|
|
f1fecf97e9 | ||
|
|
5da4d19e50 | ||
|
|
2019ea5593 | ||
|
|
4419fc4ba2 | ||
|
|
52aed7ac97 | ||
|
|
1d2c879fab | ||
|
|
bffe7d8392 | ||
|
|
d245b17b89 | ||
|
|
8977833ee2 | ||
|
|
acf5291d80 | ||
|
|
ebf078b64c | ||
|
|
9052f8ff3e | ||
|
|
e0fe04084e | ||
|
|
e859abaf18 | ||
|
|
a972eebe51 | ||
|
|
739c59e991 | ||
|
|
de090cb2a0 | ||
|
|
b97fe7c7d4 | ||
|
|
38e4aebfc8 | ||
|
|
d8a06666da | ||
|
|
60e0cb1e7b | ||
|
|
b09efb706c | ||
|
|
f090f53480 | ||
|
|
347385b07b | ||
|
|
bb45bca5ff | ||
|
|
3075b60576 | ||
|
|
4fcb628fca | ||
|
|
1ee379898b | ||
|
|
366ed6ed0e | ||
|
|
248c86355b | ||
|
|
e5866ac6c1 | ||
|
|
2bc3265e63 | ||
|
|
f6861fe494 | ||
|
|
632d8b9eb0 | ||
|
|
5549374241 | ||
|
|
cba16247b9 | ||
|
|
e528f948ce | ||
|
|
d3bc2754b4 | ||
|
|
ffda639b3f | ||
|
|
97e5ae56e4 | ||
|
|
bda9118168 | ||
|
|
96eff1efb9 | ||
|
|
eb66e1bde0 | ||
|
|
a8a028e2dc | ||
|
|
44c8a312c3 | ||
|
|
7bad46ee7e | ||
|
|
45eea1bc35 | ||
|
|
c8c8c3a81e | ||
|
|
e74f1c19da | ||
|
|
f16c1375b1 | ||
|
|
5146e3960f | ||
|
|
14c77900df | ||
|
|
bae368caca | ||
|
|
f3e2bd83b3 | ||
|
|
27fcb968fb | ||
|
|
2562744611 | ||
|
|
8d93e31d1d | ||
|
|
2596f3ac1c | ||
|
|
e2c4054cba | ||
|
|
2ca4e55502 | ||
|
|
cea974e770 | ||
|
|
ce20d1dea4 | ||
|
|
53d1fd5991 | ||
|
|
776f4e1944 | ||
|
|
3ff9c83bda | ||
|
|
89733cdb9a | ||
|
|
0209caafff | ||
|
|
0755255c35 | ||
|
|
36ae8f74ce | ||
|
|
160c126c6e | ||
|
|
d3deffbfa5 | ||
|
|
b542f66119 | ||
|
|
f0a38cfe58 | ||
|
|
27b43de85f | ||
|
|
7ceb84f06c | ||
|
|
2a51f38d55 | ||
|
|
e0958fe094 | ||
|
|
bc8b803471 | ||
|
|
26d93b601a | ||
|
|
c9cb3ee3ab | ||
|
|
22ff2a0636 | ||
|
|
7dae1b64de | ||
|
|
27aa660a74 | ||
|
|
6cd3539b1e | ||
|
|
97ca4c49e0 | ||
|
|
bd22105646 | ||
|
|
e16066c322 | ||
|
|
7cd9fcd3d1 | ||
|
|
2176819865 | ||
|
|
d038f89e91 | ||
|
|
3dd805d9ed | ||
|
|
16e29da52f | ||
|
|
b8b0387a31 | ||
|
|
8b6352a6fa | ||
|
|
839b841dda | ||
|
|
53a6019ad5 | ||
|
|
2a1fde3634 | ||
|
|
37799ad2f2 | ||
|
|
a1800105ef | ||
|
|
6b77613ee8 | ||
|
|
205c1c3ee5 | ||
|
|
65cc931018 | ||
|
|
3dd3efc42f | ||
|
|
ca9b10054c | ||
|
|
c9f54fab4d | ||
|
|
82d21934d3 | ||
|
|
1f27b98366 | ||
|
|
30d883e866 | ||
|
|
3ec89b24dc | ||
|
|
2e049bb3de | ||
|
|
8297b2e6d2 | ||
|
|
601304543d | ||
|
|
ceaa82cd4f | ||
|
|
444e4a9384 | ||
|
|
45938389b8 | ||
|
|
3301b2cc0f | ||
|
|
529b0d1c3b | ||
|
|
7424f0ca04 | ||
|
|
a33ecf7481 | ||
|
|
3085f45f71 | ||
|
|
ed4fbf4ed3 | ||
|
|
feed158ba2 | ||
|
|
9ff8d4fc73 | ||
|
|
5bc6021477 | ||
|
|
50c2ca0a27 | ||
|
|
d6370a0002 | ||
|
|
44a6370aba | ||
|
|
ef000908e7 | ||
|
|
cdf3787834 | ||
|
|
5e01906a1e | ||
|
|
f05b29abeb | ||
|
|
b33b0db040 | ||
|
|
d1422fb652 | ||
|
|
87c9b1c52a | ||
|
|
be402be262 | ||
|
|
cdc23c666f | ||
|
|
bbd35e281b | ||
|
|
55eb2ce442 | ||
|
|
4032797790 | ||
|
|
c7135451eb | ||
|
|
88a2531558 | ||
|
|
75de193d90 | ||
|
|
ee8a608a22 | ||
|
|
55def8cc2b | ||
|
|
85f690d3b9 | ||
|
|
c2e625bbb0 | ||
|
|
344dea5c77 | ||
|
|
b28dceb462 | ||
|
|
a7cba90a85 | ||
|
|
0d7df52a45 | ||
|
|
55200605dd | ||
|
|
cde7a9dbd9 | ||
|
|
ff7ef60841 | ||
|
|
c92141d141 | ||
|
|
9e1866736c | ||
|
|
22ba4e7bc5 | ||
|
|
033a9b512c | ||
|
|
e2b4fee0ec | ||
|
|
35078f1d04 | ||
|
|
a2ac242b91 | ||
|
|
e64dc46055 | ||
|
|
fd06e07efa | ||
|
|
21af799450 | ||
|
|
fd04f01e8e | ||
|
|
af98327a5e | ||
|
|
c21ed4f13a | ||
|
|
8b7065a876 | ||
|
|
8f9f673b86 | ||
|
|
a3391ba93c | ||
|
|
56e2802e67 | ||
|
|
aee0b23b8e | ||
|
|
d3173d3893 | ||
|
|
19337237ec | ||
|
|
d900743bce | ||
|
|
978f810bbe | ||
|
|
ae15984493 | ||
|
|
9f85b8379c | ||
|
|
24b9db41b3 | ||
|
|
503092ccca | ||
|
|
16a8db6675 | ||
|
|
bc0a9cbc11 | ||
|
|
c6f1e20d9e | ||
|
|
a249e20290 | ||
|
|
1c84af2e96 | ||
|
|
aca9033dca | ||
|
|
2efdd3e021 | ||
|
|
01da88958d | ||
|
|
6f5f79321b | ||
|
|
690fbb525a | ||
|
|
5480258fb5 | ||
|
|
bfebfd26c1 | ||
|
|
806a2aa94b | ||
|
|
13679fcb97 | ||
|
|
75a9cc7e12 | ||
|
|
03248c11bf | ||
|
|
23b6de7028 | ||
|
|
53d33b0f95 | ||
|
|
c4f84e2f78 | ||
|
|
3ba522910b | ||
|
|
6fc0aeda35 | ||
|
|
5b78e8b655 | ||
|
|
cef87cfcab | ||
|
|
a2c8142013 | ||
|
|
cabf0bf3b4 | ||
|
|
84d2fd6f3a | ||
|
|
ce1be847c8 | ||
|
|
fe26ba8d3a | ||
|
|
03f7c76acd | ||
|
|
e67e5a9ef1 | ||
|
|
3a37ec1dcc | ||
|
|
77a692a4bb | ||
|
|
6a41a5ed39 | ||
|
|
ea8417e29a | ||
|
|
5543023723 | ||
|
|
05a4abd700 | ||
|
|
740159411a | ||
|
|
346cbaa316 | ||
|
|
a83c438af4 | ||
|
|
49a3812bc3 | ||
|
|
9946cfe901 | ||
|
|
4c0902f6bf | ||
|
|
d7e9b00234 | ||
|
|
63dc285493 | ||
|
|
5a46327401 | ||
|
|
1ad3c54803 | ||
|
|
5d208c85ed | ||
|
|
209adf9a7e | ||
|
|
04e1e7fc47 | ||
|
|
2aa3fbf185 | ||
|
|
983f5ecea8 | ||
|
|
4e217aeac6 | ||
|
|
d904e7a247 | ||
|
|
f7e52a851e | ||
|
|
1e6da4e615 | ||
|
|
40c0525bed | ||
|
|
0f02b509be | ||
|
|
8ad9b5415e | ||
|
|
e11fe8afb0 | ||
|
|
fdc394819c | ||
|
|
74a8a37134 | ||
|
|
86877c557a | ||
|
|
b464dea23c | ||
|
|
d008d6cee9 | ||
|
|
96a8ff4d15 | ||
|
|
a195096733 | ||
|
|
aef216cb25 | ||
|
|
370b30f919 | ||
|
|
97c54f618c | ||
|
|
c133d6c893 | ||
|
|
a584136b6f | ||
|
|
986f6b49e3 | ||
|
|
1d63a8f3a1 | ||
|
|
f212d5b900 | ||
|
|
f4f7dcf13b | ||
|
|
6cdd1ffbbb | ||
|
|
81f34c2374 | ||
|
|
168a0ac860 | ||
|
|
727f2a74ea | ||
|
|
3b0337d894 | ||
|
|
3c33856997 | ||
|
|
6b8ac76d96 | ||
|
|
d138b8ff4b | ||
|
|
566a1dafc6 | ||
|
|
6bc5c93513 | ||
|
|
b28adf9789 | ||
|
|
7397073d86 | ||
|
|
1ea8397d69 | ||
|
|
86847d7f16 | ||
|
|
33cd4d5cc1 | ||
|
|
60ad29f242 | ||
|
|
9191cf3fb0 | ||
|
|
668e71d54a | ||
|
|
1e919c7c56 | ||
|
|
9d3eb0c637 | ||
|
|
bef5f3f97a | ||
|
|
c194d22b5c | ||
|
|
df8605e875 | ||
|
|
fbbbadc292 | ||
|
|
4b5b68ee29 | ||
|
|
09436b78f9 | ||
|
|
19e1f70ea6 | ||
|
|
0722ddbbd5 | ||
|
|
88b22abf15 | ||
|
|
e36093b11d | ||
|
|
2f4a3868fb | ||
|
|
3816c4afec | ||
|
|
48f05f92fe | ||
|
|
e2733c5b86 | ||
|
|
682d0920ba | ||
|
|
2863939580 | ||
|
|
35972133b0 | ||
|
|
0bbea438e1 | ||
|
|
6b4da93dcb | ||
|
|
e16566b313 | ||
|
|
1de45a1a9b | ||
|
|
1ef77564e3 | ||
|
|
4c8b76b6f0 | ||
|
|
00849c4dea | ||
|
|
a440967b12 | ||
|
|
1c63119756 | ||
|
|
022b23945b | ||
|
|
f31e1a83eb | ||
|
|
eac5d1d7b3 | ||
|
|
eaf8c25d1c | ||
|
|
741ba22943 | ||
|
|
e7d8533880 | ||
|
|
bb76c3c99b | ||
|
|
f26747bfc6 | ||
|
|
084f3b376a | ||
|
|
dc5c80f26a | ||
|
|
5ab2187416 | ||
|
|
dc33c29d1a | ||
|
|
4975ab82fe | ||
|
|
447e939b73 | ||
|
|
4e802ff11d | ||
|
|
0885af531a | ||
|
|
b1ec8e525c | ||
|
|
a694531a03 | ||
|
|
684b181101 | ||
|
|
df4af50125 | ||
|
|
02af7e7659 | ||
|
|
b7d7a18980 | ||
|
|
16dc6fe403 | ||
|
|
779ddcc517 | ||
|
|
e1025f35e4 | ||
|
|
3014c64264 | ||
|
|
4ae863717e | ||
|
|
3cff8dc4ec | ||
|
|
81cdc278c2 | ||
|
|
e500386a54 | ||
|
|
e882e8a483 | ||
|
|
66b382de52 | ||
|
|
3af98170d0 | ||
|
|
6ef70a7303 | ||
|
|
32d472fe76 | ||
|
|
6d1144cea3 | ||
|
|
0e1c754999 | ||
|
|
90b8205b62 | ||
|
|
883ade4b9d | ||
|
|
b36c2b506b | ||
|
|
ee1db0bc12 | ||
|
|
b0d1a30f50 | ||
|
|
77370af99a | ||
|
|
a13705aa8f | ||
|
|
76cab1e26d | ||
|
|
8059b63da8 | ||
|
|
e7f8fa38cf | ||
|
|
f72461d56d | ||
|
|
24dda0d435 | ||
|
|
8924a11fda | ||
|
|
0932e9572e | ||
|
|
830486a851 | ||
|
|
15d597c4ca | ||
|
|
2fe28ea0ee | ||
|
|
c2f6920794 | ||
|
|
2b685c33b6 | ||
|
|
62fd028089 | ||
|
|
fb11cc482e | ||
|
|
d5132d21e0 | ||
|
|
0bd0cd2873 | ||
|
|
e5c8a8bb62 | ||
|
|
611a6cccda | ||
|
|
38eea65993 | ||
|
|
c4112794fa | ||
|
|
3d8b3b99c6 | ||
|
|
fc1c26d867 | ||
|
|
5d3866775c | ||
|
|
c134edf473 | ||
|
|
3366d2b9b3 | ||
|
|
7c126fab32 | ||
|
|
72960562ce | ||
|
|
de72b7fa0d | ||
|
|
d767edfacd | ||
|
|
cf54433c14 | ||
|
|
a6f1e79394 | ||
|
|
3287ef1409 | ||
|
|
73dad06bea | ||
|
|
4cb98aea9f | ||
|
|
05a992d4f2 | ||
|
|
8b68b0fcdd | ||
|
|
958d23d81c | ||
|
|
3c18f58ee0 | ||
|
|
2d09135c6e | ||
|
|
b7960d7a85 | ||
|
|
71ffb4c8cc | ||
|
|
6ea9b1f3bb | ||
|
|
264a931de2 | ||
|
|
e82087bcc8 | ||
|
|
fe91413e5d | ||
|
|
f4c734e7e0 | ||
|
|
4b69c32541 | ||
|
|
39abed9124 | ||
|
|
f26d7fbfe7 | ||
|
|
9ee5d1ad7a | ||
|
|
7db7fa42c8 | ||
|
|
3f2144f062 | ||
|
|
a11777054a | ||
|
|
a448b8d2df | ||
|
|
b82ad639e8 | ||
|
|
439e8ba2e7 | ||
|
|
0280644e77 | ||
|
|
308ec2cc1c | ||
|
|
5c0aff8cbc | ||
|
|
314c430bfc | ||
|
|
f7cfb520bf | ||
|
|
a2fd4189f1 | ||
|
|
5f73c7cdcb | ||
|
|
02f08035b4 | ||
|
|
680f9582e1 | ||
|
|
f055d9cd11 | ||
|
|
b5fe251ba5 | ||
|
|
b7071c91c7 | ||
|
|
206fc6f317 | ||
|
|
01f072b520 | ||
|
|
548bd57802 | ||
|
|
4939dbc787 | ||
|
|
022f4a6477 | ||
|
|
8fa89ee02f | ||
|
|
8f13f2830a | ||
|
|
9183d0422c | ||
|
|
073239e6d5 | ||
|
|
7779f47a7d | ||
|
|
79924a5d93 | ||
|
|
1942447e90 | ||
|
|
44d9adfc7e | ||
|
|
fa8b8b243e | ||
|
|
c4c31a529c | ||
|
|
92ae1b336f | ||
|
|
e3aa15d7d7 | ||
|
|
360ec09cf2 | ||
|
|
1cac1e056d | ||
|
|
fe07e84d0f | ||
|
|
6610987057 | ||
|
|
94a49d08ce | ||
|
|
6a5aa7862e | ||
|
|
f47a2fe235 | ||
|
|
32d7c8ebf4 | ||
|
|
274639fb88 | ||
|
|
a9b0607111 | ||
|
|
b9695a7f6e | ||
|
|
b8cd29fde4 | ||
|
|
fb69206450 | ||
|
|
4ea06438db | ||
|
|
674fb57941 | ||
|
|
d931d6415a | ||
|
|
25831a8ac0 | ||
|
|
708e79264b | ||
|
|
5e28ff8c23 | ||
|
|
b0803dc450 | ||
|
|
72a4024161 | ||
|
|
e18afc84cc | ||
|
|
bec84a1dad | ||
|
|
e6bb9e0f3b | ||
|
|
d6a364c0c0 | ||
|
|
68ced97f81 | ||
|
|
a1370863e4 | ||
|
|
d6ec4c5546 | ||
|
|
be2ee6f356 | ||
|
|
388b4036d4 | ||
|
|
e77e30c7d9 | ||
|
|
e8b9821f4a | ||
|
|
ea9f451076 | ||
|
|
43fe82b10f | ||
|
|
f0ca6b24f4 | ||
|
|
944afe5c88 | ||
|
|
bae7656347 | ||
|
|
51c4770643 | ||
|
|
df27223a4e | ||
|
|
56d6e9da2c | ||
|
|
afd7cb4851 | ||
|
|
b8ff99f2cc | ||
|
|
3fe4612d93 | ||
|
|
dae811ddd9 | ||
|
|
ea38f3a3ee | ||
|
|
628ada76cd | ||
|
|
a30bb7d89d | ||
|
|
1043504c7a | ||
|
|
ea9021ed86 | ||
|
|
a3ae96e87b | ||
|
|
93c1291f6d | ||
|
|
6337b94d3c | ||
|
|
9675fc97fd | ||
|
|
1adc57b97b | ||
|
|
407cf23da7 | ||
|
|
1998011d90 | ||
|
|
e0c27dd34f | ||
|
|
03072faadc | ||
|
|
fd6c1af1a0 | ||
|
|
01d6a1019c | ||
|
|
387905148a | ||
|
|
51be26d7e2 | ||
|
|
064c3bf979 | ||
|
|
87ca4e8bf7 | ||
|
|
0ae0b6b3c2 | ||
|
|
69595f5821 | ||
|
|
aae8016c84 | ||
|
|
deaa9b1054 | ||
|
|
e79a2ba84b | ||
|
|
f6f71abef4 | ||
|
|
ff78115647 | ||
|
|
b22b6f4909 | ||
|
|
28bd124258 | ||
|
|
b4e5fa6eef | ||
|
|
0352a19654 | ||
|
|
89e88f87f2 | ||
|
|
900fe0c03a | ||
|
|
8e339d7051 | ||
|
|
9adaa38f22 | ||
|
|
9e5eb79cc4 | ||
|
|
37ed348665 | ||
|
|
c4d31db8d6 | ||
|
|
0a1ed4e09b | ||
|
|
93c0a5c0ff | ||
|
|
fc3954bfe2 | ||
|
|
d556c318f4 | ||
|
|
7576de5f26 | ||
|
|
c95e34f97a | ||
|
|
01e5ebf726 | ||
|
|
b9368f4db8 | ||
|
|
d262baceef | ||
|
|
f7e82abcba | ||
|
|
6438ead58d | ||
|
|
17fbae497b | ||
|
|
7d5730f688 | ||
|
|
1b294221b5 | ||
|
|
c5658ba4bf | ||
|
|
d09e6d65fc | ||
|
|
a969387ca9 | ||
|
|
fb083823bd | ||
|
|
925f3f54ac | ||
|
|
5bf4cae3b6 | ||
|
|
b48bb1f899 | ||
|
|
2d3e8140ce | ||
|
|
5763326a0a | ||
|
|
cbaea98521 | ||
|
|
093ae6f4db | ||
|
|
56aa3d8857 | ||
|
|
53b6a68e12 | ||
|
|
7675d2bcbd | ||
|
|
4a0865bb62 | ||
|
|
e144b337de | ||
|
|
33505d7faa | ||
|
|
b581d16a82 | ||
|
|
6769662ecf | ||
|
|
190d7c0dc0 | ||
|
|
88d6579459 | ||
|
|
efec7dc067 | ||
|
|
f82fa0c1af | ||
|
|
996dec3193 | ||
|
|
b41019a19a | ||
|
|
a70ff86667 | ||
|
|
f7c1bfa175 | ||
|
|
f2050832cf | ||
|
|
3d70eef3a3 | ||
|
|
9247a09214 | ||
|
|
59c6ab2057 | ||
|
|
d12cab0ed1 | ||
|
|
fa30358f84 | ||
|
|
d5937ed2b6 | ||
|
|
3faf54fea3 | ||
|
|
a4b87fccbe | ||
|
|
06b27d1461 | ||
|
|
58ddcd7bbb | ||
|
|
3745c835b2 | ||
|
|
5b499d512f | ||
|
|
1ee7233460 | ||
|
|
119e21752b | ||
|
|
0e3f6e996e | ||
|
|
f1d4017883 | ||
|
|
ee46834915 | ||
|
|
3a445ae2bf | ||
|
|
86969460f1 | ||
|
|
577df7a23b | ||
|
|
8dc0ac8011 | ||
|
|
681768e0bb | ||
|
|
1700702e52 | ||
|
|
f6a1224ee2 | ||
|
|
bdab0b1017 | ||
|
|
ae99934c21 | ||
|
|
ad6d94e568 | ||
|
|
0817b0e8cc | ||
|
|
fce9570711 | ||
|
|
3123fe20af | ||
|
|
d51c9a92ed | ||
|
|
e0b4928bc8 | ||
|
|
eeaf84f756 | ||
|
|
955c99dc26 | ||
|
|
6590765dc6 | ||
|
|
0976d925b9 | ||
|
|
1b1bb4698d | ||
|
|
e185c36c59 | ||
|
|
3248b75af8 | ||
|
|
5db0c39dde | ||
|
|
3f0c999440 | ||
|
|
0c8acfa274 | ||
|
|
54f634d5f9 | ||
|
|
cd1bfafe72 | ||
|
|
1ebd6265db | ||
|
|
0ddb89c007 | ||
|
|
a931dd8660 | ||
|
|
5e376b69ed | ||
|
|
45edf565df | ||
|
|
5576c785ce | ||
|
|
6da7f6b010 | ||
|
|
0f11660414 | ||
|
|
bd9e1d8947 | ||
|
|
902b039c4d | ||
|
|
5c1f8f7f6c | ||
|
|
202a52d206 | ||
|
|
b15ffa9542 | ||
|
|
256788294d | ||
|
|
2df4f3e1d0 | ||
|
|
9f514bc49d | ||
|
|
632a1f380e | ||
|
|
63c01bee24 | ||
|
|
cd9d1ac669 | ||
|
|
320cc2dda3 | ||
|
|
0c449919da | ||
|
|
4d931ca77e | ||
|
|
849ededd5b | ||
|
|
10e484f552 | ||
|
|
fa93a7f01f | ||
|
|
760e4e81d0 | ||
|
|
ad90c63923 | ||
|
|
9d11369db7 | ||
|
|
a19bf32e51 | ||
|
|
dcda65f7d9 | ||
|
|
3c1aaae176 | ||
|
|
9f0a8463a9 | ||
|
|
52db75973e | ||
|
|
99182c29be | ||
|
|
2f4bbfa7d2 | ||
|
|
506b99456f | ||
|
|
0732d03fa1 | ||
|
|
8f3574c48b | ||
|
|
41994bc6c7 | ||
|
|
0c4bf38033 | ||
|
|
57ef0d138f | ||
|
|
24178e51d3 | ||
|
|
799b92993a | ||
|
|
52dcb9252c | ||
|
|
d8dcc924b7 | ||
|
|
9a4a1dcf27 | ||
|
|
38f21c01f1 | ||
|
|
1694727548 | ||
|
|
fefb2da2b1 | ||
|
|
dafc10852f | ||
|
|
c83fee02fa | ||
|
|
191a22e759 | ||
|
|
c17c48043e | ||
|
|
31b6649d78 | ||
|
|
5d40d837f6 | ||
|
|
90e3385c15 | ||
|
|
373bf77f3a | ||
|
|
834202d124 | ||
|
|
6918fda018 | ||
|
|
f58f0ec1d0 | ||
|
|
d69b52e2c7 | ||
|
|
e13c480626 | ||
|
|
a5b00eee2d | ||
|
|
0cf969a05d | ||
|
|
04abd59fc6 | ||
|
|
7204df600d | ||
|
|
f9dbd2c8d6 | ||
|
|
ce295b6080 | ||
|
|
fc99aaf87b | ||
|
|
f0b70134a8 | ||
|
|
1153702d1a | ||
|
|
29c09c6f99 | ||
|
|
9ab649ff55 | ||
|
|
933113e375 | ||
|
|
3c896fcdea | ||
|
|
88d15ed051 | ||
|
|
adb42a31ff | ||
|
|
55fd9daa08 | ||
|
|
53b84d2baa | ||
|
|
05401103d2 | ||
|
|
995c101dba | ||
|
|
114a5737f5 | ||
|
|
55a87877b5 | ||
|
|
93b658c8db | ||
|
|
fe1bfdfd29 | ||
|
|
499d64181a | ||
|
|
bf6ba26a7f | ||
|
|
7e3a1037ff | ||
|
|
b09fd0dc69 | ||
|
|
7b12ec165d | ||
|
|
41a0ccaf16 | ||
|
|
6974abaea3 | ||
|
|
f3f660b745 | ||
|
|
d2b6e718d1 | ||
|
|
62cadddf28 | ||
|
|
1882cff76b | ||
|
|
8d4111dff8 | ||
|
|
0e5c9aaed6 | ||
|
|
a45162c5fa | ||
|
|
0811443909 | ||
|
|
54c351b92f | ||
|
|
0f63032916 | ||
|
|
188b03c486 | ||
|
|
df3945af8a | ||
|
|
212fbfe455 | ||
|
|
84da588c36 | ||
|
|
af2695407a | ||
|
|
ff98d9900f | ||
|
|
6cc8c0d448 | ||
|
|
c575f18c99 | ||
|
|
f931ea81d5 | ||
|
|
8c9733b5c6 | ||
|
|
f487613bfc | ||
|
|
d2eae41dd6 | ||
|
|
d92bc4d3ab | ||
|
|
84efbac6f1 | ||
|
|
599df45795 | ||
|
|
0f77ba5e7e | ||
|
|
682afd5aa9 | ||
|
|
529761ff03 | ||
|
|
3220953fb4 | ||
|
|
0cd66905e5 | ||
|
|
bab2978ccf | ||
|
|
a66221d24a | ||
|
|
c92f86ef71 | ||
|
|
0afda58804 | ||
|
|
46645c6d73 | ||
|
|
2bf9b94936 | ||
|
|
702bb42cbb | ||
|
|
86c23326c9 | ||
|
|
b613184d64 | ||
|
|
dfd7a52224 | ||
|
|
918bcddb4f | ||
|
|
5fe92a568a | ||
|
|
2b0719dc70 | ||
|
|
1630d4c894 | ||
|
|
8f29a36f16 | ||
|
|
8cd8cf04ac | ||
|
|
cdbb60e0fe | ||
|
|
9f5c752cd1 | ||
|
|
310635e7d5 | ||
|
|
a1360f42d3 | ||
|
|
3daa34dba0 | ||
|
|
0b92e12d9c | ||
|
|
af36326844 | ||
|
|
a41c8c46e7 | ||
|
|
6c1edac204 | ||
|
|
5676882e64 | ||
|
|
918512f62a | ||
|
|
3a91c09727 | ||
|
|
d0255c71ec | ||
|
|
d3e846eb53 | ||
|
|
c1d666301f | ||
|
|
bd2d361afc | ||
|
|
80a1596a3d | ||
|
|
ae2b8535a9 | ||
|
|
c59441323d | ||
|
|
37572b6c1a | ||
|
|
4a01756ea4 | ||
|
|
106f9824b0 | ||
|
|
697e0bb8a6 | ||
|
|
20807d2d3d | ||
|
|
41021e5e19 | ||
|
|
b3d4cfe311 | ||
|
|
d765bbd68e | ||
|
|
63ae22b42b | ||
|
|
41dbfd987b | ||
|
|
06c61d9437 | ||
|
|
b3ce351cde | ||
|
|
8336da3482 | ||
|
|
a392f4e18e | ||
|
|
acaa281c54 | ||
|
|
37c160eec0 | ||
|
|
ad68bfefd1 | ||
|
|
98a1fc1b94 | ||
|
|
a2a2638461 | ||
|
|
9e7bc6691c | ||
|
|
9bda02122d | ||
|
|
8ff280ed3d | ||
|
|
63ee800cf2 | ||
|
|
1a2958294d | ||
|
|
356eb8f093 | ||
|
|
bda9453953 | ||
|
|
1852295d9a | ||
|
|
68f856fb9d | ||
|
|
256e581aa7 | ||
|
|
b8cda55e57 | ||
|
|
194f13d30f | ||
|
|
e3b4ecb808 | ||
|
|
6272d465df | ||
|
|
7439d56c5c | ||
|
|
ce3d50b8f9 | ||
|
|
3584d15ddd | ||
|
|
a51434ff7d | ||
|
|
2157b35e24 | ||
|
|
e13178ac40 | ||
|
|
88d8390222 | ||
|
|
5d508ec1e1 | ||
|
|
ad2c9829fd | ||
|
|
8a4fd13423 | ||
|
|
6437496faf | ||
|
|
2ec6ac7c9c | ||
|
|
6752f1b5f7 | ||
|
|
de4fb8d6a3 | ||
|
|
1fe19db437 | ||
|
|
52365781a6 | ||
|
|
9af0f02a74 | ||
|
|
d899e8b846 | ||
|
|
3f0c7d5bda | ||
|
|
4f64f8c4a6 | ||
|
|
eb684d2256 | ||
|
|
3ec310db40 | ||
|
|
53dc251508 | ||
|
|
34f77c059b | ||
|
|
7bebbe4033 | ||
|
|
3a31c38751 | ||
|
|
7ed93eadae | ||
|
|
ee9dfd1a37 | ||
|
|
4c2f220971 | ||
|
|
2dbe4c265b | ||
|
|
5c6c581b35 | ||
|
|
c5825bcd81 | ||
|
|
c32827ccaf | ||
|
|
62f08a8b2e | ||
|
|
c408bace90 | ||
|
|
2f2bac4645 | ||
|
|
7cc0450ae4 | ||
|
|
f21d644e70 | ||
|
|
c1463d0e76 | ||
|
|
80d5be2814 | ||
|
|
a96980bcc2 | ||
|
|
a7f8f99084 | ||
|
|
2f5f267eda | ||
|
|
4263117b48 | ||
|
|
6c4135ddfb | ||
|
|
8a0ca48bb7 | ||
|
|
8ad818dc70 | ||
|
|
2742c2342f | ||
|
|
bc9faf230a | ||
|
|
d658d182e4 | ||
|
|
6b9c48fe4d | ||
|
|
070d9fea4e | ||
|
|
f459f3c400 | ||
|
|
ebbf129719 | ||
|
|
c53a5e4dd8 | ||
|
|
a9247247af | ||
|
|
7edf74bb15 | ||
|
|
be121813f0 | ||
|
|
6c57533958 | ||
|
|
88c3962423 | ||
|
|
3f4d63ca8a | ||
|
|
212f27505a | ||
|
|
8ccb6cd0a0 | ||
|
|
4d6ce95563 | ||
|
|
ea66d19c5e | ||
|
|
29b9421518 | ||
|
|
dda1166326 | ||
|
|
2a205c294f | ||
|
|
1333a2c130 | ||
|
|
94b501b657 | ||
|
|
95aa27ae60 | ||
|
|
da1e9070f2 | ||
|
|
893e97c18e | ||
|
|
8e065f9a78 | ||
|
|
b09676e34a | ||
|
|
679b5bda19 | ||
|
|
1b33016019 | ||
|
|
9b5ed1da6e | ||
|
|
160ca30590 | ||
|
|
2f98090707 | ||
|
|
4601565dbd | ||
|
|
e64291dc6d | ||
|
|
c88df6f9c7 | ||
|
|
11acaa3f2b | ||
|
|
f593c2eab4 | ||
|
|
10826925c9 | ||
|
|
7c54cc6a10 | ||
|
|
56d0b8fc63 | ||
|
|
0fa8d99934 | ||
|
|
42dc3991c1 | ||
|
|
44fef497f2 | ||
|
|
f364b38b74 | ||
|
|
38c92f4011 | ||
|
|
9f5436cd6d | ||
|
|
d5777232ad | ||
|
|
94d803f595 | ||
|
|
40fbf7c155 | ||
|
|
c6fb5737c1 | ||
|
|
e3fe95d228 | ||
|
|
1a4a91256d | ||
|
|
80e4084420 | ||
|
|
58e55b5898 | ||
|
|
a3aa6c0074 | ||
|
|
4d5c66375d | ||
|
|
a634154a22 | ||
|
|
8d48d90d72 | ||
|
|
aac074ab06 | ||
|
|
fdc6b9d892 | ||
|
|
44471d1c94 | ||
|
|
de238f3dde | ||
|
|
e838224264 | ||
|
|
3aa9179424 | ||
|
|
0fedb30182 | ||
|
|
f63195656a | ||
|
|
8bd4563087 | ||
|
|
f9b2987716 | ||
|
|
0347de1f22 | ||
|
|
9329d1f752 | ||
|
|
6c6123fb29 | ||
|
|
d9c9d6e616 | ||
|
|
a9bc9c57e7 | ||
|
|
d4999a2b2f | ||
|
|
8a0d833080 | ||
|
|
2b891f17a5 | ||
|
|
5ca15b3793 | ||
|
|
3ea51f9944 | ||
|
|
7edb12df2d | ||
|
|
edf112cd92 | ||
|
|
f2a10ff3ed | ||
|
|
fbb27a989c | ||
|
|
64d20004c7 | ||
|
|
6c592bdb33 | ||
|
|
482ffb5306 | ||
|
|
25eeb74fe9 | ||
|
|
5e65197df6 | ||
|
|
772d420dc4 | ||
|
|
d13b63054b | ||
|
|
7af6741bf2 | ||
|
|
dd4e7f62b2 | ||
|
|
099e832028 | ||
|
|
3628dc1f04 | ||
|
|
c829374f48 | ||
|
|
e5996eeaff | ||
|
|
b94a3e5d16 | ||
|
|
f49b611321 | ||
|
|
40b99348e8 | ||
|
|
9f89ecab7e | ||
|
|
e648610eae | ||
|
|
6aa0dda7ee | ||
|
|
b4106dcf63 | ||
|
|
a2370042f4 | ||
|
|
dfeb93cdc7 | ||
|
|
3b3ac393ba | ||
|
|
96735b20d9 | ||
|
|
fdd6f127c2 | ||
|
|
4dbe8de82d | ||
|
|
d1e5637929 | ||
|
|
b096147894 | ||
|
|
95c4070090 | ||
|
|
67b70ea814 | ||
|
|
7d1bae51fc | ||
|
|
aa89efd1e2 | ||
|
|
ea1e4ef249 | ||
|
|
f9982ef182 | ||
|
|
adf1eb245e | ||
|
|
bd2efe1c9e | ||
|
|
d23f949801 | ||
|
|
f9147709a6 | ||
|
|
82cd04c9a6 | ||
|
|
dc98f6483a | ||
|
|
0efb22a1dd | ||
|
|
972db68d6b | ||
|
|
49c61475de | ||
|
|
46be542125 | ||
|
|
9ee6a8f88b | ||
|
|
4e3d5c10f1 | ||
|
|
691bf44151 | ||
|
|
e0ee51f442 | ||
|
|
9dfcef628b | ||
|
|
5cc6640ae8 | ||
|
|
73bdae55c6 | ||
|
|
853f99919d | ||
|
|
487f4af04c | ||
|
|
18b174f9ab | ||
|
|
85963cfa5f | ||
|
|
8c720987cb | ||
|
|
84886e33b9 | ||
|
|
2e9aacfd9e | ||
|
|
098d1d365e | ||
|
|
a423a6b203 | ||
|
|
af838bc8ea | ||
|
|
183d769841 | ||
|
|
2a710313ff | ||
|
|
507a1eb419 | ||
|
|
1f873774ab | ||
|
|
eb5eef341f | ||
|
|
3b4da4f39b | ||
|
|
042d16718e | ||
|
|
80e29bf57c | ||
|
|
da49251bf3 | ||
|
|
25db401c9f | ||
|
|
c88d7a3820 | ||
|
|
2d7816a227 | ||
|
|
1e0519ad53 | ||
|
|
9a39b0ddba | ||
|
|
1e1f3cb711 | ||
|
|
dbc822ba8b | ||
|
|
98f012e268 | ||
|
|
fb357977b5 | ||
|
|
afa5fc3b1a | ||
|
|
1c82574f86 | ||
|
|
a182724136 | ||
|
|
a7d5ee01cd | ||
|
|
4eddcc43d4 | ||
|
|
0254343de3 | ||
|
|
34bec9c119 | ||
|
|
f3fea3b8b8 | ||
|
|
0827eb8eda | ||
|
|
27627bc793 | ||
|
|
1c48187ca1 | ||
|
|
28d1918c26 | ||
|
|
24d54e4db5 | ||
|
|
346989eda1 | ||
|
|
57d654f972 | ||
|
|
dbefd920b5 | ||
|
|
60bfb02db9 | ||
|
|
dc3283da19 | ||
|
|
bc779f2216 | ||
|
|
ed4e1ce391 | ||
|
|
46b77abeb2 | ||
|
|
aa4bd2cc11 | ||
|
|
db1e08fa66 | ||
|
|
50f89666fc | ||
|
|
72a14b078c | ||
|
|
d01ec72338 | ||
|
|
3f5aab992c | ||
|
|
522d8795b0 | ||
|
|
4dc6c80cac | ||
|
|
67fadbc64b | ||
|
|
fe0fad5743 | ||
|
|
b9b527af9d | ||
|
|
94b9627f75 | ||
|
|
724f1f7f90 | ||
|
|
8012f017bc | ||
|
|
5131af5ab7 | ||
|
|
25c730223f | ||
|
|
5ed678ae54 | ||
|
|
86a8ffe96a | ||
|
|
4f680fdfcb | ||
|
|
d9f65684f8 | ||
|
|
27bb095b45 | ||
|
|
dec7c712c7 | ||
|
|
22d18a7bc9 | ||
|
|
36688eface | ||
|
|
428bab3201 | ||
|
|
3c48cefad4 | ||
|
|
60d0598a69 | ||
|
|
da06957d53 | ||
|
|
230631c466 | ||
|
|
8325f12c33 | ||
|
|
f86d227dc5 | ||
|
|
3df5aa3f99 | ||
|
|
fb0c332006 | ||
|
|
f89687fd87 | ||
|
|
b6b4e54251 | ||
|
|
b16b705f5d | ||
|
|
cae5062e3a | ||
|
|
fc68bb6a8f | ||
|
|
4d8c29adbe | ||
|
|
40f6c9d253 | ||
|
|
6433934db7 | ||
|
|
1bb166dbaa | ||
|
|
dfe014a2ba | ||
|
|
b42f1dc56f | ||
|
|
02cd44e3aa | ||
|
|
dda9a56cb7 | ||
|
|
518a24dd64 | ||
|
|
43d7cc755e | ||
|
|
1a370b965c | ||
|
|
5b149495c5 | ||
|
|
340d36c860 | ||
|
|
870880963d | ||
|
|
1308aae1b7 | ||
|
|
2945c2d8d0 | ||
|
|
4b14fe447b | ||
|
|
7f3be81d6c | ||
|
|
d42b7621de | ||
|
|
196ed7f450 | ||
|
|
9142b47bdf | ||
|
|
cff3a1c9db | ||
|
|
5ba266db25 | ||
|
|
c114a18c87 | ||
|
|
3f76dccc32 | ||
|
|
48cea71beb | ||
|
|
6a678f02a0 | ||
|
|
f840c58934 | ||
|
|
07a741b595 | ||
|
|
620b549486 | ||
|
|
d1cd34b375 | ||
|
|
61ab76b6f5 | ||
|
|
669a65ade5 | ||
|
|
ecfec194b4 | ||
|
|
bba3475deb | ||
|
|
32aa4629de | ||
|
|
872b145ea8 | ||
|
|
8298d3c195 | ||
|
|
af83516f0b | ||
|
|
4e3a7720cf | ||
|
|
3be2a04383 | ||
|
|
b35d946929 | ||
|
|
263eda0106 | ||
|
|
3b248ebcca | ||
|
|
2d51078ce1 | ||
|
|
52e6546c69 | ||
|
|
add77db7a0 | ||
|
|
4faeb001ba | ||
|
|
c4527242c9 | ||
|
|
eacbb46994 | ||
|
|
048f0a7b71 | ||
|
|
6a36102939 | ||
|
|
6c6ef51066 | ||
|
|
3f7c984b49 | ||
|
|
40ec259ccd | ||
|
|
c6e3db8609 | ||
|
|
4198ba9915 | ||
|
|
bd454d403d | ||
|
|
495d1a9f2b | ||
|
|
40ed55b37f | ||
|
|
56334b72ba | ||
|
|
f0325776c1 | ||
|
|
6a9bbd93de | ||
|
|
48b1274616 | ||
|
|
f4f3011630 | ||
|
|
ecda0d4680 | ||
|
|
9043a74e2d | ||
|
|
e76cf87d44 | ||
|
|
546aa598a0 | ||
|
|
c3432699aa | ||
|
|
82b40c3218 | ||
|
|
c37c4d7b3f | ||
|
|
7d8d58f39a | ||
|
|
6f74038eea | ||
|
|
3f06dd868b | ||
|
|
d7d8c03193 | ||
|
|
d9dc457d40 | ||
|
|
989b67ee95 | ||
|
|
d624ac9a4b | ||
|
|
d605e8ca80 | ||
|
|
fc0c3ca23a | ||
|
|
09cf3eb81d | ||
|
|
51a05126fd | ||
|
|
2ac57b13a8 | ||
|
|
67c304b387 | ||
|
|
fb66e3f37f | ||
|
|
a378ba34cd | ||
|
|
71329a839f | ||
|
|
5729f343e7 | ||
|
|
0b2ff221c1 | ||
|
|
02dc131bc9 | ||
|
|
69b0c527fa | ||
|
|
fd2f25a2cb | ||
|
|
c16bf24b04 | ||
|
|
898480070f | ||
|
|
30b3226101 | ||
|
|
e94dff42e1 | ||
|
|
7c6425e74e | ||
|
|
07813780b9 | ||
|
|
f3c5a5751e | ||
|
|
2f65a6b066 | ||
|
|
f03ffd7fed | ||
|
|
343ce793eb | ||
|
|
233afff41c | ||
|
|
7683e1c7f6 | ||
|
|
247e44194b | ||
|
|
21008ce758 | ||
|
|
b68164528e | ||
|
|
19128a10f9 | ||
|
|
d8882f776e | ||
|
|
e82a373b50 | ||
|
|
964e4b5da5 | ||
|
|
c2534c5dc8 | ||
|
|
2d56eee224 | ||
|
|
d42a753176 | ||
|
|
288e5e31e3 | ||
|
|
b3b5939ef9 | ||
|
|
a625a183f0 | ||
|
|
4bec688648 | ||
|
|
326030418d | ||
|
|
1b6b20c29e | ||
|
|
6f2bc13984 | ||
|
|
3d00ed98b0 | ||
|
|
d75fb91d1d | ||
|
|
a2ab0d5f60 | ||
|
|
45a3833f0b | ||
|
|
c87a6e5219 | ||
|
|
85b3be3526 | ||
|
|
87fe3c02f6 | ||
|
|
a70938f228 | ||
|
|
3fe11518dd | ||
|
|
fb0917c35b | ||
|
|
35445613b3 | ||
|
|
0c8aa72378 | ||
|
|
95d69d91a2 | ||
|
|
cc093f53dd | ||
|
|
4ced93d549 | ||
|
|
92b1aad608 | ||
|
|
d5393f2a12 | ||
|
|
5158944ad3 | ||
|
|
b37fdc2d3a | ||
|
|
8e0c08dff2 | ||
|
|
3fdf46e530 | ||
|
|
873948b838 | ||
|
|
ec54145304 | ||
|
|
399da28fda | ||
|
|
1b39c1d57d | ||
|
|
7b059d64f1 | ||
|
|
0e7ccf6f74 | ||
|
|
24e9125a7e | ||
|
|
296d1ff6c1 | ||
|
|
ccfa3e3be9 | ||
|
|
e530b79b5a | ||
|
|
0f3c8f0841 | ||
|
|
0d7aac283c | ||
|
|
87ac2ef5b0 | ||
|
|
82f3a0154b | ||
|
|
39ef24a169 | ||
|
|
1525f3a142 | ||
|
|
4dfec51b8b | ||
|
|
f4b857f6ec | ||
|
|
7374cbdab0 | ||
|
|
9ae5600999 | ||
|
|
0a4976e62c | ||
|
|
77cd72ca05 | ||
|
|
0024474b95 | ||
|
|
0ee4d1f812 | ||
|
|
9f57c9194b | ||
|
|
cebe908d3c | ||
|
|
768e74a5e7 | ||
|
|
9e18c4a8aa | ||
|
|
477481fec3 | ||
|
|
b26bb7f452 | ||
|
|
514c499896 | ||
|
|
512ac3be49 | ||
|
|
3dd22cfd60 | ||
|
|
cb1577367c | ||
|
|
e15b3fc922 | ||
|
|
33def0e800 | ||
|
|
ba16e4f08d | ||
|
|
cd623fd6ca | ||
|
|
9059a89078 | ||
|
|
3ea03971d3 | ||
|
|
d1c805a595 | ||
|
|
74334d2d85 | ||
|
|
536ae3ea14 | ||
|
|
fe1012d75f | ||
|
|
0f0fca177a | ||
|
|
f6226f7252 | ||
|
|
76fd3a0f67 | ||
|
|
d027f2c286 | ||
|
|
a0d084bbc3 | ||
|
|
3b3a773dc2 | ||
|
|
a9ae58ba76 | ||
|
|
615158d7c2 | ||
|
|
ecc822d588 | ||
|
|
43fa826342 | ||
|
|
c915881537 | ||
|
|
c05a02b60a | ||
|
|
77e10b05f8 | ||
|
|
087d134036 | ||
|
|
39834a75d0 | ||
|
|
692a4f69cc | ||
|
|
7fb840ec1d | ||
|
|
0c815bbd73 | ||
|
|
062e99e829 | ||
|
|
8fcb236ecf | ||
|
|
d7e2dcd44d | ||
|
|
d3b844554c | ||
|
|
5933694096 | ||
|
|
f5090fc3c2 | ||
|
|
914eabb226 | ||
|
|
24951fa2f4 | ||
|
|
82b38382b7 | ||
|
|
5227face30 | ||
|
|
386fedf257 | ||
|
|
0b559b5ad0 | ||
|
|
cfc1915f56 | ||
|
|
cf49003c27 | ||
|
|
efc9c85e9b | ||
|
|
f960330ecb | ||
|
|
ccaeeb7eb6 | ||
|
|
1d029046f8 | ||
|
|
378e926584 | ||
|
|
2e588363e0 | ||
|
|
e36572e582 | ||
|
|
5afb7e8102 | ||
|
|
721d808eed | ||
|
|
c247cff20a | ||
|
|
ac752e7026 | ||
|
|
07fcc835cd | ||
|
|
a24f8ae999 | ||
|
|
9f0e653c5a | ||
|
|
7867844fbb | ||
|
|
94c12a6e7f | ||
|
|
8a93e66d2c | ||
|
|
5b4fc8c27d | ||
|
|
1268199bc4 | ||
|
|
41e17802f1 | ||
|
|
e149dfa1ae | ||
|
|
b7b4722e4f | ||
|
|
74ab9c2ba2 | ||
|
|
7c6cd34dbe | ||
|
|
d05cf2beb8 | ||
|
|
bf5d488bfe | ||
|
|
2f31b65b3c | ||
|
|
039212362b | ||
|
|
1ad183a086 | ||
|
|
7ff87c4321 | ||
|
|
ee9177d1d5 | ||
|
|
d7475392dd | ||
|
|
0b9c174d1a | ||
|
|
9b66a2bbfa | ||
|
|
c5935b9cb5 | ||
|
|
e009b9aaa0 | ||
|
|
1d0c65856b | ||
|
|
abdfb0a7fb | ||
|
|
b3d15a64cc | ||
|
|
db55515f7a | ||
|
|
533442071f | ||
|
|
a6ca37cbbf | ||
|
|
62ff356566 | ||
|
|
da55339548 | ||
|
|
dac4f63f1e | ||
|
|
aa8cc414bb | ||
|
|
a4c977dd8a | ||
|
|
a5995d757b | ||
|
|
2627912062 | ||
|
|
bda91bf1e3 | ||
|
|
c2a2733915 | ||
|
|
780139c880 | ||
|
|
c4c7365c7f | ||
|
|
25dc45d086 | ||
|
|
5b199f5cdf | ||
|
|
d0da7cc332 | ||
|
|
d3c8eee07e | ||
|
|
c09e00884c | ||
|
|
706183b79e | ||
|
|
415fbdef9d | ||
|
|
cf0a4911d0 | ||
|
|
8968c6b19d | ||
|
|
92a3a28355 | ||
|
|
776ae83c06 | ||
|
|
ec09d65da7 | ||
|
|
3d0c201496 | ||
|
|
d31fe11a44 | ||
|
|
5c1dfef8d6 | ||
|
|
5c1c2a9936 | ||
|
|
2f352bde2b | ||
|
|
5f6627a71e | ||
|
|
34f7327b4b | ||
|
|
9f709d76f0 | ||
|
|
13c8a3bbd4 | ||
|
|
e56b2a7654 | ||
|
|
f8038a640f | ||
|
|
37176addee | ||
|
|
c5534b54a7 | ||
|
|
e3c3cb8f5a | ||
|
|
48445f5b9e | ||
|
|
2fb19eb06a | ||
|
|
9c8361377a | ||
|
|
506b7686e9 | ||
|
|
8bafdfa3c7 | ||
|
|
75a2fe5985 | ||
|
|
f7f51fbcd3 | ||
|
|
4514a35d1d | ||
|
|
8dd2b78935 | ||
|
|
446f7876cd | ||
|
|
4f26727ecf | ||
|
|
d61003c395 | ||
|
|
f9fcf37b67 | ||
|
|
715907ea21 | ||
|
|
2b346002db | ||
|
|
4d9cd43168 | ||
|
|
dba75ffb25 | ||
|
|
66a8f2046b | ||
|
|
caff5b7013 | ||
|
|
80731ca347 | ||
|
|
6876a86f42 | ||
|
|
40dfde5b4c | ||
|
|
954dd35a91 | ||
|
|
da910f5eaf | ||
|
|
d2af313653 | ||
|
|
d282dec072 | ||
|
|
4e1fcf6eac | ||
|
|
c3f9dedef6 | ||
|
|
8a7e3951ca | ||
|
|
d057d8693b | ||
|
|
ca550a95b6 | ||
|
|
bbd30299d8 | ||
|
|
9ba62160c0 | ||
|
|
f81cbcd60d | ||
|
|
7efefc7347 | ||
|
|
cb55ecce7f | ||
|
|
7e1100d73f | ||
|
|
137c64f5b7 | ||
|
|
8671d833d7 | ||
|
|
89fe108b41 | ||
|
|
df54872bc7 | ||
|
|
02ee221e2d | ||
|
|
d04d3a4516 | ||
|
|
d609c47344 | ||
|
|
8bff5da5a2 | ||
|
|
c7c179b818 | ||
|
|
8123c2ca46 | ||
|
|
e4ca242154 | ||
|
|
b835bef402 | ||
|
|
c6ab37993a | ||
|
|
4180591c5a | ||
|
|
bb9556b9d5 | ||
|
|
100983eb98 | ||
|
|
1cc5708f4d | ||
|
|
c70e754d4c | ||
|
|
6307a5aaf1 | ||
|
|
eb4eebaa98 | ||
|
|
3392e3da66 | ||
|
|
52132465ae | ||
|
|
c979296d6c | ||
|
|
f886fff9fd | ||
|
|
e05924fe7f | ||
|
|
ad04d48572 | ||
|
|
7b10a16ca4 | ||
|
|
737d66eeb3 | ||
|
|
7ec481ceaa | ||
|
|
684b930fa6 | ||
|
|
8f9faa7b58 | ||
|
|
28592bc7a9 | ||
|
|
36f82a31d2 | ||
|
|
7db4dcf130 | ||
|
|
d58c7db803 | ||
|
|
aa84837945 | ||
|
|
05f35278c5 | ||
|
|
6ab84e8d7b | ||
|
|
53cbe9700d | ||
|
|
ccb935478c | ||
|
|
ba935fcb3c | ||
|
|
59c7d15a60 | ||
|
|
2f55165c11 | ||
|
|
82d284f547 | ||
|
|
7c7a130949 | ||
|
|
fa7553fca1 | ||
|
|
016ce8ba1b | ||
|
|
fe5de38a61 | ||
|
|
11cc12043b | ||
|
|
d0f94dabb6 | ||
|
|
5c42568468 | ||
|
|
bbb76244c2 | ||
|
|
59715e8a3c | ||
|
|
c220447682 | ||
|
|
b67870cdbc | ||
|
|
0396ef8894 | ||
|
|
4890d04457 | ||
|
|
29cea0b017 | ||
|
|
1175b1c1df | ||
|
|
e9860b34e1 | ||
|
|
3d23aaddcd | ||
|
|
4cda10ebc6 | ||
|
|
68d567c063 | ||
|
|
762b9a64de | ||
|
|
8b6885433e | ||
|
|
f031805b5c | ||
|
|
1020dfd188 | ||
|
|
ac3e312fa0 | ||
|
|
763e0cf2e0 | ||
|
|
aba174c9f3 | ||
|
|
8db30e46f4 | ||
|
|
4169b55bf3 | ||
|
|
9da3b7479f | ||
|
|
072f4960f0 | ||
|
|
4603205230 | ||
|
|
f7f92c7107 | ||
|
|
b9a7f0341a | ||
|
|
4579e78071 | ||
|
|
98f4febbf8 | ||
|
|
d1ea14cea6 | ||
|
|
70e5a2bf16 | ||
|
|
13b8f22fd0 | ||
|
|
ce58a153c8 | ||
|
|
3fc78031f6 | ||
|
|
d11d185f5c | ||
|
|
3bd0e699bf | ||
|
|
697b538c95 | ||
|
|
999b541764 | ||
|
|
374224622d | ||
|
|
404ab49c50 | ||
|
|
40b6d84525 | ||
|
|
357b2a03d9 | ||
|
|
f8876ae2ff | ||
|
|
e44fbd358a | ||
|
|
064e90964d | ||
|
|
fc8a02113f | ||
|
|
840aef623e | ||
|
|
c11f0312ea | ||
|
|
a48373d9c0 | ||
|
|
783cdef629 | ||
|
|
c1284a0302 | ||
|
|
35fb4f1324 | ||
|
|
b0e8476766 | ||
|
|
37e50b56fd | ||
|
|
6424ca6bcb | ||
|
|
3454df1c1b | ||
|
|
b0f47ebc1d | ||
|
|
aca9b189b9 | ||
|
|
89b0ea157c | ||
|
|
7bac547878 | ||
|
|
56d18bdddc | ||
|
|
ea0ff45c2c | ||
|
|
23074f4773 | ||
|
|
dcb1d173aa | ||
|
|
c9a674261b | ||
|
|
65cd935b00 | ||
|
|
d6fe24d465 | ||
|
|
d1e6d6fd5c | ||
|
|
8800c7765d | ||
|
|
8c8bd23364 | ||
|
|
f4df71c263 | ||
|
|
bcad21f9b6 | ||
|
|
d7e50cda01 | ||
|
|
dd86cab539 | ||
|
|
20a1c7a8db | ||
|
|
6271b56cf0 | ||
|
|
2fd8f68989 | ||
|
|
5de6a4071a | ||
|
|
6137e60fe5 | ||
|
|
79f0e040c7 | ||
|
|
9131e162fc | ||
|
|
7ab15826d8 | ||
|
|
a1f84052f3 | ||
|
|
ec267acdbc | ||
|
|
1abdc9222b | ||
|
|
604ef9a4b5 | ||
|
|
302cf288a8 | ||
|
|
9648611b47 | ||
|
|
39dfe59d36 | ||
|
|
93ca2d1fc0 | ||
|
|
bea96e54c3 | ||
|
|
25d5fd974c | ||
|
|
ab101d53f8 | ||
|
|
b4fbcc5f6c | ||
|
|
9f3f2be215 | ||
|
|
e62c16dc09 | ||
|
|
85cfc26799 | ||
|
|
ef16421e42 | ||
|
|
ade15ea42d | ||
|
|
c7c731ac3b | ||
|
|
429116f985 | ||
|
|
1bee3bcac7 | ||
|
|
0c3c9d7beb | ||
|
|
0a6709fac9 | ||
|
|
7ac975c37a | ||
|
|
2beccada02 | ||
|
|
30d44a5cd9 | ||
|
|
763aeaaaaa | ||
|
|
6a1ad2657f | ||
|
|
0ae8240e03 | ||
|
|
ef77996df1 | ||
|
|
0380ffccfd | ||
|
|
a58b24f2c4 | ||
|
|
3c7223a7c8 | ||
|
|
7be94a1184 | ||
|
|
4d0604e519 | ||
|
|
0bff510085 | ||
|
|
219402cf4f | ||
|
|
2afb5b6d0d | ||
|
|
9135888f00 | ||
|
|
82229f3b7e | ||
|
|
78ea57db75 | ||
|
|
90176902f3 | ||
|
|
481c494df0 | ||
|
|
75e44b65cb | ||
|
|
1cfd0959e3 | ||
|
|
23a64770f7 | ||
|
|
d7c54142ed | ||
|
|
cf6cb771e4 | ||
|
|
e803d4ba14 | ||
|
|
45a7f74c8e | ||
|
|
a33a23bb10 | ||
|
|
21238959c7 | ||
|
|
eb4ea7f9c7 | ||
|
|
a47f19b50d | ||
|
|
c410581c26 | ||
|
|
5807183432 | ||
|
|
39a7baec89 | ||
|
|
4baf766e9f | ||
|
|
092e53b46d | ||
|
|
44fae2aac9 | ||
|
|
cbfc2576a3 | ||
|
|
3527d059bd | ||
|
|
b1943ff11f | ||
|
|
564646cfac | ||
|
|
8a463dab3a | ||
|
|
c95756df7b | ||
|
|
fdb31d2966 | ||
|
|
dd0e1f61bc | ||
|
|
a63e88e7c1 | ||
|
|
33960b0684 | ||
|
|
76ac97faa9 | ||
|
|
42b9da7f9b | ||
|
|
a8933cec25 | ||
|
|
4a6e625326 | ||
|
|
3195750127 | ||
|
|
d328bbf369 | ||
|
|
47c59aa790 | ||
|
|
cf8df4fa6c | ||
|
|
fdaac929fd | ||
|
|
b4fee56db3 | ||
|
|
a88ffc3932 | ||
|
|
663bb3e6f8 | ||
|
|
cadfc58396 | ||
|
|
52141b2129 | ||
|
|
1ed3a24af2 | ||
|
|
d2d2f7b7da | ||
|
|
b93c6bc96e | ||
|
|
e88301b65d | ||
|
|
c5653f6668 | ||
|
|
92f702da1b | ||
|
|
3b6faa2d74 | ||
|
|
0c6c9e3176 | ||
|
|
9823c2ebdc | ||
|
|
e6dea03f48 | ||
|
|
99e9730a01 | ||
|
|
fcf21f5efc | ||
|
|
0b58c67de8 | ||
|
|
4b4d670206 | ||
|
|
4a3fc82d85 | ||
|
|
0b8fd1e321 | ||
|
|
404d5870dd | ||
|
|
efb5547368 | ||
|
|
eac5f9eccf | ||
|
|
26afe95616 | ||
|
|
718b7f6fe4 | ||
|
|
4f05c24c7e | ||
|
|
db60f99a7a | ||
|
|
f3db19df76 | ||
|
|
80da0c8c21 | ||
|
|
179dbb35b6 | ||
|
|
b3e1b7f46d | ||
|
|
90f6eae720 | ||
|
|
dd3064db0c | ||
|
|
b1f06033ba | ||
|
|
ee8a77e663 | ||
|
|
b3306b2206 | ||
|
|
3d293b56ae | ||
|
|
41a5575411 | ||
|
|
06fc43366b | ||
|
|
f60cb87e0e | ||
|
|
83997c7a7d | ||
|
|
1776a515f2 | ||
|
|
6363d25a1b | ||
|
|
8ace2a3184 | ||
|
|
3d18cca043 | ||
|
|
4d5d6112b7 | ||
|
|
0cfc3f5f28 | ||
|
|
cbda01aa6d | ||
|
|
a234034ca1 | ||
|
|
852c765e54 | ||
|
|
dfbe574295 | ||
|
|
bd13ab4a6d | ||
|
|
2f62e5f0a5 | ||
|
|
9ca366420c | ||
|
|
1f2e2a7695 | ||
|
|
19651defd9 | ||
|
|
cb12be7151 | ||
|
|
7e3b6b651b | ||
|
|
1d576f6d42 | ||
|
|
e28f5b5012 | ||
|
|
e510f0f33c | ||
|
|
9095e9a986 | ||
|
|
e77b7bb12f | ||
|
|
a0535781a7 | ||
|
|
0c82743a77 | ||
|
|
0aefea55bf | ||
|
|
8e8daecba2 | ||
|
|
adae0b76b1 | ||
|
|
3afdf4a0f8 | ||
|
|
4f874fc24b | ||
|
|
ecc4ba3fb8 | ||
|
|
4b36c51940 | ||
|
|
3570091474 | ||
|
|
6f5269acff | ||
|
|
0a286c0530 | ||
|
|
b482979c14 | ||
|
|
899d52d795 | ||
|
|
7e152a48bd | ||
|
|
41621ca0bd | ||
|
|
31b08b75b8 | ||
|
|
28061c08e3 | ||
|
|
1ad0b44a68 | ||
|
|
b7a58c25c1 | ||
|
|
f3196f1100 | ||
|
|
541440391e | ||
|
|
a3f53d66f5 | ||
|
|
793136b7e1 | ||
|
|
7e3d5e04b9 | ||
|
|
8c623260fc | ||
|
|
229405b1cc | ||
|
|
588543cba8 | ||
|
|
8cb5159fa0 | ||
|
|
b6b5ecdc4b | ||
|
|
57f84d05d2 | ||
|
|
c0f6471afa | ||
|
|
c3f1981823 | ||
|
|
d4f7672f45 | ||
|
|
af2bd808be | ||
|
|
8aa6e9810f | ||
|
|
4015329654 | ||
|
|
cf999248f9 | ||
|
|
56383fc004 | ||
|
|
9b464baf76 | ||
|
|
3521e54b81 | ||
|
|
6acdf815ea | ||
|
|
ab38a17bd4 | ||
|
|
dde72eed75 | ||
|
|
8ace5381ec | ||
|
|
18c386b071 | ||
|
|
aa91e71893 | ||
|
|
418f85e9eb | ||
|
|
2550501caa | ||
|
|
37efe11502 | ||
|
|
5cfae1ce62 | ||
|
|
bbc8e83e5d | ||
|
|
a51e6a0455 | ||
|
|
79d936fa5e | ||
|
|
04c82c0586 | ||
|
|
31f24f0f45 | ||
|
|
ea73209a1d | ||
|
|
52127777e1 | ||
|
|
362311942d | ||
|
|
7383fd7e89 | ||
|
|
7718f45b00 | ||
|
|
2661f4de38 | ||
|
|
53ecf6b6be | ||
|
|
68d5deba65 |
|
|
@ -17,7 +17,7 @@ clear, when to stay silent, what never to say — lives once in
|
||||||
| `backend/` | Backend | `cli`, `@n8n/db`, `core`, `workflow`, node packages |
|
| `backend/` | Backend | `cli`, `@n8n/db`, `core`, `workflow`, node packages |
|
||||||
| `db-migrations/` | DB migrations | `@n8n/db` migrations + their tests in `cli` |
|
| `db-migrations/` | DB migrations | `@n8n/db` migrations + their tests in `cli` |
|
||||||
| `frontend/` | Frontend | `packages/frontend` |
|
| `frontend/` | Frontend | `packages/frontend` |
|
||||||
| `qa-dx/` | QA & DX | `.github`, `docker`, `scripts`, `patches`, `packages/testing`, the lint/test/TS config packages, baselines |
|
| `qa-dx/` | QA & DX | `.github`, `docker`, `scripts`, `patches`, `packages/quality`, the lint/test/TS config packages, baselines |
|
||||||
| `testing/` | Backend + Frontend | any package with a test suite |
|
| `testing/` | Backend + Frontend | any package with a test suite |
|
||||||
|
|
||||||
A directory maps to one agent unless, like `testing/`, the policy is identical
|
A directory maps to one agent unless, like `testing/`, the policy is identical
|
||||||
|
|
@ -27,7 +27,7 @@ never a copy per directory. Security and QA & DX deliberately don't link
|
||||||
agents shouldn't be able to produce.
|
agents shouldn't be able to produce.
|
||||||
|
|
||||||
All five slots are used, so a new domain now merges into an existing agent. QA &
|
All five slots are used, so a new domain now merges into an existing agent. QA &
|
||||||
DX covers the build, test, and CI surface — the same paths `.github/OWNERS`
|
DX covers the build, test, and CI surface — the same paths `OWNERS`
|
||||||
assigns to `@n8n-io/qa-dx`. Code-quality rules that happen to apply broadly
|
assigns to `@n8n-io/qa-dx`. Code-quality rules that happen to apply broadly
|
||||||
(error classes, `any`, lazy imports) are backend rules, not QA & DX ones. DB
|
(error classes, `any`, lazy imports) are backend rules, not QA & DX ones. DB
|
||||||
migrations is split out of Backend because a migration is permanent and runs
|
migrations is split out of Backend because a migration is permanent and runs
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,10 @@ Flag a diff that **adds** entries to any of these, and ask for the fix instead:
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| `.code-health-baseline.json` | `@n8n/code-health` violations |
|
| `.code-health-baseline.json` | `@n8n/code-health` violations |
|
||||||
| `.boundaries-baseline.json` | `turbo boundaries` issue count |
|
| `.boundaries-baseline.json` | `turbo boundaries` issue count |
|
||||||
| `packages/testing/playwright/.janitor-baseline.json` | Playwright janitor findings |
|
| `packages/quality/testing/playwright/.janitor-baseline.json` | Playwright janitor findings |
|
||||||
| `packages/cli/eslint.config.mjs` | the `misplaced-n8n-typeorm-import` and public-API allowlists, each captioned "NEVER add to this list" |
|
| `.code-health-baseline.json` | the `typeorm-persistence-boundary` baseline, which only shrinks as business logic moves queries into repositories |
|
||||||
|
| `packages/cli/eslint.config.mjs` | the public-API allowlists captioned "NEVER add to this list" |
|
||||||
|
| `.code-health-baseline.json` (`lint-config-layering`) | package-wide rule downgrades left in package ESLint configs |
|
||||||
|
|
||||||
Removals are the healthy direction and need no comment.
|
Removals are the healthy direction and need no comment.
|
||||||
|
|
||||||
|
|
@ -33,3 +35,11 @@ Flag a lint rule moved from `'error'` to `'warn'` or `'off'`, and a new
|
||||||
`eslint-disable` for one of the guarded rules. Most packages run
|
`eslint-disable` for one of the guarded rules. Most packages run
|
||||||
`eslint . --quiet`, so a warning never fails CI — downgrading to `'warn'` is
|
`eslint . --quiet`, so a warning never fails CI — downgrading to `'warn'` is
|
||||||
functionally deleting the rule while appearing to keep it.
|
functionally deleting the rule while appearing to keep it.
|
||||||
|
|
||||||
|
In a package `eslint.config.mjs` the `lint-config-layering` code-health rule
|
||||||
|
catches this for you: a package-wide downgrade fails Static Analysis unless it
|
||||||
|
is already in the baseline. What it cannot judge is a downgrade dressed as a
|
||||||
|
scoped block. Check that a new `files` glob names the paths that actually need
|
||||||
|
the exception, and that a rule retired in `@n8n/eslint-config/src/configs/base.ts`
|
||||||
|
comes with the count of packages that had already stopped enforcing it
|
||||||
|
(`node scripts/lint-parity/majority.mjs`).
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ fed from a `needs:` list. Flag:
|
||||||
Jobs gated on a `ci-filter` filter only run when a matching file changed, so a
|
Jobs gated on a `ci-filter` filter only run when a matching file changed, so a
|
||||||
filter that is too narrow means the test quietly stops covering new code. When
|
filter that is too narrow means the test quietly stops covering new code. When
|
||||||
a PR adds a directory that an existing filter was meant to cover — a new package
|
a PR adds a directory that an existing filter was meant to cover — a new package
|
||||||
under `packages/testing/`, a new script under `.github/scripts/` — check the
|
under `packages/quality/`, a new script under `.github/scripts/` — check the
|
||||||
filter still matches it.
|
filter still matches it.
|
||||||
|
|
||||||
## Least privilege
|
## Least privilege
|
||||||
|
|
|
||||||
24
.agents/skills/agent-design-language/SKILL.md
Normal file
24
.agents/skills/agent-design-language/SKILL.md
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
name: n8n:agent-design-language
|
||||||
|
description: Design or review Agent Builder interfaces. Use for Agent configuration patterns, modal flows, responsive behavior, status treatments, and other Agent-only UI work.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Agent design language
|
||||||
|
|
||||||
|
Use this skill only for interface work in
|
||||||
|
`packages/frontend/editor-ui/src/features/agents`.
|
||||||
|
|
||||||
|
Before you change code:
|
||||||
|
|
||||||
|
1. Read `packages/frontend/editor-ui/src/features/agents/AGENTS.md`.
|
||||||
|
2. Read `packages/frontend/editor-ui/src/features/agents/agents-design-language.md`
|
||||||
|
completely.
|
||||||
|
3. Use [ui-design](../ui-design/SKILL.md) for visual implementation rules.
|
||||||
|
4. Use [content-design](../content-design/SKILL.md) when you add or change UI
|
||||||
|
text.
|
||||||
|
|
||||||
|
Keep Agent-specific components in the Agent feature. Do not change the Design
|
||||||
|
System unless the user explicitly asks for this change.
|
||||||
|
|
||||||
|
Update the design language document when you establish a reusable Agent
|
||||||
|
interface pattern. Add or update tests for the behavior that you change.
|
||||||
|
|
@ -113,7 +113,7 @@ Run when `AutoReject` is `null`. Full rules for each in `reference/checks.md`:
|
||||||
|
|
||||||
## Step 4 — Identify the responsible team
|
## Step 4 — Identify the responsible team
|
||||||
|
|
||||||
Run `node .github/scripts/owners.mjs` against the changed file list and map the winning GitHub team to a Linear team. Full mapping table, sub-agent fallback procedure, and label rules: see `reference/teams.md`.
|
Run `node .github/scripts/owners/owners.mjs` against the changed file list and map the winning GitHub team to a Linear team. Full mapping table, sub-agent fallback procedure, and label rules: see `reference/teams.md`.
|
||||||
|
|
||||||
## Step 5 — Extract the Linear ticket
|
## Step 5 — Extract the Linear ticket
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Owner resolution, the GitHub-team → Linear-team → label mapping, and the Lin
|
||||||
|
|
||||||
## Identifying the owning team
|
## Identifying the owning team
|
||||||
|
|
||||||
Use the canonical owners script at `.github/scripts/owners.mjs`. It parses `.github/OWNERS` with last-match-wins semantics and returns allocations sorted by file count with a `share` percentage. Using the script keeps this skill consistent with whatever CI uses.
|
Use the canonical owners script at `.github/scripts/owners/owners.mjs`. It parses `OWNERS` with last-match-wins semantics and returns allocations sorted by file count with a `share` percentage. Using the script keeps this skill consistent with whatever CI uses.
|
||||||
|
|
||||||
1. Write the PR's changed file paths (from the `files` list) to a temp file, one per line:
|
1. Write the PR's changed file paths (from the `files` list) to a temp file, one per line:
|
||||||
```bash
|
```bash
|
||||||
|
|
@ -24,7 +24,7 @@ Use the canonical owners script at `.github/scripts/owners.mjs`. It parses `.git
|
||||||
```
|
```
|
||||||
2. Run the script:
|
2. Run the script:
|
||||||
```bash
|
```bash
|
||||||
node .github/scripts/owners.mjs /tmp/pr-<number>-files.txt
|
node .github/scripts/owners/owners.mjs /tmp/pr-<number>-files.txt
|
||||||
```
|
```
|
||||||
3. The script prints JSON of the form:
|
3. The script prints JSON of the form:
|
||||||
```json
|
```json
|
||||||
|
|
@ -38,10 +38,10 @@ Use the canonical owners script at `.github/scripts/owners.mjs`. It parses `.git
|
||||||
```
|
```
|
||||||
Allocations are already sorted by `fileCount` descending — take the first entry as the winning team.
|
Allocations are already sorted by `fileCount` descending — take the first entry as the winning team.
|
||||||
4. Clean up: `rm /tmp/pr-<number>-files.txt`.
|
4. Clean up: `rm /tmp/pr-<number>-files.txt`.
|
||||||
5. Strip the `@n8n-io/` prefix from `allocations[0].team` — the GitHub team slug is `nodes`, `iam`, `ai`, etc. If `allocations` is empty (no file matched any rule, which is possible only if `.github/OWNERS` lost its catch-all), fall back to `catalysts`.
|
5. Strip the `@n8n-io/` prefix from `allocations[0].team` — the GitHub team slug is `nodes`, `iam`, `ai`, etc. If `allocations` is empty (no file matched any rule, which is possible only if `OWNERS` lost its catch-all), fall back to `catalysts`.
|
||||||
6. Map the GitHub team slug to its Linear team name and PR label using the table below. The `team` field in the JSON output is the **Linear team name**. If the resolved GitHub team slug has no entry in the table, fall back to `Engineering`.
|
6. Map the GitHub team slug to its Linear team name and PR label using the table below. The `team` field in the JSON output is the **Linear team name**. If the resolved GitHub team slug has no entry in the table, fall back to `Engineering`.
|
||||||
|
|
||||||
**Sub-agent fallback**: if `node` execution is denied by the sandbox, read `.github/OWNERS` directly and apply last-match-wins by hand. All the active rules fit on one screen.
|
**Sub-agent fallback**: if `node` execution is denied by the sandbox, read `OWNERS` directly and apply last-match-wins by hand. All the active rules fit on one screen.
|
||||||
|
|
||||||
## GitHub team → Linear team → GitHub label
|
## GitHub team → Linear team → GitHub label
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ Use the canonical owners script at `.github/scripts/owners.mjs`. It parses `.git
|
||||||
| `design` | Design | `team:design` |
|
| `design` | Design | `team:design` |
|
||||||
| `iam` | Identity & Access | `team:identity` |
|
| `iam` | Identity & Access | `team:identity` |
|
||||||
| `ligo` | Lifecycle & Governance | `team:lifecycle` |
|
| `ligo` | Lifecycle & Governance | `team:lifecycle` |
|
||||||
| `instance-ai` | AI Assistant | `team:instance-ai` |
|
| `ai-assistant` | AI Assistant | `team:instance-ai` |
|
||||||
| `frontend` | Adore | `team:adore` |
|
| `frontend` | Adore | `team:adore` |
|
||||||
| `qa-dx` | Developer Platform | `team:qa-dx` |
|
| `qa-dx` | Developer Platform | `team:qa-dx` |
|
||||||
| `migrations-review` | Catalysts | `team:cats` |
|
| `migrations-review` | Catalysts | `team:cats` |
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ throw new UnexpectedError('message', { extra: { context } });
|
||||||
**Testing:**
|
**Testing:**
|
||||||
- Vitest (unit), Playwright (E2E)
|
- Vitest (unit), Playwright (E2E)
|
||||||
- Mock external dependencies
|
- Mock external dependencies
|
||||||
|
- Keep filesystem tests in a test-owned temporary directory
|
||||||
|
- Set `N8N_USER_FOLDER` before importing settings code
|
||||||
|
- Trace branches activated by mocks and isolate every reachable mutation
|
||||||
- Work from package directory: `pushd packages/cli && pnpm test`
|
- Work from package directory: `pushd packages/cli && pnpm test`
|
||||||
|
|
||||||
**Database:**
|
**Database:**
|
||||||
|
|
@ -69,7 +72,8 @@ pnpm lint # Before commit
|
||||||
| Package | Purpose |
|
| Package | Purpose |
|
||||||
|---------|---------|
|
|---------|---------|
|
||||||
| `packages/cli` | Backend API |
|
| `packages/cli` | Backend API |
|
||||||
| `packages/frontend/editor-ui` | Vue 3 frontend |
|
| `packages/frontend/editor-ui` | Vue 3 frontend shell |
|
||||||
|
| `packages/modules/<name>/frontend` | Frontend feature modules. Guide: `packages/@n8n/module-cli/frontend-module-guide.md` |
|
||||||
| `packages/@n8n/api-types` | Shared types |
|
| `packages/@n8n/api-types` | Shared types |
|
||||||
| `packages/@n8n/db` | TypeORM entities |
|
| `packages/@n8n/db` | TypeORM entities |
|
||||||
| `packages/workflow` | Core interfaces |
|
| `packages/workflow` | Core interfaces |
|
||||||
|
|
|
||||||
377
.agents/skills/create-agent-builder-eval/SKILL.md
Normal file
377
.agents/skills/create-agent-builder-eval/SKILL.md
Normal file
|
|
@ -0,0 +1,377 @@
|
||||||
|
---
|
||||||
|
name: n8n:create-agent-builder-eval
|
||||||
|
description: >-
|
||||||
|
Authors and calibrates Instance AI evaluations that build standalone n8n
|
||||||
|
Agents through Agent Builder. Use when a change under
|
||||||
|
packages/cli/src/modules/agents affects build-agent routing, Agent setup,
|
||||||
|
model or credential selection, tools, MCP servers, integrations, skills,
|
||||||
|
tasks, testing, or user-facing build responses. Requires LangTracer access
|
||||||
|
before authoring so each finished case can be published.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Create an Agent Builder eval
|
||||||
|
|
||||||
|
Use the shared Instance AI eval harness. Agent cases use an Agent-specific
|
||||||
|
authoring directory, dataset, and LangTracer suite.
|
||||||
|
|
||||||
|
## Required LangTracer preflight
|
||||||
|
|
||||||
|
Run this check before sourcing, drafting, or writing an eval. Run it from
|
||||||
|
`packages/@n8n/instance-ai`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm exec dotenvx run -f ../../../.env.eval -- \
|
||||||
|
sh -c 'test -n "${LANGTRACER_URL:-}" && test -n "${LANGTRACER_API_KEY:-}"'
|
||||||
|
```
|
||||||
|
|
||||||
|
If the check fails, stop before creating an eval file. Ask the user to:
|
||||||
|
|
||||||
|
1. Generate a key on the
|
||||||
|
[LangTracer API page](https://lang-tracer.n8n-maintenance.workers.dev/account?section=api).
|
||||||
|
2. Add these variables to the repository root `.env.eval` file:
|
||||||
|
|
||||||
|
```env
|
||||||
|
LANGTRACER_URL=https://lang-tracer.n8n-maintenance.workers.dev
|
||||||
|
LANGTRACER_API_KEY=<generated-key>
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Confirm when the environment is ready.
|
||||||
|
|
||||||
|
Do not ask the user to paste the key into chat. Do not print or inspect its
|
||||||
|
value. Rerun the check after the user confirms. Continue only when it passes.
|
||||||
|
|
||||||
|
## Non-negotiable routing
|
||||||
|
|
||||||
|
- Author the case at
|
||||||
|
`packages/@n8n/instance-ai/evaluations/data/agents/<slug>.json`.
|
||||||
|
- Set `"datasets": ["agents"]`.
|
||||||
|
- Ask the driver for the target suite before you do anything else. See
|
||||||
|
"Ask for the target suite first" below. Do not assume `agents`.
|
||||||
|
- Do not commit the case JSON. LangTracer is the durable source of truth.
|
||||||
|
- Commit changes to this skill, the harness, and CI when applicable.
|
||||||
|
|
||||||
|
The disk runner loads both `data/agents/` and `data/workflows/`. A misplaced
|
||||||
|
Agent case can therefore pass locally. That does not make the location correct.
|
||||||
|
|
||||||
|
## Decide what the case proves
|
||||||
|
|
||||||
|
Write the smallest user request that exercises the changed behavior.
|
||||||
|
|
||||||
|
- Use `processExpectations` for the Instance AI conversation and final response.
|
||||||
|
- Use `outcomeExpectations` for the created Agent artifact and its configuration.
|
||||||
|
- Use `executionScenarios` only when the built Agent must run to prove the behavior.
|
||||||
|
- Declare only the credentials that the build must see.
|
||||||
|
|
||||||
|
The harness captures the Agent configuration and authored skills. It supplies
|
||||||
|
them to the expectation judge. A scenario-less Agent case is valid when process
|
||||||
|
or outcome expectations can prove the behavior.
|
||||||
|
|
||||||
|
Use the substitution test for every expectation. A correct alternative build
|
||||||
|
must pass. A build that misses the requested behavior must fail.
|
||||||
|
|
||||||
|
## Write expectations about the Agent, not the builder's internals
|
||||||
|
|
||||||
|
Agent Builder runs as a delegated sub-agent architecture today. That design
|
||||||
|
can change. Do not write an expectation that depends on it. Follow
|
||||||
|
"Keep expectations free of internal mechanics" in
|
||||||
|
[create-instance-ai-eval](../create-instance-ai-eval/SKILL.md).
|
||||||
|
|
||||||
|
Do not write:
|
||||||
|
|
||||||
|
- "The sub-agent runs/tests the Agent before it responds."
|
||||||
|
- "Instance AI delegates to `build-agent`" or "calls `build-agent` once."
|
||||||
|
- "The builder calls `call_agent` to verify the Agent."
|
||||||
|
- "The sub-agent reads the skill, then sets the model."
|
||||||
|
|
||||||
|
Write what a user or a reviewer can observe:
|
||||||
|
|
||||||
|
| ❌ mechanical | ✅ intent |
|
||||||
|
|---|---|
|
||||||
|
| "The sub-agent tests the Agent before it reports" | "The final response says the Agent was tested only if a test ran, and it reports the result of that test honestly" |
|
||||||
|
| "`build-agent` is called with the Slack credential" | "The Agent uses the Slack credential the user has" |
|
||||||
|
| "The sub-agent adds a tool for the lookup" | "The Agent can look up the order status when a user asks for it" |
|
||||||
|
| "The builder sets `model` after the catalog lookup" | "The Agent uses a model that the connected credential supports" |
|
||||||
|
|
||||||
|
Put each one where it belongs:
|
||||||
|
|
||||||
|
- The Agent's configuration, tools, skills, and behavior go in
|
||||||
|
`outcomeExpectations`.
|
||||||
|
- What the user is told, asked, or shown goes in `processExpectations`.
|
||||||
|
- The final response is the place to check claims ("says it is ready",
|
||||||
|
"lists the tools it added"). Do not check which component made the claim.
|
||||||
|
|
||||||
|
The calibration steps below ask you to confirm that `build-agent` ran. That is
|
||||||
|
a check for you, to be sure the case reached Agent Builder. Do not add it to the
|
||||||
|
case.
|
||||||
|
|
||||||
|
For multi-turn, seeded, or capability-gap cases, follow the case-shape and
|
||||||
|
calibration rules in [create-instance-ai-eval](../create-instance-ai-eval/SKILL.md).
|
||||||
|
This skill overrides its workflow directory and suite guidance for Agent cases.
|
||||||
|
The sections below add the Agent-specific parts. Do not skip the general rules
|
||||||
|
they point to.
|
||||||
|
|
||||||
|
## Ask for the target suite first
|
||||||
|
|
||||||
|
Follow "Ask for the target suite first" in
|
||||||
|
[create-instance-ai-eval](../create-instance-ai-eval/SKILL.md). Do it after the
|
||||||
|
LangTracer preflight and before you source or draft anything. If the request
|
||||||
|
already names a suite, state it and do not ask. Otherwise ask, in autonomous
|
||||||
|
mode too, in the same message as the autonomy question.
|
||||||
|
|
||||||
|
For Agent cases, recommend
|
||||||
|
[Instance AI capabilities — agents](https://lang-tracer.n8n-maintenance.workers.dev/suites/10)
|
||||||
|
(slug `agents`). Offer `baseline` as well: the Instance AI (INS) team monitors
|
||||||
|
it and it runs nightly. Get the full list from `list_suites`. Use the suite the
|
||||||
|
driver picks in every push command, in place of `agents` in the examples below.
|
||||||
|
Keep the `agents` dataset and the `data/agents/` directory. They do not depend
|
||||||
|
on the suite.
|
||||||
|
|
||||||
|
## Set the autonomy level first
|
||||||
|
|
||||||
|
Follow "Set the autonomy level first" in
|
||||||
|
[create-instance-ai-eval](../create-instance-ai-eval/SKILL.md). Ask the driver
|
||||||
|
for *autonomous* or *checkpoint* mode before you source or draft anything. The
|
||||||
|
four gates are the same: selection, shape and expectations, calibration, push.
|
||||||
|
|
||||||
|
## Source the case from a real thread
|
||||||
|
|
||||||
|
The best Agent cases come from a real conversation. Discover the conversation
|
||||||
|
with LangTracer. Author a synthetic case from what you learn.
|
||||||
|
|
||||||
|
1. List candidates: `list_conversations` with `usedAgentBuilder: true`. Do not
|
||||||
|
use `source: "agent-builder"`. That pool is a different product, has
|
||||||
|
unscrubbed payloads, and has no Agent snapshots.
|
||||||
|
2. List what the thread did to the Agent: `list_conversation_agent_snapshots`.
|
||||||
|
`target-resolved` is the state that a turn opened on. `config-updated` is the
|
||||||
|
state after the builder changed it.
|
||||||
|
3. Pick the shape from the snapshot sequence (next section).
|
||||||
|
4. Fetch the state to seed with `get_conversation_agent_snapshot`. Seed from the
|
||||||
|
`target-resolved` row of the turn under test.
|
||||||
|
5. Read the raw turn before you write any expectation. Follow
|
||||||
|
"First reproduce, then reclassify" in the general skill.
|
||||||
|
|
||||||
|
Two snapshot patterns to look for:
|
||||||
|
|
||||||
|
- A `target-resolved` hash that differs from the previous `config-updated` hash.
|
||||||
|
The user edited the Agent in the UI between turns. This is the best seed for a
|
||||||
|
repair or update case.
|
||||||
|
- A run of turns that each end in `config-updated`. The user added one rule per
|
||||||
|
turn. Use it for a "new rule does not erase old rules" case.
|
||||||
|
|
||||||
|
Credentials arrive as `[redacted]`. Instructions and skill bodies do not. Scrub
|
||||||
|
the prose before it enters a case. See the `agents` section in
|
||||||
|
[case-shapes.md](../create-instance-ai-eval/case-shapes.md) (the `agents` seed section).
|
||||||
|
|
||||||
|
## Pick the shape: create or update
|
||||||
|
|
||||||
|
| Shape | Question it answers | How to write it |
|
||||||
|
|---|---|---|
|
||||||
|
| **Create** | Does the builder make the right Agent from a fresh request? | One user turn. No seed. Assert on the Agent artifact. |
|
||||||
|
| **Update** | Does the builder change only what the user asked for? | `seed.agents` with the Agent before the change. One live turn with the change. Assert on the new behavior and that the untouched parts survive. |
|
||||||
|
| **Repair** | Does the builder find the cause of a failure and fix it? | Seed the broken Agent. The live turn reports the failure. Assert on the cause found and the fix applied. |
|
||||||
|
| **Incremental rules** | Do earlier rules survive when a new rule lands? | Seed the Agent after several rules. Add one conflicting or overlapping rule. Assert that the old rules are still in force. |
|
||||||
|
|
||||||
|
Rules that apply to all four:
|
||||||
|
|
||||||
|
- An update that rebuilds the Agent from scratch is a failure. Assert on a
|
||||||
|
specific untouched instruction, tool, or skill that must still be there.
|
||||||
|
- Write the conversation in English, even when the source thread is not.
|
||||||
|
- Trim to the fewest turns that reproduce the behavior. Do not copy a long
|
||||||
|
thread.
|
||||||
|
- Put only the live turn in `conversation`. Put earlier turns in `seed.messages`.
|
||||||
|
|
||||||
|
## Confirm the precondition fired
|
||||||
|
|
||||||
|
A pass can mean the builder did the right thing. It can also mean the situation
|
||||||
|
never happened. Check before you trust a green.
|
||||||
|
|
||||||
|
- For "the builder did not do X", confirm that it reached the turn where X was
|
||||||
|
possible. A builder that never edited the Agent passes "did not delete the old
|
||||||
|
rule".
|
||||||
|
- For a repair case, confirm that the seeded Agent really has the defect. Read
|
||||||
|
the seeded config in the rendered artifact.
|
||||||
|
- For an update case, compare the seeded config with the final config. Confirm
|
||||||
|
that the requested change is the only difference you expected.
|
||||||
|
- For a "say you cannot" case, confirm that the tool or data was really missing
|
||||||
|
in the run.
|
||||||
|
|
||||||
|
## A red is a finding
|
||||||
|
|
||||||
|
Follow "A red is signal" in the general skill. For Agent cases, add this:
|
||||||
|
|
||||||
|
1. Classify the red as a product gap, a harness limitation, or non-determinism.
|
||||||
|
2. Keep a product-gap red. Start the case `description` with
|
||||||
|
`Capability-gap finding:`.
|
||||||
|
3. **Propose a Linear ticket for the Agent team.** The Linear team is named
|
||||||
|
`Agent`. Propose the ticket. Do not create it unless the driver says go.
|
||||||
|
Follow "Capability gap → propose a Linear ticket" in the general skill. Also
|
||||||
|
check whether the gap already has a ticket.
|
||||||
|
- Write the ticket in English. Use Simplified Technical English, as
|
||||||
|
[AGENTS.md](../../../AGENTS.md) requires. Translate the user's words. Do
|
||||||
|
not paste them.
|
||||||
|
- This repository is public. Keep customer names, company names, and real
|
||||||
|
URLs out of the ticket. Describe the use case in neutral words.
|
||||||
|
- Link the LangTracer case and the source thread. Do not copy raw user
|
||||||
|
messages or agent instructions from the thread.
|
||||||
|
- Reproduce the gap first. This is a default, not a hard rule. Propose a
|
||||||
|
ticket only after a case is red on a real build. Quote the failing
|
||||||
|
expectation and the judge reason. Follow "Reproduce first" in the general
|
||||||
|
skill.
|
||||||
|
- The driver may approve an exception, for example when the harness cannot
|
||||||
|
reach the mechanism after about three attempts. Then the ticket must say
|
||||||
|
"Not reproduced in the eval. Based on trace analysis."
|
||||||
|
4. **Check the builder's own guidance for the gap.** Read the files that steer
|
||||||
|
Agent Builder:
|
||||||
|
`packages/cli/src/modules/agents/builder/agents-builder-prompts.ts`,
|
||||||
|
`packages/cli/src/modules/agents/builder/prompts/`, and
|
||||||
|
`packages/cli/src/modules/agents/builder/skills/`. Also read the Instance AI
|
||||||
|
orchestrator prompt in `packages/@n8n/instance-ai/src/agent/system-prompt.ts`.
|
||||||
|
If none of them covers the failing situation, add that to the ticket as a
|
||||||
|
proposed prompt or skill change.
|
||||||
|
5. Propose the smallest added line first. Do not delete existing guidance to fix a
|
||||||
|
gap. A measured case: adding one line fixed a routing gap, and deleting two
|
||||||
|
lines did not.
|
||||||
|
6. Every prompt or skill change needs a before and after measurement. The new
|
||||||
|
case is the "before" run. Run it again after the change. Use `--iterations 5`.
|
||||||
|
|
||||||
|
When the failure is in the Agent's runtime (for example a channel that cannot
|
||||||
|
report an error), the builder cannot see it. The right fix is often a builder
|
||||||
|
instruction to say so and stop guessing. Write that as a `processExpectations`
|
||||||
|
item on the final response.
|
||||||
|
|
||||||
|
## Publish and link
|
||||||
|
|
||||||
|
Follow "Share links, never bare ids" and "Link the pushed case to its source" in
|
||||||
|
the general skill. For a sourced Agent case:
|
||||||
|
|
||||||
|
- Report the case, the suite, and the source thread as links. Use the
|
||||||
|
`https://lang-tracer.n8n-maintenance.workers.dev/test-cases/<id>` form.
|
||||||
|
- Call `update_test_case` with `sourceThreadId`, `expectedBehavior`, and
|
||||||
|
`failurePattern`.
|
||||||
|
- Add a capability tag with `add_case_tags`.
|
||||||
|
- Push a case whose *build* is wrong with `--set-kind capability_gap` into a
|
||||||
|
suite of that kind. If no such Agent suite exists, tell the driver. Do not put
|
||||||
|
it in a `regression` suite.
|
||||||
|
|
||||||
|
## Draft the case
|
||||||
|
|
||||||
|
Start with this shape:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"description": "The Agent Builder behavior this case guards.",
|
||||||
|
"conversation": [
|
||||||
|
{ "role": "user", "text": "Build me an Agent that ..." }
|
||||||
|
],
|
||||||
|
"complexity": "simple",
|
||||||
|
"tags": ["agent", "agent-build", "<capability>"],
|
||||||
|
"credentials": [{ "type": "<credentialType>", "name": "<display name>" }],
|
||||||
|
"processExpectations": [
|
||||||
|
"The final response ..."
|
||||||
|
],
|
||||||
|
"outcomeExpectations": [
|
||||||
|
"A standalone Agent is the deliverable; any workflow created exists only as a tool the Agent calls.",
|
||||||
|
"The Agent ..."
|
||||||
|
],
|
||||||
|
"datasets": ["agents"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep the prompt in the user's voice. Do not tell Instance AI which internal
|
||||||
|
tools or configuration fields to use unless that choice is the behavior under
|
||||||
|
test.
|
||||||
|
|
||||||
|
## Validate and run locally
|
||||||
|
|
||||||
|
Read [local-setup.md](local-setup.md) when the machine does not already have an
|
||||||
|
eval instance and environment file.
|
||||||
|
|
||||||
|
From `packages/@n8n/instance-ai`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm exec tsx -e "import { loadAgentEvalTestCasesWithFiles } from './evaluations/data/agents/index.ts'; const matches = loadAgentEvalTestCasesWithFiles('<slug>'); if (matches.length !== 1) throw new Error('Expected exactly one Agent eval case, found ' + matches.length); console.log(matches[0].fileSlug)"
|
||||||
|
|
||||||
|
pnpm eval:instance-ai \
|
||||||
|
--base-url http://localhost:5680 \
|
||||||
|
--filter <slug> \
|
||||||
|
--tier agents \
|
||||||
|
--concurrency 1 \
|
||||||
|
--keep-workflows \
|
||||||
|
--verbose
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `eval:instance-ai` for a new disk case. `eval:agents` reads the published
|
||||||
|
LangTracer suite and is for running cases that are already there.
|
||||||
|
|
||||||
|
Inspect the transcript, the rendered Agent artifact, and each judge reason.
|
||||||
|
Do not accept a green result when a conditional expectation never occurred.
|
||||||
|
Do not weaken an expectation to hide a real Agent Builder defect.
|
||||||
|
|
||||||
|
## CI coverage
|
||||||
|
|
||||||
|
The Instance AI PR gate checks the files changed by the PR. A change under
|
||||||
|
`packages/cli/src/modules/agents/` selects the `Instance AI capabilities — agents`
|
||||||
|
suite through its `agents` slug. It also selects the `agents` dataset and uses
|
||||||
|
an absolute pass gate. The run uses a suite-scoped LangSmith cohort. It does not
|
||||||
|
write to the workflow dataset or compare against the workflow baseline. Other
|
||||||
|
Instance AI changes select the `baseline` suite and its `pr` dataset.
|
||||||
|
|
||||||
|
The gate runs when a PR opens, reopens, or becomes ready for review. It does not
|
||||||
|
run for each new push. Use the PR gate's manual dispatch after a later push.
|
||||||
|
|
||||||
|
## Credential behavior
|
||||||
|
|
||||||
|
Declared credentials are real n8n credential records with placeholder data.
|
||||||
|
The eval thread limits the builder to those credential IDs.
|
||||||
|
|
||||||
|
Agent Builder model catalog requests return deterministic fake models during an
|
||||||
|
eval. They do not decrypt the placeholder model credential or call its provider.
|
||||||
|
Production model catalog requests remain live.
|
||||||
|
|
||||||
|
This mock covers catalog lookup only. A builder `call_agent` action and an Agent
|
||||||
|
`executionScenario` run the target Agent model. They need a working provider
|
||||||
|
credential such as `EVAL_OPENAI_API_KEY`. A build-only case does not need one.
|
||||||
|
|
||||||
|
## Calibrate and publish
|
||||||
|
|
||||||
|
1. Run the case once with `--concurrency 1`.
|
||||||
|
2. Confirm that Instance AI called `build-agent`.
|
||||||
|
3. Confirm that the expected Agent artifact was captured.
|
||||||
|
4. Classify each red as a product gap, harness limitation, or non-determinism.
|
||||||
|
5. Use `--iterations 5` before adding a case to a gating tier.
|
||||||
|
6. Preview the LangTracer change.
|
||||||
|
7. Push it to the suite the driver chose (`<suite>` below).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm exec dotenvx run -f ../../../.env.eval -- \
|
||||||
|
pnpm eval:langtracer-push --suite <suite> --dry-run --changed
|
||||||
|
|
||||||
|
pnpm exec dotenvx run -f ../../../.env.eval -- \
|
||||||
|
pnpm eval:langtracer-push --suite <suite> --changed
|
||||||
|
```
|
||||||
|
|
||||||
|
The push needs `LANGTRACER_URL` and `LANGTRACER_API_KEY`. Generate a key on the
|
||||||
|
[LangTracer API page](https://lang-tracer.n8n-maintenance.workers.dev/account?section=api).
|
||||||
|
Report the case and suite as clickable LangTracer links. Delete the local JSON
|
||||||
|
after a successful push.
|
||||||
|
|
||||||
|
## Completion checklist
|
||||||
|
|
||||||
|
- The LangTracer environment preflight passed before authoring.
|
||||||
|
- The driver chose the target suite before any work, including in autonomous mode.
|
||||||
|
- The autonomy level was set and stated before any work.
|
||||||
|
- A sourced case links to its source thread, and the source turn was read raw.
|
||||||
|
- Each conditional expectation has proof that its precondition fired.
|
||||||
|
- A kept product-gap red has a proposed Linear ticket and a check of the builder guidance.
|
||||||
|
- The case is in `data/agents/` and uses the `agents` dataset.
|
||||||
|
- The strict loader accepts it.
|
||||||
|
- A local run captures a standalone Agent.
|
||||||
|
- The transcript proves each process expectation was exercised.
|
||||||
|
- The rendered Agent artifact proves each outcome expectation.
|
||||||
|
- No expectation names a sub-agent, an internal tool, or a delegation step.
|
||||||
|
Each one passes for a correct build from a different architecture.
|
||||||
|
- Repeated runs are stable enough for the selected tier.
|
||||||
|
- The case is pushed to the suite the driver chose, and the report links to it.
|
||||||
|
- Agent Builder PR changes select the `agents` suite in CI. A case pushed to
|
||||||
|
another suite does not run in that lane.
|
||||||
|
- The local case JSON is not committed.
|
||||||
110
.agents/skills/create-agent-builder-eval/local-setup.md
Normal file
110
.agents/skills/create-agent-builder-eval/local-setup.md
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
# Local Agent Builder eval setup
|
||||||
|
|
||||||
|
## Required LangTracer access
|
||||||
|
|
||||||
|
Generate a key on the
|
||||||
|
[LangTracer API keys page](https://lang-tracer.n8n-maintenance.workers.dev/account?section=api).
|
||||||
|
Add it to `.env.eval` at the repository root:
|
||||||
|
|
||||||
|
```env
|
||||||
|
LANGTRACER_URL=https://lang-tracer.n8n-maintenance.workers.dev
|
||||||
|
LANGTRACER_API_KEY=<generated-key>
|
||||||
|
```
|
||||||
|
|
||||||
|
Do not paste the key into chat or put it in a command. The main skill checks
|
||||||
|
that both variables exist before it creates an eval.
|
||||||
|
|
||||||
|
## Remaining environment
|
||||||
|
|
||||||
|
Create `.env.eval` at the repository root. Use one Instance AI model provider
|
||||||
|
and one sandbox provider.
|
||||||
|
|
||||||
|
```env
|
||||||
|
N8N_INSTANCE_AI_MODEL=anthropic/claude-sonnet-4-6
|
||||||
|
N8N_INSTANCE_AI_MODEL_API_KEY=<model-key>
|
||||||
|
ANTHROPIC_API_KEY=<same-model-key>
|
||||||
|
N8N_AI_ASSISTANT_BASE_URL=
|
||||||
|
|
||||||
|
N8N_INSTANCE_AI_SANDBOX_ENABLED=true
|
||||||
|
N8N_INSTANCE_AI_SANDBOX_PROVIDER=daytona
|
||||||
|
DAYTONA_API_URL=https://app.daytona.io/api
|
||||||
|
DAYTONA_API_KEY=<daytona-key>
|
||||||
|
|
||||||
|
N8N_EVAL_EMAIL=nathan@n8n.io
|
||||||
|
N8N_EVAL_PASSWORD=PlaywrightTest123
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the n8n sandbox service instead of Daytona when it is available. Set
|
||||||
|
`N8N_INSTANCE_AI_SANDBOX_PROVIDER=n8n-sandbox`,
|
||||||
|
`N8N_SANDBOX_SERVICE_URL`, and, when required,
|
||||||
|
`N8N_SANDBOX_SERVICE_API_KEY`.
|
||||||
|
|
||||||
|
LangSmith is optional. Unset `LANGSMITH_API_KEY` and `LANGSMITH_TRACING` for a
|
||||||
|
throwaway direct run. This keeps the run out of the shared LangSmith dataset.
|
||||||
|
|
||||||
|
## Build after code changes
|
||||||
|
|
||||||
|
From the repository root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
(
|
||||||
|
pnpm --filter n8n... build > build.log 2>&1
|
||||||
|
build_status=$?
|
||||||
|
tail -n 20 build.log
|
||||||
|
exit "$build_status"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Restart the instance after each build. A running process keeps the old code in
|
||||||
|
memory.
|
||||||
|
|
||||||
|
## Start an isolated instance
|
||||||
|
|
||||||
|
Create a temporary user directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mktemp -d /tmp/n8n-agent-eval.XXXXXX
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the printed path as `N8N_USER_FOLDER`. Start the built CLI from
|
||||||
|
`packages/cli`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
N8N_PORT=5680 \
|
||||||
|
N8N_RUNNERS_BROKER_PORT=5681 \
|
||||||
|
N8N_USER_FOLDER=<printed-temp-directory> \
|
||||||
|
E2E_TESTS=true \
|
||||||
|
N8N_ENABLED_MODULES=instance-ai,agents \
|
||||||
|
N8N_AI_ENABLED=true \
|
||||||
|
pnpm exec dotenvx run -f ../../.env.eval -- pnpm start
|
||||||
|
```
|
||||||
|
|
||||||
|
Use different ports when 5680 or 5681 is busy.
|
||||||
|
|
||||||
|
## Seed the owner
|
||||||
|
|
||||||
|
Run this once after the isolated instance starts:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -sf -X POST http://localhost:5680/rest/e2e/reset \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{"owner":{"email":"nathan@n8n.io","password":"PlaywrightTest123","firstName":"Eval","lastName":"Owner"},"admin":{"email":"admin@n8n.io","password":"PlaywrightTest123","firstName":"Admin","lastName":"User"},"members":[],"chat":{"email":"chat@n8n.io","password":"PlaywrightTest123","firstName":"Chat","lastName":"User"}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run a local disk case
|
||||||
|
|
||||||
|
From `packages/@n8n/instance-ai`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm exec dotenvx run -f ../../../.env.eval -- \
|
||||||
|
env -u LANGSMITH_API_KEY -u LANGSMITH_TRACING \
|
||||||
|
pnpm eval:instance-ai \
|
||||||
|
--base-url http://localhost:5680 \
|
||||||
|
--filter <slug> \
|
||||||
|
--tier agents \
|
||||||
|
--concurrency 1 \
|
||||||
|
--verbose
|
||||||
|
```
|
||||||
|
|
||||||
|
The run writes `eval-results.json`, an HTML report, and a PR-comment preview.
|
||||||
|
The warnings about disabled run-debug capture are benign.
|
||||||
|
|
@ -1,19 +1,21 @@
|
||||||
---
|
---
|
||||||
name: n8n:create-instance-ai-eval
|
name: n8n:create-instance-ai-eval
|
||||||
description: >-
|
description: >-
|
||||||
Authors a new Instance AI workflow eval case — written locally as JSON,
|
Authors a new Instance AI workflow or Agent eval case — written locally as
|
||||||
calibrated against a real build, then pushed to the LangTracer suite CI runs
|
JSON, calibrated against a real build, then pushed to the LangTracer suite CI
|
||||||
— build cases, behaviour/process cases, credential cases, and seeded
|
runs — build cases, behaviour/process cases, credential cases, and seeded
|
||||||
(mid-conversation) cases — with intent-driven expectations. Use when adding
|
(mid-conversation) cases — with intent-driven expectations. Use when adding
|
||||||
or changing an Instance AI workflow eval, or debugging why one is flaky.
|
or changing an Instance AI eval, or debugging why one is flaky.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Create an Instance AI workflow eval
|
# Create an Instance AI eval
|
||||||
|
|
||||||
Each eval is **one JSON case** — authored locally as a file in
|
Each eval is **one JSON case**. Author workflow cases in
|
||||||
`packages/@n8n/instance-ai/evaluations/data/workflows/` (the disk loader
|
`packages/@n8n/instance-ai/evaluations/data/workflows/`. Author standalone Agent
|
||||||
auto-discovers `*.json`, no registration step), with a LangTracer suite as its
|
cases in `packages/@n8n/instance-ai/evaluations/data/agents/` and follow the
|
||||||
durable home. Cases validate against
|
[`create-agent-builder-eval` skill](../create-agent-builder-eval/SKILL.md).
|
||||||
|
The disk loader auto-discovers `*.json` in both directories. A LangTracer suite
|
||||||
|
is the durable home. Cases validate against
|
||||||
[`harness/schema.ts`](../../../packages/@n8n/instance-ai/evaluations/harness/schema.ts)
|
[`harness/schema.ts`](../../../packages/@n8n/instance-ai/evaluations/harness/schema.ts)
|
||||||
(`.strict()` — unknown keys fail at load). The eval
|
(`.strict()` — unknown keys fail at load). The eval
|
||||||
[README](../../../packages/@n8n/instance-ai/evaluations/README.md) is the
|
[README](../../../packages/@n8n/instance-ai/evaluations/README.md) is the
|
||||||
|
|
@ -23,7 +25,9 @@ exhaustive field reference; this skill is the opinionated *how*.
|
||||||
> approach.** Author the file locally (uncommitted), calibrate it against a real
|
> approach.** Author the file locally (uncommitted), calibrate it against a real
|
||||||
> build, then **push it to a lang-tracer suite** with `eval:langtracer-push`
|
> build, then **push it to a lang-tracer suite** with `eval:langtracer-push`
|
||||||
> (see [Push to a lang-tracer suite](#push-to-a-lang-tracer-suite)) —
|
> (see [Push to a lang-tracer suite](#push-to-a-lang-tracer-suite)) —
|
||||||
> `--suite baseline` for the consolidated corpus n8n CI runs, or a dedicated
|
> the suite the driver chose (see
|
||||||
|
> [Ask for the target suite first](#ask-for-the-target-suite-first)) —
|
||||||
|
> `baseline` for the consolidated corpus n8n CI runs, or a dedicated
|
||||||
> capability suite like `agents`.
|
> capability suite like `agents`.
|
||||||
> The suite is the home for the case; the eval CLI reads it back via
|
> The suite is the home for the case; the eval CLI reads it back via
|
||||||
> `--source langtracer`. You still write the JSON file — it's just the input to
|
> `--source langtracer`. You still write the JSON file — it's just the input to
|
||||||
|
|
@ -36,6 +40,34 @@ exhaustive field reference; this skill is the opinionated *how*.
|
||||||
> pruned and has no durable home. Don't commit a replay case either — derive a
|
> pruned and has no durable home. Don't commit a replay case either — derive a
|
||||||
> synthetic case from it. See [`case-shapes.md`](case-shapes.md).
|
> synthetic case from it. See [`case-shapes.md`](case-shapes.md).
|
||||||
|
|
||||||
|
## Ask for the target suite first
|
||||||
|
|
||||||
|
**Before you source, draft, or run anything, ask the driver which LangTracer
|
||||||
|
suite receives every eval you create in this session.** Ask this in both
|
||||||
|
autonomy levels, including autonomous mode. Never pick the suite yourself and
|
||||||
|
never default silently. A case pushed to the wrong suite runs in the wrong CI
|
||||||
|
lane and alerts the wrong team.
|
||||||
|
|
||||||
|
Ask the suite question and the autonomy question together, in one message.
|
||||||
|
Recommend `baseline`:
|
||||||
|
|
||||||
|
- `baseline` (recommended): the general corpus. The Instance AI (INS) team
|
||||||
|
monitors it, and it runs nightly.
|
||||||
|
- Any other suite, such as `agents` or `node-gauntlet`: call `list_suites` and
|
||||||
|
offer the live list. Do not use a hardcoded list, because suites are added
|
||||||
|
and retired.
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
|
||||||
|
- The driver's answer applies to all cases in the session. Do not ask again per
|
||||||
|
case.
|
||||||
|
- If the driver already named a suite in the request, state it back in one line
|
||||||
|
and continue. Do not ask again.
|
||||||
|
- Check that the suite kind matches the case. Push a case with a wrong build
|
||||||
|
(`capability_gap`) only into a suite that allows that kind. If the suite does
|
||||||
|
not allow it, tell the driver and ask again.
|
||||||
|
- Put the chosen suite slug in the final decision log, as a link.
|
||||||
|
|
||||||
## Set the autonomy level first
|
## Set the autonomy level first
|
||||||
|
|
||||||
**Before you source, draft, or run anything, decide how hands-on the driver
|
**Before you source, draft, or run anything, decide how hands-on the driver
|
||||||
|
|
@ -138,7 +170,7 @@ discover → verify → encode workflow.
|
||||||
|
|
||||||
## Pick the case shape first
|
## Pick the case shape first
|
||||||
|
|
||||||
The corpus is four archetypes. Decide which you're writing before you draft — it
|
The corpus is five archetypes. Decide which you're writing before you draft — it
|
||||||
determines the fields, the grading, and how you validate. They compose (a seeded
|
determines the fields, the grading, and how you validate. They compose (a seeded
|
||||||
case can still assert outcome), but the primary shape drives the work.
|
case can still assert outcome), but the primary shape drives the work.
|
||||||
|
|
||||||
|
|
@ -148,10 +180,25 @@ case can still assert outcome), but the primary shape drives the work.
|
||||||
| **Behaviour / process** | Does the agent *converse* correctly (ask the right clarifying question, not re-ask, honour a correction, respect plan approval)? | `processExpectations` + multi-turn director script; often **build-only** |
|
| **Behaviour / process** | Does the agent *converse* correctly (ask the right clarifying question, not re-ask, honour a correction, respect plan approval)? | `processExpectations` + multi-turn director script; often **build-only** |
|
||||||
| **Credential** | Does the build behave correctly given a specific credential view? | `credentials[]` |
|
| **Credential** | Does the build behave correctly given a specific credential view? | `credentials[]` |
|
||||||
| **Seeded** | Start mid-thread, with prior work already in place, and drive the turn under test | `seed` (authored `mode: "inline"`; `"replay"` for a local check) |
|
| **Seeded** | Start mid-thread, with prior work already in place, and drive the turn under test | `seed` (authored `mode: "inline"`; `"replay"` for a local check) |
|
||||||
|
| **Context** | Does the agent still work once the conversation is long — does it reuse what it already read, and keep what matters after observational memory compacts the history? | `processExpectations` + a long `seed`; `requiresMemoryCompaction` for the compaction ones |
|
||||||
|
|
||||||
**Build** is documented in full below. The other three, the director-script
|
**Build** is documented in full below. The other four, the director-script
|
||||||
vocabulary, and the seeding modes are in [`case-shapes.md`](case-shapes.md).
|
vocabulary, and the seeding modes are in [`case-shapes.md`](case-shapes.md).
|
||||||
|
|
||||||
|
The judge also sees **token ground truth** for workflow-build cases: per-turn
|
||||||
|
input and output tokens inline in each transcript turn header, a build-wide
|
||||||
|
total, a cache read/write split, and the opening step's cost. So an expectation
|
||||||
|
may reference cost or consumption directly ("does not re-read the same node's
|
||||||
|
schema in turn 2"). The numbers cover the orchestrator's own LLM steps only. A
|
||||||
|
delegated Agent build runs in a sub-agent whose steps are not in the snapshot,
|
||||||
|
so do not write cost expectations on an Agent case. Those numbers come from run-debug snapshots, so they need
|
||||||
|
`N8N_INSTANCE_AI_RUN_DEBUG_ENABLED=true` on the instance under test; without it
|
||||||
|
the judge reads `(no run debug captured)` and cost expectations are ungradeable.
|
||||||
|
|
||||||
|
The judge also sees the thread's **observation rows** — what observational
|
||||||
|
memory kept after it compacted — so a memory case can grade the summary itself.
|
||||||
|
That block is a separate REST read and needs no flag.
|
||||||
|
|
||||||
## Core principle (all shapes)
|
## Core principle (all shapes)
|
||||||
|
|
||||||
**Write expectations from intent, then calibrate against a real build.** Decide
|
**Write expectations from intent, then calibrate against a real build.** Decide
|
||||||
|
|
@ -244,11 +291,14 @@ calibration you hand the driver the thread link + login to review the real build
|
||||||
build has a real gap, or because the harness can't exercise it, **that red is
|
build has a real gap, or because the harness can't exercise it, **that red is
|
||||||
the result — keep it and surface why** (see "A red is signal", below). Never
|
the result — keep it and surface why** (see "A red is signal", below). Never
|
||||||
delete a scenario, weaken an assertion, or drop to build-only just to make the
|
delete a scenario, weaken an assertion, or drop to build-only just to make the
|
||||||
run green.
|
run green. And when the case comes back **green**, that is a result to earn,
|
||||||
|
not to accept: confirm the precondition actually fired, then re-derive it from
|
||||||
|
the raw thread before calling the case a regression guard (see
|
||||||
|
[First reproduce, then reclassify](#first-reproduce-then-reclassify)).
|
||||||
7. **Push to the suite — do NOT commit the JSON.** Once calibrated, push the case
|
7. **Push to the suite — do NOT commit the JSON.** Once calibrated, push the case
|
||||||
into its curated lang-tracer suite with `eval:langtracer-push` (see
|
into its curated lang-tracer suite with `eval:langtracer-push` (see
|
||||||
[Push to a lang-tracer suite](#push-to-a-lang-tracer-suite)); the suite is the
|
[Push to a lang-tracer suite](#push-to-a-lang-tracer-suite)); the suite is the
|
||||||
case's home, not the repo. Leave the `data/workflows/*.json` file uncommitted
|
case's home, not the repo. Leave the `data/{workflows,agents}/*.json` file uncommitted
|
||||||
(or delete it once it's in the suite). Committing new case JSONs into the repo
|
(or delete it once it's in the suite). Committing new case JSONs into the repo
|
||||||
is no longer the approach. (An `inline` seed pushes with the case; only a
|
is no longer the approach. (An `inline` seed pushes with the case; only a
|
||||||
`replay` case is refused — it's a local throwaway; see
|
`replay` case is refused — it's a local throwaway; see
|
||||||
|
|
@ -282,13 +332,80 @@ and verify X actually materialised — the direct-loop `eval-results.json` does
|
||||||
persist per-expectation judge reasoning, so pass/fail alone can't tell you which
|
persist per-expectation judge reasoning, so pass/fail alone can't tell you which
|
||||||
reading you got.
|
reading you got.
|
||||||
|
|
||||||
**A sourced failure that no longer reproduces is still worth keeping — it's now a
|
**The negative form is the easiest to fool yourself with.** An assertion phrased
|
||||||
regression guard.** When you encode a real failure and calibration shows the
|
as "the agent did NOT call `X` with a bad argument" passes when the agent called
|
||||||
current build handling it correctly (behaviour drifts across versions), the case
|
`X` correctly *and* when **it never called `X` at all**. Those are opposite
|
||||||
doesn't lose value: it flips from *capability-gap* (currently red) to *regression
|
results and the judge reports the same green. So for any assertion about tool
|
||||||
guard* (currently green, catches a re-introduction). Keep it — but only after the
|
misuse, confirm the tool was actually invoked before believing the pass: parse
|
||||||
non-vacuous check above proves it *would* turn red on the bad behaviour, else the
|
`testCases[].transcriptPerRun[][].steps[]` for the call. Note the transcript
|
||||||
"guard" guards nothing.
|
groups multi-action tools under a bare `toolName` (`nodes`, `workflows`,
|
||||||
|
`credentials`), so read `args.action` to get the real one — filtering on
|
||||||
|
`nodes[explore-resources]` finds nothing and looks like a clean pass. Measured on
|
||||||
|
this corpus: a batch of five tool-misuse cases scored 100% on its first
|
||||||
|
calibration run, and three of them were passing vacuously because the tool under
|
||||||
|
test was never called.
|
||||||
|
|
||||||
|
**A sourced failure that does not reproduce is not yet a regression guard — first
|
||||||
|
re-derive the precondition.** Behaviour does drift across versions, and a case
|
||||||
|
that flips from *capability-gap* (red) to *regression guard* (green, catches a
|
||||||
|
re-introduction) is a legitimate and valuable outcome. But reach it by
|
||||||
|
elimination, not by default: a green far more often means *your case never set up
|
||||||
|
the situation* than *the builder improved*. See below.
|
||||||
|
|
||||||
|
## First reproduce, then reclassify
|
||||||
|
|
||||||
|
A case built from a real failure that comes back green is the most common
|
||||||
|
outcome of a first calibration run, and "the build must have improved" is the
|
||||||
|
most common wrong conclusion. The usual cause is that you authored from a
|
||||||
|
*summary* of the thread — the theme label, the observation description, your own
|
||||||
|
one-line note — and the trigger you assumed is not the trigger that fired. Go
|
||||||
|
back to the raw thread before you downgrade anything.
|
||||||
|
|
||||||
|
**Find the turn, not the topic.** Locate the exact tool call that failed, then
|
||||||
|
read the assistant text immediately before it. The agent usually states its
|
||||||
|
intent in the open, and that sentence is the precondition. Then ask what *state*
|
||||||
|
made that call necessary — not what the conversation was about.
|
||||||
|
|
||||||
|
Worked example from this corpus. Sourced finding: "the agent invents
|
||||||
|
`nodes[explore-resources]` method names." Assumed trigger: the user swaps model
|
||||||
|
provider. A case built on a clean provider swap came back green — the agent set
|
||||||
|
the model id directly and never called the tool at all. The raw thread said it
|
||||||
|
plainly:
|
||||||
|
|
||||||
|
> "The **Groq Chat Model** has an invalid model (`llama3-8b-8192` isn't offered
|
||||||
|
> by your Groq credential). **Let me list valid models and fix it.**"
|
||||||
|
|
||||||
|
The precondition was never the swap. It was *an existing model id that the
|
||||||
|
provider rejects at runtime, with a credential already connected* — that is the
|
||||||
|
state that makes enumerating models necessary. Rebuilt on it, the same case
|
||||||
|
reproduced the failure on the first run, with the agent inventing two method
|
||||||
|
names in a row.
|
||||||
|
|
||||||
|
Three moves turn a non-reproducing case into a reproducing one. Try them in
|
||||||
|
order before settling for a guard:
|
||||||
|
|
||||||
|
1. **Fix the precondition.** Rebuild the seed and the live turn to recreate the
|
||||||
|
state the source thread was in, not the subject it was discussing.
|
||||||
|
2. **Move the assertion to the first call.** A mechanism where the agent
|
||||||
|
*self-corrects* grades green on the end state and is still a real defect — the
|
||||||
|
wasted round-trip and the guessed schema are the finding. Grading first-call
|
||||||
|
correctness turned a mechanism previously dismissed as "self-corrects, weak
|
||||||
|
eval" into a gap that reproduced in 2 of 2 runs.
|
||||||
|
3. **Keep what the attempt actually caught.** A reproduction run often reds on a
|
||||||
|
*different* real defect than the one you targeted. That is still a
|
||||||
|
capability-gap finding — keep the red, retarget the description, and say
|
||||||
|
plainly in it that the originally targeted mechanism did not reproduce.
|
||||||
|
|
||||||
|
**Know when to stop.** Some mechanisms are structurally unreachable in this
|
||||||
|
harness, and no amount of re-deriving fixes that. The clearest example: a seed
|
||||||
|
restores a **fresh** workspace file at the start of the graded turn, so the
|
||||||
|
agent's first `old_str` always comes from a file it just read. Failures that need
|
||||||
|
*accumulated drift* across many turns — the `str_replace` byte-fidelity family,
|
||||||
|
the largest agent-caused tool-call failure in production at 15% of threads — do
|
||||||
|
not reproduce even in a multi-turn chain of edits, each followed by a build. Cap
|
||||||
|
the effort at about three attempts, then write the negative result into the case
|
||||||
|
`description` as the finding it is, and ask whether the real defect belongs in a
|
||||||
|
ticket rather than an eval.
|
||||||
|
|
||||||
## A red is signal — surface it, don't work around it
|
## A red is signal — surface it, don't work around it
|
||||||
|
|
||||||
|
|
@ -381,6 +498,16 @@ read the run assumes someone already owns it. So once a red is classified as a
|
||||||
real gap (and the driver has confirmed it, per the autonomy level), **propose a
|
real gap (and the driver has confirmed it, per the autonomy level), **propose a
|
||||||
Linear ticket for it.**
|
Linear ticket for it.**
|
||||||
|
|
||||||
|
**Reproduce first. This is a default, not a hard rule.** Propose a ticket only
|
||||||
|
after a case has reproduced the gap. That means the case is red on a real build,
|
||||||
|
the precondition was confirmed to fire, and you re-read the raw thread (see
|
||||||
|
[First reproduce, then reclassify](#first-reproduce-then-reclassify)). A gap that
|
||||||
|
comes from trace analysis alone is a hypothesis. A ticket for it costs the owning
|
||||||
|
team time. The driver may approve an exception, for example when the harness
|
||||||
|
cannot reach the mechanism after about three attempts. In that case the ticket
|
||||||
|
must say that the eval did not reproduce the gap. Never file an unreproduced gap
|
||||||
|
without the driver's approval.
|
||||||
|
|
||||||
**Propose, don't create.** Per [AGENTS.md](../../../AGENTS.md), never open a
|
**Propose, don't create.** Per [AGENTS.md](../../../AGENTS.md), never open a
|
||||||
Linear ticket unasked. Put the draft in front of the driver — interactively in
|
Linear ticket unasked. Put the draft in front of the driver — interactively in
|
||||||
checkpoint mode, in the decision log in autonomous mode — with a title, a team,
|
checkpoint mode, in the decision log in autonomous mode — with a title, a team,
|
||||||
|
|
@ -528,9 +655,16 @@ nodes get LLM-generated pin data). So:
|
||||||
static data** (`removeItemsSeenInPreviousExecutions`, `$getWorkflowStaticData`)
|
static data** (`removeItemsSeenInPreviousExecutions`, `$getWorkflowStaticData`)
|
||||||
is **not** seedable, because static data starts empty every run, so such a
|
is **not** seedable, because static data starts empty every run, so such a
|
||||||
scenario reds vacuously (it sees everything as "new"). To get a seedable
|
scenario reds vacuously (it sees everything as "new"). To get a seedable
|
||||||
change-detection scenario, steer the build toward a Data Table; otherwise
|
change-detection scenario, say "keep the state in a data table" in the prompt;
|
||||||
|
otherwise
|
||||||
accept the static-data red as a harness limit and carry the logic in
|
accept the static-data red as a harness limit and carry the logic in
|
||||||
`outcomeExpectations`. Note the agent may *choose* static-data dedup on its own.
|
`outcomeExpectations`. Note the agent may *choose* static-data dedup on its own.
|
||||||
|
- **Message an Agent runs the called Agent with its real model.** The harness
|
||||||
|
mocks the Agent's tools, MCP servers and web search, and records those calls
|
||||||
|
under the calling node. It turns off the Agent's memory, vector stores and chat
|
||||||
|
integrations. Only OpenAI models are supported today, and only when
|
||||||
|
`EVAL_OPENAI_API_KEY` is set (CI sets it): put the Agent on an `openai/*` model
|
||||||
|
and declare an `openAiApi` credential.
|
||||||
- Don't assert exact counts that depend on mock generation ("exactly 7 posts").
|
- Don't assert exact counts that depend on mock generation ("exactly 7 posts").
|
||||||
Say "fewer than the original 10".
|
Say "fewer than the original 10".
|
||||||
|
|
||||||
|
|
@ -624,8 +758,9 @@ Both are natural-language assertions graded by the same Sonnet judge, and each
|
||||||
They run everywhere, including prebuilt/MCP runs (no transcript needed).
|
They run everywhere, including prebuilt/MCP runs (no transcript needed).
|
||||||
- **`processExpectations`** — **how the agent behaved during the build**, judged
|
- **`processExpectations`** — **how the agent behaved during the build**, judged
|
||||||
from the transcript. Assert clarifying questions asked (or not re-asked),
|
from the transcript. Assert clarifying questions asked (or not re-asked),
|
||||||
tool-call behaviour, plan/approval handling, batching, honouring a correction,
|
user-visible behaviour, plan/approval handling, batching, honouring a
|
||||||
ordering. They need a transcript, so they're **skipped in prebuilt/MCP runs**.
|
correction, ordering. Do not assert internal mechanics such as sub-agents or
|
||||||
|
tool names (see "Keep expectations free of internal mechanics"). They need a transcript, so they're **skipped in prebuilt/MCP runs**.
|
||||||
|
|
||||||
Rule of thumb: an assertion about *the artifact* is an outcome expectation; an
|
Rule of thumb: an assertion about *the artifact* is an outcome expectation; an
|
||||||
assertion about *the conversation or the agent's choices along the way* is a
|
assertion about *the conversation or the agent's choices along the way* is a
|
||||||
|
|
@ -663,6 +798,54 @@ case, where the source and channel were **left unspecified**):
|
||||||
Put intent the conversation only *implied* (a preferred but unstated channel) in
|
Put intent the conversation only *implied* (a preferred but unstated channel) in
|
||||||
`processExpectations`, not `outcomeExpectations`.
|
`processExpectations`, not `outcomeExpectations`.
|
||||||
|
|
||||||
|
## Keep expectations free of internal mechanics
|
||||||
|
|
||||||
|
An expectation describes what the user or the artifact sees. It does not
|
||||||
|
describe how Instance AI is built inside. The internal architecture changes:
|
||||||
|
sub-agents, tool names, delegation, planning steps, and run ordering all move.
|
||||||
|
An expectation that names them goes red when the design changes, although the
|
||||||
|
behavior is still correct. It also stops proving the behavior: a build that
|
||||||
|
solves the problem by another route fails it.
|
||||||
|
|
||||||
|
**Do not name these in an expectation:**
|
||||||
|
|
||||||
|
- Sub-agents, delegation, or hand-off ("the sub-agent runs ...", "the
|
||||||
|
orchestrator delegates ...").
|
||||||
|
- Internal tool names or call counts ("calls `build-agent`", "calls
|
||||||
|
`search-nodes` twice").
|
||||||
|
- Internal stages, task lists, or step order that the user cannot see.
|
||||||
|
- Which component produced a result.
|
||||||
|
|
||||||
|
**Do name these:**
|
||||||
|
|
||||||
|
- What the user sees in the conversation: the question asked, the plan shown
|
||||||
|
for approval, the claim in the final response.
|
||||||
|
- What the artifact contains: the workflow or Agent, its configuration, and
|
||||||
|
how it behaves.
|
||||||
|
- A user-visible sequence, only when the user asked for it ("asks before it
|
||||||
|
builds").
|
||||||
|
|
||||||
|
Rewrite test. Delete the internal term. State the result the term produced.
|
||||||
|
|
||||||
|
| ❌ mechanical | ✅ intent |
|
||||||
|
|---|---|
|
||||||
|
| "The sub-agent runs the workflow before it reports success" | "The final response reports only results that the build verified; it does not claim an untested step works" |
|
||||||
|
| "The orchestrator calls `ask-user` before delegating" | "The agent asks for the missing Slack channel before it builds, and does not guess one" |
|
||||||
|
| "The builder calls `search-nodes` for the trigger" | "The workflow starts from a trigger that matches the requested schedule" |
|
||||||
|
|
||||||
|
Second test. Imagine the internals are replaced by one agent with different
|
||||||
|
tools. A correct build must still pass. If the expectation would fail or become
|
||||||
|
meaningless, rewrite it.
|
||||||
|
|
||||||
|
Some mechanics are a legitimate subject: a case whose purpose is to guard a
|
||||||
|
specific tool contract (for example, a regression in how a tool reports an
|
||||||
|
error). Keep these rare. State the reason in `description`. Do not mix them with
|
||||||
|
intent expectations in the same case.
|
||||||
|
|
||||||
|
**Calibration steps are not expectations.** Reading the transcript to confirm
|
||||||
|
that a build ran, or that a sub-agent was reached, is a good calibration check.
|
||||||
|
Keep it in your own run notes. Do not copy it into the case JSON.
|
||||||
|
|
||||||
## Robust design vs harness flakiness
|
## Robust design vs harness flakiness
|
||||||
|
|
||||||
Two different things — keep them apart:
|
Two different things — keep them apart:
|
||||||
|
|
@ -733,7 +916,10 @@ concluding whether the failure is your case, the build, or the harness.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd packages/@n8n/instance-ai
|
cd packages/@n8n/instance-ai
|
||||||
npx tsx -e "import {loadWorkflowTestCasesWithFiles} from './evaluations/data/workflows/index.ts'; console.log(loadWorkflowTestCasesWithFiles('<slug>')[0].fileSlug)"
|
pnpm exec tsx -e "import {loadWorkflowTestCasesWithFiles} from './evaluations/data/workflows/index.ts'; console.log(loadWorkflowTestCasesWithFiles('<slug>')[0].fileSlug)"
|
||||||
|
|
||||||
|
# For a standalone Agent case:
|
||||||
|
pnpm exec tsx -e "import {loadAgentEvalTestCasesWithFiles} from './evaluations/data/agents/index.ts'; console.log(loadAgentEvalTestCasesWithFiles('<slug>')[0].fileSlug)"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Push to a lang-tracer suite
|
## Push to a lang-tracer suite
|
||||||
|
|
@ -746,24 +932,32 @@ drifted, leaves the rest unchanged, and never prunes. It's the inverse of
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd packages/@n8n/instance-ai
|
cd packages/@n8n/instance-ai
|
||||||
# preview first — no writes (use `npx dotenvx`; the bare `dotenvx` binary is usually not on PATH):
|
# <suite> is the slug the driver chose (e.g. baseline)
|
||||||
npx dotenvx run -f .env.eval -- pnpm eval:langtracer-push --suite baseline --dry-run --changed
|
# preview first — no writes:
|
||||||
|
pnpm exec dotenvx run -f .env.eval -- pnpm eval:langtracer-push --suite <suite> --dry-run --changed
|
||||||
# then push (drop --dry-run):
|
# then push (drop --dry-run):
|
||||||
npx dotenvx run -f .env.eval -- pnpm eval:langtracer-push --suite baseline --changed
|
pnpm exec dotenvx run -f .env.eval -- pnpm eval:langtracer-push --suite <suite> --changed
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Selectors** (at least one required — no accidental push-all): positional
|
- **Selectors** (at least one required — no accidental push-all): positional
|
||||||
`<slugs...>` (exact file slugs), `--changed` (new/untracked + staged + modified
|
`<slugs...>` (exact file slugs), `--changed` (new/untracked + staged + modified
|
||||||
`data/workflows/*.json`, ideal right after authoring an uncommitted case),
|
`data/{workflows,agents}/*.json`, ideal right after authoring an uncommitted case),
|
||||||
`--filter`/`--tier` (with `--exclude` as a modifier).
|
`--filter`/`--tier` (with `--exclude` as a modifier).
|
||||||
|
- **Validation is selective.** Exact slugs and `--changed` read only the named
|
||||||
|
files, so an unrelated invalid file in `data/workflows` (a case authored on a
|
||||||
|
newer branch, a half-written draft) never blocks your push. `--filter` parses
|
||||||
|
only the files whose slug matches; `--tier` reads the tier from inside each
|
||||||
|
file, so it parses them all. An invalid file either one parses prints
|
||||||
|
`⚠ skipped invalid case file …` and the push continues without it. A file you
|
||||||
|
named still fails the push when it is invalid.
|
||||||
- **Multiple positional slugs? Skip pnpm — call the script directly.** `pnpm
|
- **Multiple positional slugs? Skip pnpm — call the script directly.** `pnpm
|
||||||
eval:langtracer-push … slugA slugB` forwards the slugs as one joined argument
|
eval:langtracer-push … slugA slugB` forwards the slugs as one joined argument
|
||||||
(`"slugA slugB"`), so no case file matches and nothing is pushed. Either use a
|
(`"slugA slugB"`), so no case file matches and nothing is pushed. Either use a
|
||||||
no-positional selector through pnpm (`--changed`), or run the script directly so
|
no-positional selector through pnpm (`--changed`), or run the script directly so
|
||||||
each slug is its own argv: `npx dotenvx run -f .env.eval -- npx tsx
|
each slug is its own argv: `pnpm exec dotenvx run -f .env.eval -- pnpm exec tsx
|
||||||
evaluations/cli/langtracer-push.ts --suite <slug> <slug1> <slug2> …`.
|
evaluations/cli/langtracer-push.ts --suite <slug> <slug1> <slug2> …`.
|
||||||
- **Env:** `LANGTRACER_URL` + `LANGTRACER_API_KEY` (an `lt_` bearer; one key works
|
- **Env:** `LANGTRACER_URL` + `LANGTRACER_API_KEY` (an `lt_` bearer; one key works
|
||||||
for MCP + REST) — put them in `.env.eval` and run under `npx dotenvx`.
|
for MCP + REST) — put them in `.env.eval` and run under `pnpm exec dotenvx`.
|
||||||
- **Options:** `--set-kind regression|capability_gap` (default `regression`, must
|
- **Options:** `--set-kind regression|capability_gap` (default `regression`, must
|
||||||
match the suite's kind), `--contains-user-data` (default is `synthetic`). A case
|
match the suite's kind), `--contains-user-data` (default is `synthetic`). A case
|
||||||
whose **build is correct** (outcome expectations green) but that carries a
|
whose **build is correct** (outcome expectations green) but that carries a
|
||||||
|
|
@ -833,8 +1027,9 @@ in *checkpoint* mode calibration this is how the driver opens the built thread
|
||||||
|
|
||||||
## Other eval harnesses (not this skill)
|
## Other eval harnesses (not this skill)
|
||||||
|
|
||||||
This skill is for `data/workflows/` cases. Three siblings exist with their own
|
Use the [`create-agent-builder-eval` skill](../create-agent-builder-eval/SKILL.md)
|
||||||
data dirs and CLIs: **`eval:subagent`** (workflow-build compatibility corpus,
|
for standalone Agent cases. Three other harnesses have their own data dirs and
|
||||||
|
CLIs: **`eval:subagent`** (workflow-build compatibility corpus,
|
||||||
binary-check scored), **`eval:discovery`** (asserts first-hop tool/dispatch
|
binary-check scored), **`eval:discovery`** (asserts first-hop tool/dispatch
|
||||||
routing, no n8n server), **`eval:pairwise`** (head-to-head build comparison vs
|
routing, no n8n server), **`eval:pairwise`** (head-to-head build comparison vs
|
||||||
`ai-workflow-builder.ee`). Authoring them is out of scope here — see the README
|
`ai-workflow-builder.ee`). Authoring them is out of scope here — see the README
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Case shapes beyond the plain build
|
# Case shapes beyond the plain build
|
||||||
|
|
||||||
The [SKILL](SKILL.md) covers the **build** archetype. This file covers the other
|
The [SKILL](SKILL.md) covers the **build** archetype. This file covers the other
|
||||||
three — **behaviour/process**, **credential**, **seeded** — plus the
|
four — **behaviour/process**, **credential**, **seeded**, **context** — plus the
|
||||||
director-note vocabulary multi-turn cases rely on. Field-level docs live in the
|
director-note vocabulary multi-turn cases rely on. Field-level docs live in the
|
||||||
eval [README](../../../packages/@n8n/instance-ai/evaluations/README.md); this is
|
eval [README](../../../packages/@n8n/instance-ai/evaluations/README.md); this is
|
||||||
the opinionated *how* and the traps.
|
the opinionated *how* and the traps.
|
||||||
|
|
@ -103,6 +103,7 @@ recognises this vocabulary:
|
||||||
| Dismiss a setup card / skip a value | `[When the setup card asks for the API base URL, dismiss it — the user hasn't decided yet.]` (proxy dismisses via `approve_or_reject(false)`) |
|
| Dismiss a setup card / skip a value | `[When the setup card asks for the API base URL, dismiss it — the user hasn't decided yet.]` (proxy dismisses via `approve_or_reject(false)`) |
|
||||||
| Reject a plan that misses a requirement | `[When the agent shows its plan, reject it unless it sorts descending by count.]` |
|
| Reject a plan that misses a requirement | `[When the agent shows its plan, reject it unless it sorts descending by count.]` |
|
||||||
| Iterate change-by-change, in order | `[Send each change below in order, waiting for the build after each; keep bundled changes in one message.]` |
|
| Iterate change-by-change, in order | `[Send each change below in order, waiting for the build after each; keep bundled changes in one message.]` |
|
||||||
|
| Run the workflow themselves and report back | `[When the agent asks you to test the workflow, run it yourself, then tell it you ran it.]` Set `allowUserExecution: true` on the case. The proxy then sets `runWorkflowId` to the intended saved workflow. The harness uses normal execution without mocks. This action supports credential-free manual or schedule workflows without pinned data. |
|
||||||
|
|
||||||
The `text` of a turn may be an **array of strings** (joined with newlines) so a
|
The `text` of a turn may be an **array of strings** (joined with newlines) so a
|
||||||
long director note stays readable in JSON. A note governs only what it covers;
|
long director note stays readable in JSON. A note governs only what it covers;
|
||||||
|
|
@ -567,6 +568,56 @@ it on a dev instance, fetch both, scrub, paste. Things worth knowing:
|
||||||
- **Requires the agents module.** A seeded agent restore fails loudly (as a
|
- **Requires the agents module.** A seeded agent restore fails loudly (as a
|
||||||
framework issue) on an instance where agents are disabled, rather than running
|
framework issue) on an instance where agents are disabled, rather than running
|
||||||
the case unseeded.
|
the case unseeded.
|
||||||
|
#### `folders` — "look at the ODW folder"
|
||||||
|
|
||||||
|
A folder case grades how the agent finds the contents of a folder the user names
|
||||||
|
(CONTEXT-86: the workflow list tool takes `folderPath` or `folderId`). Declare the
|
||||||
|
folders and place the seed workflows in them:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"seed": {
|
||||||
|
"mode": "inline",
|
||||||
|
"folders": [{ "id": "odwFolder0001", "name": "ODW" }],
|
||||||
|
"workflows": [
|
||||||
|
{ "id": "odwSignal1Wf", "name": "Odds Watch - 1", "parentFolderId": "odwFolder0001", "nodes": [], "connections": {} },
|
||||||
|
{ "id": "rootWorkflow1", "name": "Voice Agent", "nodes": [], "connections": {} }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Things worth knowing:
|
||||||
|
|
||||||
|
- **Leave decoys at the root.** A folder case is only informative when the folder's
|
||||||
|
contents differ from what a name search would return. Keep workflows outside the
|
||||||
|
folder, and pick names a `query` filter for the folder name would not match.
|
||||||
|
- **Grade the mechanism and the result.** One expectation for the `folderPath` or
|
||||||
|
`folderId` call, one for reporting exactly the folder's workflows, one for not asking
|
||||||
|
the user what the folder holds. The miss path (no folder exists) is a separate case:
|
||||||
|
LangTracer case 699 grades it, and it needs no `folders` slot.
|
||||||
|
- **Names are verbatim and leftovers are evicted**, like seeded projects. The live turn
|
||||||
|
names the folder, so the created name has to match exactly; a root folder of the same
|
||||||
|
name that existed before the run started is deleted before the restore, with every
|
||||||
|
workflow and subfolder in it. There is no seed marker on the name, so a same-named
|
||||||
|
folder a human made on that instance goes too: use an eval instance, and a name a
|
||||||
|
real project would not use. A previous iteration's folder, created during the run,
|
||||||
|
is left alone.
|
||||||
|
- **Run it alone.** A folder case and its miss-path sibling (case 699) share the
|
||||||
|
project, so one invocation per case. With several iterations the previous folder can
|
||||||
|
still be live for a few seconds while it is judged; keep the name distinctive.
|
||||||
|
- **Nesting works.** A folder's own `parentFolderId` names another seed folder. Parents
|
||||||
|
are created first. The `folderPath` for a nested folder is `Parent/Child`, so a folder
|
||||||
|
name cannot contain `/`.
|
||||||
|
- **Rules are checked at case load**: ids of at least 8 characters, unique; every
|
||||||
|
`parentFolderId` names a declared folder; no cycles; trimmed names that pass n8n's
|
||||||
|
folder-name rules; at most 20 folders.
|
||||||
|
- **Needs a licensed instance** (`feat:folders`) with
|
||||||
|
`N8N_INSTANCE_AI_FOLDER_EXPLORATION_ENABLED=true`. An unlicensed instance fails the
|
||||||
|
restore with a hint rather than running the case without its folder. Locally, after
|
||||||
|
`/rest/e2e/reset`: `PATCH /rest/e2e/feature {"feature":"feat:folders","enabled":true}`.
|
||||||
|
- **Keep it on disk for now.** The LangTracer case-write API does not store
|
||||||
|
`seed.folders` or `workflows[].parentFolderId`, so the push refuses the case until
|
||||||
|
`n8n-io/lang-tracer` adds both.
|
||||||
|
|
||||||
#### Which opening shape — the agent is handed the workflow, or it has to find it
|
#### Which opening shape — the agent is handed the workflow, or it has to find it
|
||||||
|
|
||||||
Two real conversations look the same in a case file but test different things, and
|
Two real conversations look the same in a case file but test different things, and
|
||||||
|
|
@ -611,6 +662,24 @@ really had one — and the agent has to guess from prose that deliberately names
|
||||||
nothing. It will list workflows and pick, or ask which one, and you will score a
|
nothing. It will list workflows and pick, or ask which one, and you will score a
|
||||||
clarification failure the real user never hit.
|
clarification failure the real user never hit.
|
||||||
|
|
||||||
|
#### Seeded faults must really fail
|
||||||
|
|
||||||
|
`seed.priorRuns[].hints` steer the mock for the staged run's outbound calls and
|
||||||
|
nothing else. The builder's own runs are never mocked, and Code, Set, IF, Filter
|
||||||
|
and Merge run for real. So:
|
||||||
|
|
||||||
|
- **The fault must fail in n8n.** A Code node that returns a plain object does not
|
||||||
|
fail; n8n wraps it as one item. Return an array of plain values, reference a
|
||||||
|
node that does not exist (`$('Missing')`), or throw.
|
||||||
|
- **The fault fires before any external call.** The builder's rerun reaches a
|
||||||
|
fixture host and dies there (DNS, 401), so a fault behind an HTTP node is never
|
||||||
|
reached. Never grade the rerun itself; grade the fix with `outcomeExpectations`
|
||||||
|
and the harness's `executionScenarios`.
|
||||||
|
- **An empty branch needs a Filter that keeps nothing.** Split Out over an empty
|
||||||
|
array still emits a placeholder item.
|
||||||
|
- **Walk the item flow before asserting a count.** A Slack node fed three items
|
||||||
|
posts three times.
|
||||||
|
|
||||||
#### Before you ship a seeded case — three checks
|
#### Before you ship a seeded case — three checks
|
||||||
|
|
||||||
1. **The defect still bites.** A seed whose workflow isn't broken any more makes the
|
1. **The defect still bites.** A seed whose workflow isn't broken any more makes the
|
||||||
|
|
@ -627,3 +696,139 @@ build". A seeded thread starts with an empty sandbox, so the agent re-reads the
|
||||||
workflow from the database and re-derives SDK source a real resumed session would
|
workflow from the database and re-derives SDK source a real resumed session would
|
||||||
still have on disk. The bias is *harder* than reality, so those numbers read worse
|
still have on disk. The bias is *harder* than reality, so those numbers read worse
|
||||||
for a reason that has nothing to do with the builder.
|
for a reason that has nothing to do with the builder.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Context cases (long conversations, token cost, compaction)
|
||||||
|
|
||||||
|
A context case asks whether the agent still works once the conversation is
|
||||||
|
long. Two questions, two mechanics.
|
||||||
|
|
||||||
|
### The judge already has the token numbers
|
||||||
|
|
||||||
|
Every case's judge context carries token ground truth, so no new field is
|
||||||
|
needed to grade cost:
|
||||||
|
|
||||||
|
- Each transcript turn header reads
|
||||||
|
`Turn 2 (3 steps, 47446 tokens in [41220 cached], 812 tokens out)`.
|
||||||
|
- A **Total** block sums every LLM step across the whole build, main run and
|
||||||
|
resumes, plus a cache read/write split and a **Fixed overhead** line — the
|
||||||
|
opening step's input, which is instructions and tool schemas plus one user
|
||||||
|
message, so it reads as the floor cost of any turn on that instance. Use it
|
||||||
|
to separate "the prompt got bigger" from "this conversation got expensive".
|
||||||
|
|
||||||
|
So `processExpectations` may reference consumption directly. Write them as
|
||||||
|
statements about *behaviour the numbers reveal*, not as thresholds:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"processExpectations": [
|
||||||
|
"The agent answers the second question without calling get_node_details on the Notion node again — it read that schema in turn 1 and the answer needs nothing new.",
|
||||||
|
"Turn 2's input tokens are mostly cache reads, which is what an unchanged prefix looks like. A turn that re-reads the history from scratch shows a cache-read share near zero."
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Absolute token budgets rot: a prompt edit moves every number and the case goes
|
||||||
|
red for a reason that has nothing to do with the agent. Grade the *shape* —
|
||||||
|
what got re-read, what came from cache, which turn is the expensive one.
|
||||||
|
|
||||||
|
Two limits to know before you write a cost expectation:
|
||||||
|
|
||||||
|
- It needs `N8N_INSTANCE_AI_RUN_DEBUG_ENABLED=true` on the instance under test.
|
||||||
|
Without it the blocks render `(no run debug captured)` and the expectation is
|
||||||
|
unjudgeable — it fails or passes at random.
|
||||||
|
- The capture hooks **only the orchestrator's own stream**. A workflow build
|
||||||
|
runs inside that loop, so a workflow case's numbers are its real cost. A
|
||||||
|
delegated **Agent** build (the `build-agent` tool) runs on a separate stream
|
||||||
|
with no hooks, so its tokens are missing from every block. Don't write a cost
|
||||||
|
expectation on an `data/agents/` case.
|
||||||
|
|
||||||
|
### `requiresMemoryCompaction` — grade the post-compaction window
|
||||||
|
|
||||||
|
Observational memory compacts a long thread: an Observer summarises it into
|
||||||
|
observation rows, the summary is rendered into the system prompt, and the early
|
||||||
|
turns are masked out of the agent's window. A case that tests whether a decision
|
||||||
|
*survives* that has a setup problem — production compacts at 30k tokens of
|
||||||
|
visible message content, which is a conversation too long to hand-author.
|
||||||
|
|
||||||
|
Set the flag and the harness handles it:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"requiresMemoryCompaction": true
|
||||||
|
```
|
||||||
|
|
||||||
|
Two things happen, both per-thread, so no other case in the run is affected:
|
||||||
|
|
||||||
|
1. The harness sends a low observer threshold with every turn of that thread
|
||||||
|
only: **1,000 tokens** of visible message content, the request field's floor.
|
||||||
|
The seed plus the live turns must cross it, or the observer never runs — a
|
||||||
|
short seed does not test memory, it reports **not judged** (below). Size the
|
||||||
|
seed generously; a few real turns of tool output cross 1,000 tokens easily.
|
||||||
|
The Observer's prompt, masking and cursor logic are the production ones at
|
||||||
|
any threshold.
|
||||||
|
2. After the build, the harness checks the premise actually held. If it did
|
||||||
|
not, every expectation on the case is reported **not judged** — an
|
||||||
|
`incomplete` verdict, excluded from scoring, not a red.
|
||||||
|
|
||||||
|
The premise check is the point of the flag. Uncompacted, the raw early turns
|
||||||
|
are still in the window, so the agent answers off them and every expectation
|
||||||
|
passes for free — a green that tests nothing.
|
||||||
|
|
||||||
|
The evidence is structural. `GET /rest/instance-ai/eval/threads/:threadId/memory`
|
||||||
|
returns the observation rows and the compaction cursor from their own tables. A
|
||||||
|
cursor means the observer ran and everything up to `lastObservedMessageId` is
|
||||||
|
masked out; the rows are what replaced it. Missing either, the case had nothing
|
||||||
|
to test and is reported not judged. Nothing reads the system prompt, so this
|
||||||
|
needs **no debug flag** and a prompt or SDK rename cannot quietly turn "never
|
||||||
|
compacted" into the answer.
|
||||||
|
|
||||||
|
The judge never sees the premise check — it grades the conversation, not whether
|
||||||
|
the harness configured the scenario. A misconfigured lane must not read as a
|
||||||
|
quality regression.
|
||||||
|
|
||||||
|
### Grade the summary, not just the reply
|
||||||
|
|
||||||
|
The judge *does* see the observation rows, as ground truth:
|
||||||
|
|
||||||
|
```
|
||||||
|
## Observational memory after compaction (ground truth — do not recount)
|
||||||
|
|
||||||
|
- [CRITICAL] User ruled OUT the native Slack node; will post through the HTTP
|
||||||
|
Request node instead, because the workspace is pinned to a legacy Slack API
|
||||||
|
version. Do not revisit.
|
||||||
|
- [CRITICAL] Alert fires when queue depth goes above 4700 items.
|
||||||
|
```
|
||||||
|
|
||||||
|
So write expectations at **both** layers:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"processExpectations": [
|
||||||
|
"The observational-memory block retains the alert threshold as 4700 queued items. A summary that keeps the topic but loses the number is the specific failure this looks for.",
|
||||||
|
"In its reply to the final turn, the agent gives the alert threshold as 4700 queued items."
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
The first grades the memory system, the second grades the agent. Grading only
|
||||||
|
the reply is weaker than it looks: the agent can answer correctly from the
|
||||||
|
unmasked tail, or guess well, and the case goes green while memory dropped the
|
||||||
|
detail. The `[MARKER]` is the Observer's own priority label, so "retained as
|
||||||
|
CRITICAL" is checkable too.
|
||||||
|
|
||||||
|
### Writing the conversation
|
||||||
|
|
||||||
|
The shape that makes a compaction case real:
|
||||||
|
|
||||||
|
1. **State the anchors once, in a `user` turn near the start of the seed**, and
|
||||||
|
never restate them. Anything the agent repeats later lands *after* the
|
||||||
|
cursor and survives for the wrong reason.
|
||||||
|
2. **Make live turn 1 off-topic.** Its answer must not re-surface the anchors
|
||||||
|
into the post-cursor window. Compaction runs at the end of it.
|
||||||
|
3. **Ask for the anchors back in live turn 2.** That turn runs against the
|
||||||
|
compacted context.
|
||||||
|
4. **Force the antecedent** — a lost anchor must produce a *confident wrong*
|
||||||
|
answer, not a vague one. "Posting goes through HTTP Request, not the native
|
||||||
|
Slack node" works because the Slack node is the obvious guess. "The
|
||||||
|
threshold is 4700" works because a guess reaches for 5000. See
|
||||||
|
[negative expectations need a forced antecedent](SKILL.md#core-principle-all-shapes).
|
||||||
|
|
||||||
|
Tag these `context-consumption` and put them in a `context` dataset, so a
|
||||||
|
tier that needs run debug enabled can select them.
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,44 @@ deliberately does not re-sync tier-only edits to an existing case. **Only
|
||||||
promote to `pr` after `--iterations 5+` shows it's reliably green** — a flaky
|
promote to `pr` after `--iterations 5+` shows it's reliably green** — a flaky
|
||||||
case in the gate poisons it.
|
case in the gate poisons it.
|
||||||
|
|
||||||
|
## Calibrating a batch of new cases on the dispatchers
|
||||||
|
|
||||||
|
One case costs 10–20 minutes per iteration on a laptop, and docker lanes have
|
||||||
|
crashed it. A batch calibrates on the LangTracer dispatchers:
|
||||||
|
|
||||||
|
1. Author the JSON locally. Static checks only: a `--dry-run` push (schema) and
|
||||||
|
the similarity check against the verification suites.
|
||||||
|
2. Push the batch to its suite with the tag `calibration-pending`.
|
||||||
|
3. Dispatch one manual sweep for those case ids:
|
||||||
|
`gh workflow run eval-run.yml --repo n8n-io/lang-tracer -f image=n8nio/n8n:nightly -f case_ids=<ids> -f iterations=3 -f trigger=manual`.
|
||||||
|
`trigger=manual` keeps it out of the nightly baseline.
|
||||||
|
4. Read `list_eval_runs` → `get_eval_run`. Classify each red: **builder** (keep
|
||||||
|
it red, tag `capability-gap-finding`, propose a ticket), **harness** (fix it or
|
||||||
|
design around it; never leave it to charge the model), **authoring** (fix the
|
||||||
|
case).
|
||||||
|
5. Re-push the fixed cases and re-dispatch only those ids.
|
||||||
|
6. Swap `calibration-pending` for `calibrated` and stamp the evidence into the
|
||||||
|
description, e.g. "Calibration (Opus 4.8, N=3): sweep 174 3/4, sweep 176 4/4".
|
||||||
|
|
||||||
|
## Validating a harness change before merge
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gh workflow run test-evals-instance-ai.yml --repo n8n-io/n8n \
|
||||||
|
-f branch=<your-branch> -f cache-sha=$(git rev-parse origin/<your-branch>) \
|
||||||
|
-f suite=<suite> -f filter=<slug-substrings> \
|
||||||
|
-f iterations=3 -f experiment-name=<change-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
`cache-sha` is what puts a backend change under test: without it the workflow
|
||||||
|
restores the n8n image cached for master's head, and only the eval CLI runs from
|
||||||
|
your branch. A harness-only change works either way.
|
||||||
|
|
||||||
|
CI reads cases from LangTracer only. A case that exists only on disk goes into a
|
||||||
|
throwaway suite first (`eval:langtracer-push --suite <scratch-suite> <slug>`).
|
||||||
|
Never pass `experiment-name=instance-ai-baseline`; that name refreshes the shared
|
||||||
|
baseline. Results: the run log's summary table and the
|
||||||
|
`instance-ai-workflow-eval-results` artifact (`eval-results.json` + HTML report).
|
||||||
|
|
||||||
## Baselines & regression
|
## Baselines & regression
|
||||||
|
|
||||||
When `LANGSMITH_API_KEY` is set, every run auto-compares against the most recent
|
When `LANGSMITH_API_KEY` is set, every run auto-compares against the most recent
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,20 @@ ids. Full table in
|
||||||
1. **Scan cluster themes** — `list_cluster_runs` / `get_latest_cluster_run`
|
1. **Scan cluster themes** — `list_cluster_runs` / `get_latest_cluster_run`
|
||||||
return capability-gap themes with a `label`, `summary`, and `mechanism`: the
|
return capability-gap themes with a `label`, `summary`, and `mechanism`: the
|
||||||
real, recurring failure modes.
|
real, recurring failure modes.
|
||||||
2. **Pull the conversations** — `list_conversations` (e.g. `verdict:"bad"`,
|
2. **Pull the conversations.** Start from what LangTracer already detected.
|
||||||
`analyzed:"yes"`) → `get_conversation` (raw trace) + `get_conversation_analysis`
|
`list_signal_rates` lists every code check and label rule with its rate over a
|
||||||
(findings). `get_linear_ticket_context` links a thread to its ticket. To target
|
window: what fails most right now. Then `list_conversations` with `signals`,
|
||||||
|
one token per signal, ANDed — `check:has_nodes`,
|
||||||
|
`label:task_outcome=agent-gave-up`, `analysis:bad`, `keeper:*`, `review:*` — puts
|
||||||
|
the matching entries on each row, each with its evidence (the verdict comment,
|
||||||
|
the judge's words, Keeper's reason) and its version. On a candidate,
|
||||||
|
`get_conversation_signals` shows what every source said and which ones agreed:
|
||||||
|
a thread flagged by a code check, the judge and Keeper is a stronger source
|
||||||
|
than one flagged by a single model pass. A source marked `not_run` never looked
|
||||||
|
at the thread, so read its silence as unknown, not as clean. The older path
|
||||||
|
still works: `list_conversations` (e.g. `verdict:"bad"`, `analyzed:"yes"`) →
|
||||||
|
`get_conversation` (raw trace) + `get_conversation_analysis` (findings).
|
||||||
|
`get_linear_ticket_context` links a thread to its ticket. To target
|
||||||
**execution failures**, add `funnelDrop:"05"` (built + launched an execution
|
**execution failures**, add `funnelDrop:"05"` (built + launched an execution
|
||||||
that never *succeeded*). **Caveat: the funnel drop is a *conversion* signal, not
|
that never *succeeded*). **Caveat: the funnel drop is a *conversion* signal, not
|
||||||
a build-quality one** — most `funnelDrop:"05"` threads are healthy builds that
|
a build-quality one** — most `funnelDrop:"05"` threads are healthy builds that
|
||||||
|
|
@ -61,7 +72,8 @@ ids. Full table in
|
||||||
(was `build-workflow` called on this turn?), which it reads reliably — but a
|
(was `build-workflow` called on this turn?), which it reads reliably — but a
|
||||||
content-dependent claim ("invented ID", "missing node") can be wrong when it
|
content-dependent claim ("invented ID", "missing node") can be wrong when it
|
||||||
couldn't see the built workflow. Confirm against the raw trace before building
|
couldn't see the built workflow. Confirm against the raw trace before building
|
||||||
a case around it.
|
a case around it. The same goes for a signal's `evidence`: it is what that
|
||||||
|
source saw, not the trace.
|
||||||
4. **Optionally record the selection as an observation.** Offer to save why this
|
4. **Optionally record the selection as an observation.** Offer to save why this
|
||||||
thread was selected and what the developer observed. This is a best-effort
|
thread was selected and what the developer observed. This is a best-effort
|
||||||
LangTracer note, not a gate: skip it when the developer declines or has not
|
LangTracer note, not a gate: skip it when the developer declines or has not
|
||||||
|
|
@ -70,7 +82,12 @@ ids. Full table in
|
||||||
5. **Encode a durable synthetic case** — turn the confirmed failure into an
|
5. **Encode a durable synthetic case** — turn the confirmed failure into an
|
||||||
authored case ([SKILL.md](SKILL.md), [`case-shapes.md`](case-shapes.md)). The
|
authored case ([SKILL.md](SKILL.md), [`case-shapes.md`](case-shapes.md)). The
|
||||||
failure mode is the anchor; the conversation is yours to write, in the user's
|
failure mode is the anchor; the conversation is yours to write, in the user's
|
||||||
voice.
|
voice. **Write down the precondition, not just the failure mode** — the state
|
||||||
|
the thread was in when the call went wrong, which is usually narrower than the
|
||||||
|
theme label suggests and is often stated outright in the assistant text just
|
||||||
|
before the failing call. Get this wrong and the case grades green because it
|
||||||
|
never set the situation up; see
|
||||||
|
[First reproduce, then reclassify](SKILL.md#first-reproduce-then-reclassify).
|
||||||
6. **Push it to a curated suite** (don't commit the JSON) with
|
6. **Push it to a curated suite** (don't commit the JSON) with
|
||||||
`eval:langtracer-push` — see
|
`eval:langtracer-push` — see
|
||||||
[Push to a lang-tracer suite](SKILL.md#push-to-a-lang-tracer-suite). An `inline`
|
[Push to a lang-tracer suite](SKILL.md#push-to-a-lang-tracer-suite). An `inline`
|
||||||
|
|
@ -305,14 +322,17 @@ what catch a clean-up that kept the shape but lost the point.
|
||||||
|
|
||||||
You don't need to do these by hand:
|
You don't need to do these by hand:
|
||||||
|
|
||||||
- **Credential references on nodes are dropped as the seed loads.** The case's own
|
- **Credential references on nodes resolve against the case's `credentials[]` as the
|
||||||
`credentials[]` decides what the assistant can see, and a credential's display name
|
seed loads.** A reference is kept only when exactly one seeded credential has that
|
||||||
goes with the reference.
|
type and display name; any other reference is dropped. On a `published: true`
|
||||||
|
workflow an unresolved reference fails the restore instead.
|
||||||
- **Data tables are columns only.** The seed format has no place for rows, and a
|
- **Data tables are columns only.** The seed format has no place for rows, and a
|
||||||
`rows` key is rejected rather than quietly removed — so table contents can't come
|
`rows` key is rejected rather than quietly removed — so table contents can't come
|
||||||
along by accident.
|
along by accident.
|
||||||
- **A seed workflow is only `id`, `name`, `nodes` and `connections`.** Pinned example
|
- **A seed workflow is only `id`, `name`, `nodes`, `connections` and an optional
|
||||||
data, instance metadata and settings never travel.
|
`published` flag.** `published: true` activates the workflow on restore, the way the
|
||||||
|
user's publish left it. Pinned example data, instance metadata and settings never
|
||||||
|
travel.
|
||||||
- **Ids and workflow names are per run.** Ids are replaced with fresh ones and names
|
- **Ids and workflow names are per run.** Ids are replaced with fresh ones and names
|
||||||
get a `[seed <8hex>]` suffix, with mentions updated in the prose — though not inside
|
get a `[seed <8hex>]` suffix, with mentions updated in the prose — though not inside
|
||||||
node definitions or recorded tool calls.
|
node definitions or recorded tool calls.
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ Creates GitHub PRs with titles that pass n8n's `check-pr-title` CI validation.
|
||||||
- `benchmark` - Benchmark CLI changes
|
- `benchmark` - Benchmark CLI changes
|
||||||
- `core` - Core/backend/private API
|
- `core` - Core/backend/private API
|
||||||
- `editor` - Editor UI changes
|
- `editor` - Editor UI changes
|
||||||
- `engine` - New workflow execution engine v2 (@n8n/engine package)
|
- `engine` - New workflow execution engine v2 (@n8n/engine package & engine-v2 module in cli)
|
||||||
- `* Node` - Specific node (e.g., `Slack Node`, `GitHub Node`)
|
- `* Node` - Specific node (e.g., `Slack Node`, `GitHub Node`)
|
||||||
|
|
||||||
### Summary Rules
|
### Summary Rules
|
||||||
|
|
@ -43,7 +43,7 @@ Creates GitHub PRs with titles that pass n8n's `check-pr-title` CI validation.
|
||||||
- Capitalize first letter
|
- Capitalize first letter
|
||||||
- No period at the end
|
- No period at the end
|
||||||
- No ticket IDs (e.g., N8N-1234)
|
- No ticket IDs (e.g., N8N-1234)
|
||||||
- Add `(no-changelog)` suffix to exclude from changelog
|
- Add `(no-changelog)` suffix to exclude from changelog, unless the type already excludes it
|
||||||
|
|
||||||
## Steps
|
## Steps
|
||||||
|
|
||||||
|
|
@ -78,11 +78,24 @@ Creates GitHub PRs with titles that pass n8n's `check-pr-title` CI validation.
|
||||||
body structure, then populate each section with actual content before
|
body structure, then populate each section with actual content before
|
||||||
creating the PR:
|
creating the PR:
|
||||||
- **Summary**: describe what the PR does
|
- **Summary**: describe what the PR does
|
||||||
|
- **Why**: explain why the change is needed (see Why below)
|
||||||
- **How to test**: describe how to test the changes. Include an example workflow if appropriate
|
- **How to test**: describe how to test the changes. Include an example workflow if appropriate
|
||||||
- **Related tickets**: add the Linear ticket URL (`https://linear.app/n8n/issue/[TICKET-ID]`) and any GitHub issue links
|
- **Related tickets**: add the Linear ticket URL (`https://linear.app/n8n/issue/[TICKET-ID]`) and any GitHub issue links
|
||||||
- **Checklist**: keep as-is from the template
|
- **Checklist**: keep as-is from the template
|
||||||
- Add a "🤖 PR Summary generated by AI" at the end of the body
|
- Add a "🤖 PR Summary generated by AI" at the end of the body
|
||||||
|
|
||||||
|
Before you create the PR, proofread the body with these checks. Rewrite
|
||||||
|
each sentence that fails a check:
|
||||||
|
1. The Summary and the Why together are under the word budget. If not,
|
||||||
|
first remove the details that the reviewer reads in the diff, then
|
||||||
|
shorten the Why.
|
||||||
|
2. Each sentence names who does what: a component, a process, or a person
|
||||||
|
as the subject, with a plain technical verb.
|
||||||
|
3. Each domain term has a plain definition where it first appears.
|
||||||
|
4. Each sentence is true for the diff.
|
||||||
|
|
||||||
|
When a later commit changes a fact in the body, update the body.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gh pr create --draft --title "<type>(<scope>): <summary>" --body "$(cat <<'EOF'
|
gh pr create --draft --title "<type>(<scope>): <summary>" --body "$(cat <<'EOF'
|
||||||
<populated body based on pull_request_template.md>
|
<populated body based on pull_request_template.md>
|
||||||
|
|
@ -94,12 +107,43 @@ Creates GitHub PRs with titles that pass n8n's `check-pr-title` CI validation.
|
||||||
|
|
||||||
Based on `.github/pull_request_template.md`:
|
Based on `.github/pull_request_template.md`:
|
||||||
|
|
||||||
Write the PR body in ASD-STE100 Simplified Technical English: use short
|
Write for a reviewer who does not know this area of the code. The reviewer
|
||||||
sentences, the active voice, and one instruction for each sentence.
|
must understand the change before they open the diff. Use ASD-STE100
|
||||||
|
Simplified Technical English: short sentences, active voice.
|
||||||
|
1. Keep the Summary and the Why together under about 200 words. A small PR
|
||||||
|
needs much less.
|
||||||
|
2. Define each domain term in plain words where it first appears. Do not use
|
||||||
|
a ticket ID or an internal name as an explanation.
|
||||||
|
3. Leave out details that the reviewer reads in the diff: error cases, status
|
||||||
|
codes, renamed fields, the order of calls, file lists, test names. Mention
|
||||||
|
one only when it changes behaviour that a reviewer could miss. Also leave
|
||||||
|
out what reviewers already know (framework behaviour).
|
||||||
|
4. Use plain technical verbs, not metaphors ("passes the value", not
|
||||||
|
"hands the value" or "lets the value through").
|
||||||
|
|
||||||
### Summary Section
|
### Summary: what the PR does
|
||||||
- Describe what the PR does
|
1. Start with one to three sentences of background for a reader who is new to
|
||||||
- Include screenshots/videos for UI changes
|
the area. Then state what the PR does.
|
||||||
|
2. Write **prose** about behaviour, not a list of code edits. Name a class or
|
||||||
|
a function when it represents an essential/core concept and it helps
|
||||||
|
the reader to navigate the change.
|
||||||
|
3. If the PR changes no product code, say so in the first sentence
|
||||||
|
(for example: "This PR only adds tests.").
|
||||||
|
4. Do not justify the change here. The justification goes in the Why.
|
||||||
|
5. Include screenshots or videos for UI changes.
|
||||||
|
|
||||||
|
### Why: the reasoning
|
||||||
|
Always fill the `## Why` section. The Summary and the core of the
|
||||||
|
Why are what the reviewer needs most. Keep the core short:
|
||||||
|
1. Do not repeat the Summary.
|
||||||
|
2. State the problem or the constraint that makes the pre-existing code unfit.
|
||||||
|
3. If there are accepted gaps, or changes for existing code paths, state them
|
||||||
|
in a separate short paragraph.
|
||||||
|
|
||||||
|
Add rejected alternatives only when a reviewer would otherwise ask about them,
|
||||||
|
if any. Use one or two sentences for each alternative: state the concrete
|
||||||
|
reason it fails. Write an alternative that was never built in the conditional.
|
||||||
|
Together, the alternatives must be shorter than the core Why section.
|
||||||
|
|
||||||
### How to test Section
|
### How to test Section
|
||||||
- Explain how to test the changes
|
- Explain how to test the changes
|
||||||
|
|
@ -147,7 +191,7 @@ feat(API)!: Remove deprecated v1 endpoints
|
||||||
|
|
||||||
### No changelog entry
|
### No changelog entry
|
||||||
```
|
```
|
||||||
refactor(core): Simplify error handling (no-changelog)
|
feat(core): Experimental feature not enabled yet (no-changelog)
|
||||||
```
|
```
|
||||||
|
|
||||||
### No scope (affects multiple areas)
|
### No scope (affects multiple areas)
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ Run through this before requesting review. Each item is a real, recurring review
|
||||||
- [ ] Identifiers go through **`escape.tableName(...)` / `escape.columnName(...)`**. Never hand-write `n8n_table` prefixes. — [Always escape identifiers](#always-escape-identifiers)
|
- [ ] Identifiers go through **`escape.tableName(...)` / `escape.columnName(...)`**. Never hand-write `n8n_table` prefixes. — [Always escape identifiers](#always-escape-identifiers)
|
||||||
- [ ] **Match column type to value semantics.** Native `uuid` for UUIDs, `timestampTimezone()` for timestamps, a numeric type for numbers, `bool` for booleans, `json` for structured data. Never `varchar` as a catch-all. — [Column types](#column-types)
|
- [ ] **Match column type to value semantics.** Native `uuid` for UUIDs, `timestampTimezone()` for timestamps, a numeric type for numbers, `bool` for booleans, `json` for structured data. Never `varchar` as a catch-all. — [Column types](#column-types)
|
||||||
- [ ] **Pick the narrowest sane type within that category:** `int`/`smallint` not `bigint` when range allows; `text` not `varchar(255)` for unbounded strings; never `double` for version numbers. — [Column types](#column-types)
|
- [ ] **Pick the narrowest sane type within that category:** `int`/`smallint` not `bigint` when range allows; `text` not `varchar(255)` for unbounded strings; never `double` for version numbers. — [Column types](#column-types)
|
||||||
|
- [ ] **A generated `id` key is an integer** (`int.primary.autoGenerate2`). A UUID key is a UUIDv7. For a UUID or string key, write the reason in the PR description. A join table uses its foreign-key columns as the key, not an `id` column. — [Primary Keys](#primary-keys)
|
||||||
- [ ] **Default `notNull`**, relax only when justified. PK is implicitly NOT NULL. Migration's `notNull` matches the entity's nullability. — [NOT NULL and entity parity](#not-null-and-entity-parity)
|
- [ ] **Default `notNull`**, relax only when justified. PK is implicitly NOT NULL. Migration's `notNull` matches the entity's nullability. — [NOT NULL and entity parity](#not-null-and-entity-parity)
|
||||||
- [ ] **Enum-like columns** carry `.withEnumCheck([...])` AND `.comment('explains values')`. Opaque IDs / unix timestamps / JSON shapes also get `.comment()`. — [Constrain enum-like strings](#constrain-enum-like-strings), [Add comments on columns](#add-comments-on-columns)
|
- [ ] **Enum-like columns** carry `.withEnumCheck([...])` AND `.comment('explains values')`. Opaque IDs / unix timestamps / JSON shapes also get `.comment()`. — [Constrain enum-like strings](#constrain-enum-like-strings), [Add comments on columns](#add-comments-on-columns)
|
||||||
- [ ] **Every reference column has an explicit FK** with deliberate `onDelete`. Name FKs explicitly when SQLite recreate cycles risk duplicating them. Avoid polymorphic `(typeCol, idCol)` patterns. — [Foreign Key Constraints](#foreign-key-constraints), [General Design Guidance](#general-design-guidance)
|
- [ ] **Every reference column has an explicit FK** with deliberate `onDelete`. Name FKs explicitly when SQLite recreate cycles risk duplicating them. Avoid polymorphic `(typeCol, idCol)` patterns. — [Foreign Key Constraints](#foreign-key-constraints), [General Design Guidance](#general-design-guidance)
|
||||||
|
|
@ -439,11 +440,32 @@ Don't set the default of a `status` column to a terminal value — `"running"` m
|
||||||
|
|
||||||
### Primary Keys
|
### Primary Keys
|
||||||
|
|
||||||
Every table needs a primary key. Choose the type in this order:
|
Every table needs a primary key. **Use an integer key by default.** Read the options below in order. Use the first option that fits. Do not skip an option only because you like a later one better.
|
||||||
|
|
||||||
1. **Integer** — `column('id').int.primary.autoGenerate2`. Preferred for new tables: compact, fast joins, no ordering surprises. `autoGenerate2` uses Postgres `IDENTITY` (preferred over the deprecated `serial`-based `autoGenerate`).
|
1. **Integer (default)** — `column('id').int.primary.autoGenerate2`. Use this for every new table. Use a different option only when one of its conditions is true. Integer keys are small and make joins fast. `autoGenerate2` uses Postgres `IDENTITY`. Do not use `autoGenerate`. It uses `serial`, which is deprecated.
|
||||||
2. **UUID** — `column('id').uuid.primary`. Use when IDs are generated client-side, exposed in URLs, or need to be unguessable. Generate UUIDs in application code via `randomUUID()` from `node:crypto`; do **not** chain `.autoGenerate2` on `.uuid` (the DSL throws — `DEFAULT uuid_generate_v4()` fails on managed Postgres like Supabase because it needs the `uuid-ossp` extension in `public`). Use `.uuid` instead of `.varchar(36)`.
|
2. **UUID** — `column('id').uuid.primary`. Use this only when one of these conditions is true:
|
||||||
3. **String** — `column('id').varchar(36).primary` for IDs whose format isn't a UUID (e.g. nanoid-style IDs). Convention: nanoid length 16 for entity IDs.
|
- The application must know the ID before the insert. For example, the client makes the ID.
|
||||||
|
- The ID is in a URL or a public API. Users must not see how many rows exist or guess other IDs.
|
||||||
|
|
||||||
|
**You must use UUIDv7.** Make the ID in application code with the `uuid` package: `import { v7 as uuidv7 } from 'uuid'`.
|
||||||
|
|
||||||
|
Why: a UUIDv7 starts with a timestamp. Thus, new rows go near the end of the index. A UUIDv4 is random, for example `randomUUID()` from `node:crypto`. New rows go to random positions in the index. This splits index pages and makes the index larger.
|
||||||
|
|
||||||
|
A UUIDv7 does not give an exact creation order. Two IDs made in the same millisecond can sort in the wrong order. Clock differences between hosts can also cause this. If you need the exact order, sort by a timestamp column.
|
||||||
|
|
||||||
|
Do **not** chain `.autoGenerate2` on `.uuid`. The DSL throws an error. The database default makes a UUIDv4. Also, `uuid_generate_v4()` needs the `uuid-ossp` extension. Some managed Postgres services, such as Supabase, do not have it. Use `.uuid`, not `.varchar(36)`.
|
||||||
|
3. **String** — `column('id').varchar(36).primary`. Use this only when one of these conditions is true:
|
||||||
|
- The entity already uses IDs in a format that is not a UUID. For example, the public API or the UI already shows nanoid IDs for this entity.
|
||||||
|
- The UI shows the ID to users. A UUID is too long to read, copy, or type.
|
||||||
|
|
||||||
|
Entity IDs are usually nanoids with 16 characters.
|
||||||
|
|
||||||
|
**Give a reason for every key that is not an integer.** Write the reason in the PR description. Reviewers will ask for it. These reasons are not sufficient:
|
||||||
|
- "Other tables use string IDs."
|
||||||
|
- "This module already does it this way."
|
||||||
|
- "We might need it later."
|
||||||
|
|
||||||
|
**These options apply to a generated `id` column only.** A join table that only links other tables does not need an `id` column. Use its foreign-key columns as a composite key (see below). A foreign-key column always has the same type as the key that it refers to.
|
||||||
|
|
||||||
**Keep ID-column types consistent across related tables.** Mixing `uuid` and `varchar(36)` for what is "the same kind of ID" creates JOIN footguns.
|
**Keep ID-column types consistent across related tables.** Mixing `uuid` and `varchar(36)` for what is "the same kind of ID" creates JOIN footguns.
|
||||||
|
|
||||||
|
|
@ -696,7 +718,7 @@ If only Postgres needs the change, just put the file in `postgresdb/`; don't wri
|
||||||
|
|
||||||
### Postgres-version-aware UUID generation
|
### Postgres-version-aware UUID generation
|
||||||
|
|
||||||
`gen_random_uuid()` requires Postgres ≥ 13. n8n dropped Postgres 12 — prefer it over `uuid_generate_v4()` (which needs the `uuid-ossp` extension and breaks on managed services like Supabase). For UUID PKs, generate at the application level with `randomUUID()` — see [Primary Keys](#primary-keys).
|
`gen_random_uuid()` requires Postgres ≥ 13. n8n dropped Postgres 12 — prefer it over `uuid_generate_v4()` (which needs the `uuid-ossp` extension and breaks on managed services like Supabase). For UUID PKs, make a UUIDv7 in application code — see [Primary Keys](#primary-keys).
|
||||||
|
|
||||||
### SQLite doesn't enforce `varchar(N)` length
|
### SQLite doesn't enforce `varchar(N)` length
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
---
|
|
||||||
name: n8n:design-system
|
|
||||||
description: Guidelines on using Design System styles and components. Use when working on .vue files in packages/frontend. Triggers for tasks that include component architecture, styling, UI changes, or feature work.
|
|
||||||
---
|
|
||||||
|
|
||||||
# Design System
|
|
||||||
|
|
||||||
Comprehensive guide for building, styling, and using components in the frontend.
|
|
||||||
|
|
||||||
## When to Apply
|
|
||||||
Reference these guidelines when:
|
|
||||||
- Working on `.{vue|css|scss}` files in `packages/frontend`
|
|
||||||
- Adding new components to `packages/frontend/@n8n/design-system`
|
|
||||||
- Refactoring styles for Vue components
|
|
||||||
- Implementing new UI components or features
|
|
||||||
- Reviewing changes to UI
|
|
||||||
|
|
||||||
## Rules
|
|
||||||
- Follow guidelines in `packages/frontend/@n8n/design-system/src/styleguide/*.mdx`
|
|
||||||
- ALWAYS use CSS variables for styles from `packages/frontend/@n8n/design-system/src/css/_tokens.scss` or `packages/frontend/@n8n/design-system/src/css/_primitives.scss`. Use hard-coded values only when no suitable tokens.
|
|
||||||
- ALWAYS prefer using existing components from `packages/frontend/@n8n/design-system/src/components`. Prefer components that aren't marked `@deprecated`.
|
|
||||||
- Use `light-dark()` when alternating colors for ligh/dark mode
|
|
||||||
- If you need to add hover/active alpha behavior to solid components, prefer `color-mix()` with explicit percentages.
|
|
||||||
- When working with animations or transitions, ALWAYS prefer using mixins from `packages/frontend/@n8n/design-system/src/css/mixins/motion.scss`
|
|
||||||
- When reviewing animations, follow the guides in `rules/web-animation-guidelines.md`
|
|
||||||
- When reviewing UI changes or adding new components, follow `rules/web-interface-guidelines.md`
|
|
||||||
|
|
||||||
## Storybook Stories
|
|
||||||
|
|
||||||
- ALWAYS add new stories to `packages/frontend/@n8n/design-system`.
|
|
||||||
- Every story must use one of these title categories:
|
|
||||||
- `Style Guide`: styles, tokens, and utilities
|
|
||||||
- `Core`: components used across the app
|
|
||||||
- `Areas/<Product area>`: patterns and components for a specific product area, for example `Areas/Settings` or `Areas/Assistant`
|
|
||||||
- `Experimental`: beta components that require caution
|
|
||||||
- The last `title` segment is the component name and MUST be PascalCase (`Core/EmptyState`, not `Core/empty-state`). Category prefixes are unrestricted.
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
- "Add a modal dialog for confirming workflow deletion" → Use `N8nDialog`
|
|
||||||
- "Add a dropdown to select workflow status" → Use `N8nDropdown` or `N8nSelect`
|
|
||||||
- "Add button with + icon to add new tiem" → Wrap `N8nButton` with `iconOnly` prop with `N8nTooltip` and wrap in `N8nTooltip`. Use `N8nIcon` and proper aria-label.
|
|
||||||
- "Add a destructive action button" → use `N8nButton` with `variant="destructive"`
|
|
||||||
- "Make background color white/black" → Use `var(--background--surface)` for white on light mode and "black" on dark mode
|
|
||||||
- "Animate the title in gracefully" -> Use `fade-in-up` mixin from `motion.scss` with `var(--duration--base)`
|
|
||||||
158
.agents/skills/env-var-docs/SKILL.md
Normal file
158
.agents/skills/env-var-docs/SKILL.md
Normal file
|
|
@ -0,0 +1,158 @@
|
||||||
|
---
|
||||||
|
name: n8n:env-var-docs
|
||||||
|
description: >-
|
||||||
|
Writes and reviews the JSDoc on `@Env(...)` config properties. The docs team
|
||||||
|
extracts these comments from source into the public environment variable
|
||||||
|
reference, so they are user documentation, not code comments. Use when adding
|
||||||
|
or changing an `@Env` property, a config class, or reviewing a PR that touches
|
||||||
|
one.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Environment variable docs
|
||||||
|
|
||||||
|
The JSDoc above every `@Env('...')` property is exported almost verbatim into
|
||||||
|
the [environment variables reference](https://docs.n8n.io/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables)
|
||||||
|
on docs.n8n.io. The generated table has four columns: variable name,
|
||||||
|
description, data type, default. Your JSDoc is the description column. The
|
||||||
|
reader is a self-hosting operator, not an n8n developer.
|
||||||
|
|
||||||
|
Follow the [n8n docs style guide](https://docs.n8n.io/contribute/contribution-guide-for-n8n-docs/style-guide-for-n8n-docs)
|
||||||
|
for these comments. It overrides the ASD-STE100 rule in `AGENTS.md` for this
|
||||||
|
one case. The rules below are the parts of that guide that matter for a
|
||||||
|
one-paragraph description.
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- **Every `@Env` property has a JSDoc.** No exceptions. A missing comment
|
||||||
|
ships as an empty description cell.
|
||||||
|
- **Write for the operator.** Say what the setting does, when to change it,
|
||||||
|
and what happens when it's unset or wrong. Don't explain why the code is
|
||||||
|
written the way it is.
|
||||||
|
- **No code references.** No file names, class names, function names,
|
||||||
|
constants, license keys, or other internals the reader can't open. Values
|
||||||
|
the operator types into the variable are fine and often needed, for example
|
||||||
|
a credential type ID like `googleOAuth2Api` or a mode like `postgresdb`.
|
||||||
|
The test: would the operator paste this into a config file, or would they
|
||||||
|
need the source to know what it means? Details for developers go in a
|
||||||
|
regular `//` comment on the implementation, not in the JSDoc.
|
||||||
|
- **No attack scenarios.** Say what the setting protects, not how an
|
||||||
|
attacker would exploit it. This is a public page.
|
||||||
|
- **Don't repeat the default.** The default renders in its own column. Don't
|
||||||
|
write "Defaults to true" or "Default: 1 hour". Do say what the unset state
|
||||||
|
means when it's not obvious, for example "When unset, n8n uses the Redis
|
||||||
|
host".
|
||||||
|
- **State units and formats.** Say "in milliseconds", "in bytes", "a
|
||||||
|
comma-separated list", "a JSON object". The data type column only says
|
||||||
|
`Number` or `String`.
|
||||||
|
- **Use allowed values when the set is small.** "One of `sqlite`,
|
||||||
|
`postgresdb`." For a list, show one inline example in the sentence.
|
||||||
|
- **No JSDoc tags.** No `@example`, `@default`, `@see`, `@deprecated`. The
|
||||||
|
exporter copies the tag name into the docs. Put the example or the
|
||||||
|
deprecation notice in a sentence instead.
|
||||||
|
- **Product names:** "Gateway credits", not "n8n Connect" or "AI Gateway".
|
||||||
|
"Publish a workflow", not "activate". `n8n` is always lowercase.
|
||||||
|
- **Style:** present tense, active voice, second person. Use contractions.
|
||||||
|
No em dashes, use a comma or a new sentence. No "e.g." or "i.e.", write
|
||||||
|
"for example" and "that is". Spell out zero to nine, numerals from 10.
|
||||||
|
Values the operator types stay numerals, for example "Set to 0".
|
||||||
|
Sentence case. One idea per sentence. End every sentence with a period.
|
||||||
|
- **Plain words:** "use" not "utilize", "lets you" not "allows you to", cut
|
||||||
|
"powerful", "seamless", "simply", "it's important to note".
|
||||||
|
- **Length:** one to three sentences. If the setting needs more, the extra
|
||||||
|
belongs in a docs page the comment can't link to yet; keep the comment to
|
||||||
|
what fits a table cell.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Bad, as found in the generated docs:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Instance-level enablement for n8n Connect (AI Gateway). Licensed instances
|
||||||
|
* are enabled by default; false opts out. Budget / free allowance still comes
|
||||||
|
* from the license (`quota:aiGatewayBudget`).
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
Wrong product name, a restated default, and an internal license key. Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Whether Gateway credits are available on this instance. Set to false to
|
||||||
|
* turn them off on a licensed instance. The credit allowance comes from your
|
||||||
|
* license.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Time to live in milliseconds for Redis cache entries. Set to 0 to disable
|
||||||
|
* expiry. Default: 1 hour.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
The default is already in the table. Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Time to live in milliseconds for Redis cache entries. Set to 0 to keep
|
||||||
|
* entries until Redis evicts them.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Comma-separated list of credential types for which overwrites are skipped
|
||||||
|
* when the credential has been customized.
|
||||||
|
* @example `N8N_SKIP_CREDENTIAL_OVERWRITE=zohoOAuth2Api,salesforceOAuth2Api`
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
The `@example` tag lands in the description as literal text. Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Comma-separated list of credential types to skip when applying credential
|
||||||
|
* overwrites, for example `zohoOAuth2Api,salesforceOAuth2Api`. n8n skips an
|
||||||
|
* overwrite only when a user has already changed one of its fields.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Bind OAuth credential callbacks to the browser that initiated the flow.
|
||||||
|
* When enabled, a session-scoped `n8n-oauth-binding` cookie is set on flow
|
||||||
|
* initiation and verified on callback. Defeats phishing attacks where an
|
||||||
|
* attacker injects an OAuth authorize URL into a victim's browser to land
|
||||||
|
* tokens on the attacker's credential.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
Attack narrative and an internal cookie name on a public page. Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
/**
|
||||||
|
* Whether an OAuth credential connection must finish in the same browser
|
||||||
|
* that started it. When enabled, n8n rejects the callback if it arrives
|
||||||
|
* from a different browser.
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Review checklist
|
||||||
|
|
||||||
|
When you review a PR that adds or changes an `@Env` property, check each
|
||||||
|
comment against this list and quote the fix in the review:
|
||||||
|
|
||||||
|
1. JSDoc present.
|
||||||
|
2. No code identifiers, file names, or internal keys.
|
||||||
|
3. No default restated.
|
||||||
|
4. Units, format, or allowed values stated.
|
||||||
|
5. No JSDoc tags.
|
||||||
|
6. No em dashes, Latin abbreviations, or filler words.
|
||||||
|
7. Reads correctly as a sentence in a table cell with no surrounding context.
|
||||||
|
|
@ -20,4 +20,4 @@ Start with the relevant mode in [reference.md](reference.md):
|
||||||
- `Review` for auditing experiment changes.
|
- `Review` for auditing experiment changes.
|
||||||
- `Retire` for cleaning up completed or abandoned experiments.
|
- `Retire` for cleaning up completed or abandoned experiments.
|
||||||
|
|
||||||
When experiment work touches Vue components or user-facing copy, also follow `n8n:design-system` and `n8n:content-design`.
|
When experiment work touches Vue components or user-facing copy, also follow `n8n:ui-design` and `n8n:content-design`.
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ Use this guide for code under `packages/frontend/editor-ui/src/experiments/` and
|
||||||
- Wire experiments at the narrowest host surface that owns the decision.
|
- Wire experiments at the narrowest host surface that owns the decision.
|
||||||
- Keep experiment components inside the experiment folder unless they become generally reusable.
|
- Keep experiment components inside the experiment folder unless they become generally reusable.
|
||||||
- All user-facing text in Vue code must use i18n. Follow `n8n:content-design` when writing or revising copy.
|
- All user-facing text in Vue code must use i18n. Follow `n8n:content-design` when writing or revising copy.
|
||||||
- Follow `n8n:design-system` for Vue component structure, n8n design-system components, and CSS variables.
|
- Follow `n8n:ui-design` for Vue component structure, n8n design-system components, and CSS variables.
|
||||||
- At the end of scaffold or wiring work, tell the user what remains manual, such as PostHog configuration, route guards, modal registration, or extra workflow payload files.
|
- At the end of scaffold or wiring work, tell the user what remains manual, such as PostHog configuration, route guards, modal registration, or extra workflow payload files.
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ the same commands from the repo via `pnpm nathan`.
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- **No tunnel setup needed.** Nathan replies asynchronously through a short-lived
|
- **No tunnel setup needed.** Nathan replies asynchronously through a short-lived
|
||||||
public tunnel that the script opens for you (`npx localtunnel`). A `deploy` to a
|
Cloudflare Quick Tunnel that the script opens for you (`npx cloudflared`). A
|
||||||
**new** `test-<name>` also polls that instance URL directly, so it still reports
|
`deploy` to a **new** `test-<name>` also polls that instance URL directly, so it
|
||||||
success even if the tunnel drops. (Redeploying a name that's *already up* skips
|
still reports success even if the tunnel drops. (Redeploying a name that's
|
||||||
the poll — it can't tell the old instance from the new — so it falls back to the
|
*already up* skips the poll — it can't tell the old instance from the new — so
|
||||||
tunnel; prefer a fresh name when you need the reliable report.)
|
it falls back to the tunnel; prefer a fresh name when you need the reliable report.)
|
||||||
- **A token in `~/.n8n/dev/nathan-token`.** If a command reports no token, **ask the
|
- **A token in `~/.n8n/dev/nathan-token`.** If a command reports no token, **ask the
|
||||||
user for one** — point them at the form
|
user for one** — point them at the form
|
||||||
(`https://internal.users.n8n.cloud/form/d6d34a2f-4899-4ee8-afc8-f8c41a8a243d`),
|
(`https://internal.users.n8n.cloud/form/d6d34a2f-4899-4ee8-afc8-f8c41a8a243d`),
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ check the code, not license to drop a team default.
|
||||||
## Non-negotiable rules
|
## Non-negotiable rules
|
||||||
|
|
||||||
- New endpoints are `@PublicApiController` classes under `v1/controllers/`, one
|
- New endpoints are `@PublicApiController` classes under `v1/controllers/`, one
|
||||||
`*.public.controller.ts` per feature. A controller is a class — never
|
`*.public.controller.ts` per feature.
|
||||||
`export =` (the legacy tuple style; `require-public-api-controller` flags it).
|
|
||||||
- Public API and internal REST are separate HTTP surfaces. A public controller
|
- Public API and internal REST are separate HTTP surfaces. A public controller
|
||||||
never calls an internal controller/endpoint; both reuse the same service.
|
never calls an internal controller/endpoint; both reuse the same service.
|
||||||
- Controllers and handlers delegate to a service — never import a repository or
|
- Controllers and handlers delegate to a service — never import a repository or
|
||||||
|
|
@ -31,7 +30,6 @@ check the code, not license to drop a team default.
|
||||||
`@ApiResponse(Dto)`.
|
`@ApiResponse(Dto)`.
|
||||||
- Register each controller via a side-effect import in `v1/controllers/index.ts`
|
- Register each controller via a side-effect import in `v1/controllers/index.ts`
|
||||||
(`public-api-controllers.test.ts` fails otherwise).
|
(`public-api-controllers.test.ts` fails otherwise).
|
||||||
- Don't add business logic to legacy `express-openapi-validator` (EOV) handlers.
|
|
||||||
- Migrating a legacy endpoint must not change its public contract.
|
- Migrating a legacy endpoint must not change its public contract.
|
||||||
|
|
||||||
These are `n8n-local-rules` ESLint rules (see `packages/cli/eslint.config.mjs`)
|
These are `n8n-local-rules` ESLint rules (see `packages/cli/eslint.config.mjs`)
|
||||||
|
|
@ -41,6 +39,7 @@ add to it.
|
||||||
|
|
||||||
## Team defaults
|
## Team defaults
|
||||||
|
|
||||||
|
- Write code that acts as its own documentation. The schema, the decorator, and the test should make the rule clear on their own without a comment.
|
||||||
- List endpoints: cursor-based pagination (internal API uses both cursor- and
|
- List endpoints: cursor-based pagination (internal API uses both cursor- and
|
||||||
page-based — don't copy an internal endpoint's model).
|
page-based — don't copy an internal endpoint's model).
|
||||||
- Pagination args are always `offset` and `limit` — on service methods, handler
|
- Pagination args are always `offset` and `limit` — on service methods, handler
|
||||||
|
|
@ -108,19 +107,25 @@ model; reuse only what applies. Decorators, all from `@n8n/decorators`:
|
||||||
| `@Get/@Post/@Put/@Patch/@Delete('/path')` | Route method. |
|
| `@Get/@Post/@Put/@Patch/@Delete('/path')` | Route method. |
|
||||||
| `@ApiKeyScope('res:action')` | API-key grant check. |
|
| `@ApiKeyScope('res:action')` | API-key grant check. |
|
||||||
| `@ProjectScope/@GlobalScope('res:action')` | User RBAC check. |
|
| `@ProjectScope/@GlobalScope('res:action')` | User RBAC check. |
|
||||||
| `@ApiResponse(status)` / `@ApiResponse(status, Dto)` | Success status + (optional) output DTO; registry `.parse()`s + strips the return value. Exactly one per route — a second `@ApiResponse` throws. `204` can't carry a DTO — throws. |
|
| `@ApiResponse(status)` / `@ApiResponse(status, Dto)` | Success status + (optional) output DTO; registry `.parse()`s + strips the return value. Exactly one per route — a second `@ApiResponse` throws. `204` can't carry a DTO or a binary body — throws. For a binary response body (returned as `{ body, headers? }`), use `@ApiResponse(status, { mediaType, description?, headers? })` — see [Binary response bodies](reference.md#binary-response-bodies). |
|
||||||
| `@ApiErrorResponse(status)` | Declares an additional documented non-2xx status (e.g. `404`, `409`). Stack multiple for more than one. `400`/`401`/`403` are added automatically (body/query present, always, and `@ApiKeyScope` present, respectively) — don't declare those yourself. |
|
| `@ApiErrorResponse(status)` | Declares an additional documented non-2xx status (e.g. `404`, `409`). Stack multiple for more than one. `400`/`401`/`403` are added automatically (body/query present, always, and `@ApiKeyScope` present, respectively) — don't declare those yourself. |
|
||||||
| `@ApiSummary(text)` / `@ApiDescription(text)` / `@ApiTags([...])` | OpenAPI summary/description/tags. `@ApiTags` sorts alphabetically regardless of the order you pass. All optional but expected on every real route. |
|
| `@ApiSummary(text)` / `@ApiDescription(text)` / `@ApiTags([...])` | OpenAPI summary/description/tags. `@ApiTags` sorts alphabetically regardless of the order you pass. All optional but expected on every real route. |
|
||||||
| `@Query` / `@Body` / `@Param('name')` | Bind + validate via a `Z.class` DTO / path param. |
|
| `@Query` / `@Body` / `@Param('name')` | Bind + validate via a `Z.class` DTO / path param. `@Body` is JSON by default; `@Body({ mediaType: 'multipart/form-data', uploadLimits })` takes a `multipart/form-data` body instead — see [Request body media types](reference.md#request-body-media-types). |
|
||||||
| `@Licensed('feat')` | Gates the route on a single `BooleanLicenseFeature`; `PublicApiControllerRegistry` runs its own license middleware (after auth/`@ApiKeyScope`/`@ProjectScope`|`@GlobalScope`, before the handler) and 403s unlicensed requests. Only takes one feature — if the gate is an any-of/all-of combination (e.g. `LicenseState.isProvisioningLicensed()`, which is `feat:saml` OR `feat:oidc`), `@Licensed` can't express that; check manually in the handler instead, same as the internal `provisioning.controller.ee.ts`/`role-mapping-rule.controller.ee.ts` do today (throwing `ForbiddenError` on failure). |
|
| `@Licensed('feat')` | Gates the route on a single `BooleanLicenseFeature`; `PublicApiControllerRegistry` runs its own license middleware (after auth/`@ApiKeyScope`/`@ProjectScope`|`@GlobalScope`, before the handler) and 403s unlicensed requests. Only takes one feature — if the gate is an any-of/all-of combination (e.g. `LicenseState.isProvisioningLicensed()`, which is `feat:saml` OR `feat:oidc`), `@Licensed` can't express that; check manually in the handler instead, same as the internal `provisioning.controller.ee.ts`/`role-mapping-rule.controller.ee.ts` do today (throwing `ForbiddenError` on failure). |
|
||||||
|
|
||||||
## Authorization (easy to get wrong)
|
## Authorization (easy to get wrong)
|
||||||
|
|
||||||
- `@ApiKeyScope` (what the API key is granted) and `@ProjectScope`/`@GlobalScope`
|
- `@ApiKeyScope` (what the API key is granted) and `@ProjectScope`/`@GlobalScope`
|
||||||
(what the user may do) are independent. Use both when the model needs both.
|
(what the user may do) are independent. Use both when the model needs both.
|
||||||
- `@ProjectScope` reads `req.params` as-is and does not remap `id` — name the path
|
- Name every path param `{resource}Id` (e.g. `workflowId`, `credentialId`,
|
||||||
param what the resolver expects (`workflowId`, `credentialId`, `projectId`,
|
`projectId`, …) — never a generic `:id` / `{id}`. This is the Public API's
|
||||||
`dataTableId`, …). A generic `id` often fails.
|
naming convention: it keeps the API self-documenting and gives typed SDK
|
||||||
|
codegen a real argument name instead of `id`. `@ProjectScope` also reads
|
||||||
|
`req.params` as-is and does not remap `id` — it resolves authorization by
|
||||||
|
exact key name (`workflowId`, `credentialId`, `projectId`, `dataTableId`,
|
||||||
|
…), so a generic `id` on a `@ProjectScope` route often fails outright; a
|
||||||
|
`@GlobalScope` or unscoped route won't fail the same way, but still follow
|
||||||
|
the convention.
|
||||||
- `@ApiKeyScope` takes a string, `{ anyOf: [...] }`, or `{ allOf: [...] }` — never
|
- `@ApiKeyScope` takes a string, `{ anyOf: [...] }`, or `{ allOf: [...] }` — never
|
||||||
a bare array. The scope must exist in the permissions registry
|
a bare array. The scope must exist in the permissions registry
|
||||||
(`API_KEY_RESOURCES` in `@n8n/permissions`); `scope-parity.test.ts` fails on an
|
(`API_KEY_RESOURCES` in `@n8n/permissions`); `scope-parity.test.ts` fails on an
|
||||||
|
|
@ -193,6 +198,5 @@ existing tests.
|
||||||
- [Test-before-save endpoints](reference.md#test-before-save-endpoints)
|
- [Test-before-save endpoints](reference.md#test-before-save-endpoints)
|
||||||
- [Errors](reference.md#errors)
|
- [Errors](reference.md#errors)
|
||||||
- [Testing matrix](reference.md#testing-matrix)
|
- [Testing matrix](reference.md#testing-matrix)
|
||||||
- [Migrating legacy EOV endpoints](reference.md#migrating-legacy-eov-endpoints)
|
|
||||||
- [Verifying a migration](reference.md#verifying-a-migration)
|
- [Verifying a migration](reference.md#verifying-a-migration)
|
||||||
- [CI and merging](reference.md#ci-and-merging)
|
- [CI and merging](reference.md#ci-and-merging)
|
||||||
|
|
|
||||||
|
|
@ -103,55 +103,76 @@ scope, RBAC denial. Add whichever apply, matching the nearest existing tests:
|
||||||
unchanged. Tests alone cannot show this — see
|
unchanged. Tests alone cannot show this — see
|
||||||
[Verifying a migration](#verifying-a-migration).
|
[Verifying a migration](#verifying-a-migration).
|
||||||
|
|
||||||
## Migrating legacy EOV endpoints
|
## Request body media types
|
||||||
|
|
||||||
Legacy `express-openapi-validator` endpoints live under
|
`@Body` defaults to `application/json`; the body is already parsed by the
|
||||||
`v1/handlers/`, wired through `openapi.yml` with `x-eov-operation-*` and request
|
app-wide `bodyParser` before the registry sees it. Declaring
|
||||||
types in `packages/cli/src/public-api/types.ts`. Treat these as migration targets,
|
`@Body({ mediaType: 'multipart/form-data', uploadLimits })` instead takes a
|
||||||
not templates.
|
`multipart/form-data` body:
|
||||||
|
|
||||||
- Prefer migrating to `@PublicApiController` over extending the handler.
|
- `uploadLimits: () => MultipartUploadLimits` is a thunk, read once the route
|
||||||
- Preserve the public contract: path, method, scopes, status codes, response
|
handles its first request (not at startup) — read live config inside it
|
||||||
shape, and pagination.
|
(e.g. `Container.get(GlobalConfig)`), don't inline a literal.
|
||||||
- Move HTTP concerns into the controller and business orchestration into the
|
- The route's `@Body` DTO validates text fields merged with uploaded files,
|
||||||
shared service; keep the controller a thin HTTP boundary. If the legacy
|
not `req.body` alone. A text field and a file share the same flat object;
|
||||||
handler was itself already just a thin wrapper around an internal
|
a file field uses `publicApiUploadedFileSchema` (`@n8n/api-types`) — a
|
||||||
`@RestController` (calling its methods directly, e.g.
|
multer-file-shaped schema that documents itself as `{ type: 'string',
|
||||||
`Container.get(SomeController).createThing(req, res, payload)`), the new
|
format: 'binary' }`. Several files under the same field name become an
|
||||||
public controller can call that same internal controller directly — no need
|
array.
|
||||||
to duplicate its validation/business logic.
|
- An unknown field (one the DTO doesn't declare, on a `{ strict: true }` DTO)
|
||||||
- A route must be served by either the EOV handler or a controller, not both —
|
fails with `Unexpected form field "<name>"` — not the default "unrecognized
|
||||||
the build's `mergeDecoratorDocument` (`v1/openapi-gen/generate.ts`) throws on
|
keys" wording.
|
||||||
a path+method declared by both sides. Remove the legacy wiring (its path's
|
- Multer parsing errors map to these statuses: `413` for a size or count limit,
|
||||||
`$ref` entry in `openapi.yml`, the `x-eov-operation-*` handler, and its
|
`500` for `LIMIT_UNEXPECTED_FILE`, `400` for any other multer error, and `500`
|
||||||
`handler.ts`) only after the new controller is registered, `pnpm build`
|
for anything else (a malformed body). The `500` is not masked, because it is a
|
||||||
regenerates the spec cleanly, and tests are updated.
|
`ResponseError`. A missing boundary gives `400` with `multipart file(s) required`.
|
||||||
- Fully delete the migrated legacy files: the handler's `.ts`, its
|
- The body is parsed **after** every auth/scope/license/quota gate and
|
||||||
`spec/paths/*.yml` and `spec/schemas/*.yml`, and any now-dead request type
|
**before** controller/route middlewares — a caller those gates would reject
|
||||||
in `packages/cli/src/public-api/types.ts`. Then check
|
never has their (possibly huge) body read off the socket, and a middleware
|
||||||
`v1/shared/spec/schemas/_index.yml` and `v1/shared/spec/parameters/_index.yml`
|
that reads `req.body` sees it already parsed.
|
||||||
for entries that `$ref` one of the deleted schema/parameter files — those are
|
- `/discover` shows no request schema for a multipart route (same as a legacy
|
||||||
separate from the path's own `$ref` in `openapi.yml` and are easy to miss;
|
multipart route today) — a client can't assume a JSON schema it never gets.
|
||||||
left dangling, the next bundle fails on a broken `$ref`.
|
- The generator documents the body under the `multipart/form-data` content
|
||||||
- If the legacy handler gated on a license (`isLicensed('feat:x')` middleware),
|
key (not `application/json`) and adds `413` alongside `415` to the route's
|
||||||
`@Licensed('feat:x')` now replicates that for a controller route (see the
|
documented responses automatically.
|
||||||
decorator table in [SKILL.md](SKILL.md#declaring-a-controller)) — but only for
|
|
||||||
a single feature. If the legacy check was an any-of/all-of over several flags
|
Everything above lives in `packages/cli/src/public-api/media-types/`, one
|
||||||
(e.g. `LicenseState.isProvisioningLicensed()`), `@Licensed` can't express
|
handler per media type (`REQUEST_BODY_HANDLERS` in
|
||||||
that; replicate it manually in the controller instead, don't drop it - this
|
`media-types/request-body/index.ts`). Adding a further media type (e.g.
|
||||||
is exactly what the internal `provisioning.controller.ee.ts` and
|
`application/octet-stream`) means: add it to `RequestBodyMediaOptions` in
|
||||||
`role-mapping-rule.controller.ee.ts` already do, since neither uses
|
`@n8n/decorators`'s `controller/types.ts`, write a handler implementing
|
||||||
`@Licensed` for that reason.
|
`RequestBodyHandler` in `media-types/request-body/`, and register it in
|
||||||
- As a legacy file drops repository access / the `export =` tuple, remove its
|
`REQUEST_BODY_HANDLERS` — the registry, resolver, generator and `/discover`
|
||||||
entry from the `off` allowlists for `no-repository-in-public-api-handler` and
|
need no change, since they all read the handler, not the media type.
|
||||||
`require-public-api-controller` in `packages/cli/eslint.config.mjs` (shrink-only
|
|
||||||
— never extend them).
|
## Binary response bodies
|
||||||
- For complex legacy-only, multipart, or non-standard endpoints, study the
|
|
||||||
nearest existing handler first.
|
`@ApiResponse(status, { mediaType, description?, headers? })` declares a
|
||||||
- Keep each field in its original position when you extract a request shape shared
|
success body that the controller method returns as `{ body, headers? }`, for
|
||||||
by two routes, and destructure out the ones a route doesn't take. The generator
|
example an `application/gzip` stream. The framework treats options whose
|
||||||
emits properties in shape order, so a moved field rewrites the `*.generated.yml`
|
`mediaType` is in `BINARY_RESPONSE_MEDIA_TYPES` as a binary response.
|
||||||
of a route the PR wasn't changing.
|
`mediaType` accepts only those types.
|
||||||
|
|
||||||
|
- `body` is a `Buffer` or a `Readable`. The method returns the result and never
|
||||||
|
writes to `res`.
|
||||||
|
- `headers` holds the response headers. Every header declared in `headers` must
|
||||||
|
be in the result. A missing header fails the request with a `500`. Matching is
|
||||||
|
case-insensitive.
|
||||||
|
- The registry checks the headers, then sets the declared status, the headers,
|
||||||
|
and `Content-Type: <mediaType>`. A header in the result cannot replace the
|
||||||
|
`Content-Type`.
|
||||||
|
- A stream's first chunk is read before any header is set. So a stream that
|
||||||
|
fails before its first chunk gives the normal JSON error response, with no
|
||||||
|
binary `Content-Type`. A method that throws before it returns does the same.
|
||||||
|
- After the first chunk is sent, an error ends the response. A client that
|
||||||
|
disconnects is not an error, and the framework destroys the stream.
|
||||||
|
- A method that returns no binary body fails with a `500`.
|
||||||
|
- The generator documents the body as `{ type: string, format: binary }`
|
||||||
|
under the `mediaType` content key, with the description and headers.
|
||||||
|
The description defaults to `Operation successful.`.
|
||||||
|
|
||||||
|
The runtime part is `sendBinaryResponse` in
|
||||||
|
`packages/cli/src/public-api/media-types/binary-response.ts`.
|
||||||
|
|
||||||
## Verifying a migration
|
## Verifying a migration
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ Based on the affected area, pick the test layer and pattern:
|
||||||
| CLI / API | Vitest integration | setupTestServer + supertest | `packages/cli/test/integration/` |
|
| CLI / API | Vitest integration | setupTestServer + supertest | `packages/cli/test/integration/` |
|
||||||
| Config | Vitest unit | GlobalConfig + Container | `packages/@n8n/config/src/configs/__tests__/` |
|
| Config | Vitest unit | GlobalConfig + Container | `packages/@n8n/config/src/configs/__tests__/` |
|
||||||
| Editor UI | Vitest | Vue Test Utils + Pinia | `packages/frontend/editor-ui/src/**/__tests__/` |
|
| Editor UI | Vitest | Vue Test Utils + Pinia | `packages/frontend/editor-ui/src/**/__tests__/` |
|
||||||
| E2E / Canvas | Playwright | Test containers + composables | `packages/testing/playwright/` |
|
| E2E / Canvas | Playwright | Test containers + composables | `packages/quality/testing/playwright/` |
|
||||||
|
|
||||||
## Step 3: Locate Source Files
|
## Step 3: Locate Source Files
|
||||||
|
|
||||||
|
|
@ -73,6 +73,12 @@ Write a regression test that:
|
||||||
- Asserts the CORRECT behavior (test will fail on current code)
|
- Asserts the CORRECT behavior (test will fail on current code)
|
||||||
- Also includes a "happy path" test to prove the setup works
|
- Also includes a "happy path" test to prove the setup works
|
||||||
|
|
||||||
|
Complete the test safety gate in `/AGENTS.md` before you run the test:
|
||||||
|
- Trace side effects from imports, constructors, hooks, and mocked branches
|
||||||
|
- Keep filesystem access in a test-owned temporary directory
|
||||||
|
- Set `N8N_USER_FOLDER` before importing modules that resolve it
|
||||||
|
- When a mock changes a state check, inspect and isolate the branch that it activates
|
||||||
|
|
||||||
## Step 8: Run and Score
|
## Step 8: Run and Score
|
||||||
|
|
||||||
Run the test from the package directory (e.g., `cd packages/nodes-base && pnpm test <file>`).
|
Run the test from the package directory (e.g., `cd packages/nodes-base && pnpm test <file>`).
|
||||||
|
|
|
||||||
39
.agents/skills/ui-design/SKILL.md
Normal file
39
.agents/skills/ui-design/SKILL.md
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
name: n8n:ui-design
|
||||||
|
description: Guidelines on designing and building UI. Use when working in editor-ui or design-system packages. Triggers for tasks that include refactoring components, styling changes, or feature work.
|
||||||
|
---
|
||||||
|
|
||||||
|
# UI Design
|
||||||
|
|
||||||
|
Comprehensive guide for building, styling, and using components in the frontend.
|
||||||
|
|
||||||
|
## References
|
||||||
|
- When styling components, use `packages/frontend/@n8n/design-system/src/styleguide/*.mdx`
|
||||||
|
- For animations, use `rules/web-animation-guidelines.md`
|
||||||
|
- When reviewing UI changes, use `rules/web-interface-guidelines.md`
|
||||||
|
|
||||||
|
## Best practices
|
||||||
|
- ALWAYS use CSS variables from `_tokens.scss` or `_primitives.scss` in
|
||||||
|
`packages/frontend/@n8n/design-system/src/css/`. Look up every length, color,
|
||||||
|
font-size and duration before you write it as a literal. Each spacing token
|
||||||
|
carries its px value in a comment: `--spacing--5xs: 0.125rem; /** 2px **/`.
|
||||||
|
Grep that comment to find the token for a px value. The grep gives one hit for
|
||||||
|
each token family, so pick the family that matches the property: `--spacing--*`
|
||||||
|
for margin and padding, `--radius--*` for border-radius, `--height--*` for
|
||||||
|
height. The styleguide
|
||||||
|
`packages/frontend/@n8n/design-system/src/styleguide/spacing-size.mdx` lists the
|
||||||
|
same scale as a table. The spacing scale starts at 2px, so a small value is not
|
||||||
|
a reason to hardcode. Hardcode only if the lookup finds no token. Give the
|
||||||
|
reason in a comment.
|
||||||
|
- ALWAYS prefer using existing components from `packages/frontend/@n8n/design-system/src/components`. Prefer components that aren't marked `@deprecated`.
|
||||||
|
- If you need to add hover/active alpha behavior to solid components, prefer `color-mix()` with explicit percentages.
|
||||||
|
- When working with animations or transitions, ALWAYS prefer using mixins from `packages/frontend/@n8n/design-system/src/css/mixins/motion.scss`
|
||||||
|
|
||||||
|
## Components
|
||||||
|
Use existing `design-system` components over creating custom implementations:
|
||||||
|
- "Add a modal dialog for confirming workflow deletion" → Use `N8nDialog`
|
||||||
|
- "Add a dropdown to select workflow status" → Use `N8nDropdown` or `N8nSelect`
|
||||||
|
- "Add button with + icon to add new tiem" → Wrap `N8nButton` with `iconOnly` prop with `N8nTooltip` and wrap in `N8nTooltip`. Use `N8nIcon` and proper aria-label.
|
||||||
|
- "Add a destructive action button" → use `N8nButton` with `variant="destructive"`
|
||||||
|
- "Make background color white/black" → Use `var(--background--surface)` for white on light mode and "black" on dark mode
|
||||||
|
- "Animate the title in gracefully" -> Use `fade-in-up` mixin from `motion.scss` with `var(--duration--base)`
|
||||||
2
.aikido
2
.aikido
|
|
@ -8,7 +8,7 @@ exclude:
|
||||||
# Machine-generated instance-AI expectation traces. Contain ephemeral
|
# Machine-generated instance-AI expectation traces. Contain ephemeral
|
||||||
# credential reference IDs (nanoids) that re-trip the secrets scanner
|
# credential reference IDs (nanoids) that re-trip the secrets scanner
|
||||||
# on every regeneration. No secret material.
|
# on every regeneration. No secret material.
|
||||||
- packages/testing/playwright/expectations
|
- packages/quality/testing/playwright/expectations
|
||||||
|
|
||||||
# Test code repo-wide. Fixtures routinely contain synthetic PEM blocks,
|
# Test code repo-wide. Fixtures routinely contain synthetic PEM blocks,
|
||||||
# basic-auth strings, and deliberately fake keys (including the secret
|
# basic-auth strings, and deliberately fake keys (including the secret
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"issues": 164
|
"issues": 110
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
.claude/plugins/n8n/skills/agent-design-language
Symbolic link
1
.claude/plugins/n8n/skills/agent-design-language
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../.agents/skills/agent-design-language
|
||||||
1
.claude/plugins/n8n/skills/create-agent-builder-eval
Symbolic link
1
.claude/plugins/n8n/skills/create-agent-builder-eval
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../.agents/skills/create-agent-builder-eval
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../../../../.agents/skills/design-system
|
|
||||||
1
.claude/plugins/n8n/skills/env-var-docs
Symbolic link
1
.claude/plugins/n8n/skills/env-var-docs
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../.agents/skills/env-var-docs
|
||||||
1
.claude/plugins/n8n/skills/ui-design
Symbolic link
1
.claude/plugins/n8n/skills/ui-design
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../.agents/skills/ui-design
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -4,6 +4,7 @@ ARG NODE_VERSION=24
|
||||||
FROM node:${NODE_VERSION}-bookworm
|
FROM node:${NODE_VERSION}-bookworm
|
||||||
|
|
||||||
ARG PLAYWRIGHT_VERSION=1.62.1
|
ARG PLAYWRIGHT_VERSION=1.62.1
|
||||||
|
ARG OPENCODE_VERSION=1.18.25
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
tmux sudo less jq ripgrep postgresql-client \
|
tmux sudo less jq ripgrep postgresql-client \
|
||||||
|
|
@ -14,7 +15,7 @@ RUN npx -y playwright@${PLAYWRIGHT_VERSION} install-deps chromium
|
||||||
|
|
||||||
# Agent harnesses. Self-update is off: the image is the update mechanism
|
# Agent harnesses. Self-update is off: the image is the update mechanism
|
||||||
ENV DISABLE_AUTOUPDATER=1
|
ENV DISABLE_AUTOUPDATER=1
|
||||||
RUN npm install -g @anthropic-ai/claude-code opencode-ai
|
RUN npm install -g @anthropic-ai/claude-code opencode-ai@${OPENCODE_VERSION}
|
||||||
|
|
||||||
COPY codespaces-env.sh /usr/local/lib/codespaces-env.sh
|
COPY codespaces-env.sh /usr/local/lib/codespaces-env.sh
|
||||||
COPY codespaces-secrets.sh /etc/profile.d/codespaces-secrets.sh
|
COPY codespaces-secrets.sh /etc/profile.d/codespaces-secrets.sh
|
||||||
|
|
@ -37,4 +38,7 @@ ENV PNPM_HOME=/home/node/.local/share/pnpm
|
||||||
ENV PATH=$PNPM_HOME/bin:$PATH
|
ENV PATH=$PNPM_HOME/bin:$PATH
|
||||||
|
|
||||||
USER node
|
USER node
|
||||||
RUN mkdir -p $PNPM_HOME ~/.pnpm-store && pnpm config set store-dir ~/.pnpm-store --global
|
# The store must sit on the same filesystem as the worktrees (/workspaces is its own
|
||||||
|
# mount), or pnpm copies node_modules into every worktree instead of hardlinking.
|
||||||
|
# The directory is created on the first install: Codespaces mounts /workspaces at runtime.
|
||||||
|
RUN mkdir -p $PNPM_HOME && pnpm config set store-dir /workspaces/.pnpm-store --global
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Run long-lived, human-steered agent sessions (Claude Code / OpenCode) on a
|
Run long-lived, human-steered agent sessions (Claude Code / OpenCode) on a
|
||||||
GitHub Codespace instead of your laptop: start a task, close the lid, steer it
|
GitHub Codespace instead of your laptop: start a task, close the lid, steer it
|
||||||
from anywhere with a terminal, resume tomorrow.
|
from anywhere, resume tomorrow.
|
||||||
|
|
||||||
This is a separate devcontainer config from the laptop one in
|
This is a separate devcontainer config from the laptop one in
|
||||||
`.devcontainer/` — it ships both agent CLIs, `tmux` for session persistence,
|
`.devcontainer/` — it ships both agent CLIs, `tmux` for session persistence,
|
||||||
|
|
@ -11,26 +11,73 @@ Playwright system deps, and Docker-in-Docker (for testcontainers and
|
||||||
|
|
||||||
## One-time setup (~5 min)
|
## One-time setup (~5 min)
|
||||||
|
|
||||||
1. Add provider keys at [github.com/settings/codespaces](https://github.com/settings/codespaces).
|
1. Give the GitHub CLI the codespace scope:
|
||||||
Add `ANTHROPIC_API_KEY` for Claude Code. Add `OPENROUTER_API_KEY` for OpenCode.
|
|
||||||
Give both secrets access to `n8n-io/n8n`.
|
|
||||||
(Alternative for Max subscriptions: `CLAUDE_CODE_OAUTH_TOKEN` from `claude setup-token`.)
|
|
||||||
2. Give the GitHub CLI the codespace scope:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gh auth refresh -h github.com -s codespace
|
gh auth refresh -h github.com -s codespace
|
||||||
```
|
```
|
||||||
|
|
||||||
## Daily flow
|
2. Add provider keys at [github.com/settings/codespaces](https://github.com/settings/codespaces)
|
||||||
|
if your client needs them. Give each secret access to `n8n-io/n8n`.
|
||||||
|
- `ANTHROPIC_API_KEY` for Claude Code in the terminal (`pnpm session`).
|
||||||
|
Alternative for Max subscriptions: `CLAUDE_CODE_OAUTH_TOKEN` from
|
||||||
|
`claude setup-token`. The desktop app does not need either secret.
|
||||||
|
- `OPENROUTER_API_KEY` for OpenCode.
|
||||||
|
|
||||||
|
## Choose a client
|
||||||
|
|
||||||
|
All clients run the agent, its tools, and builds in the Codespace. Your laptop
|
||||||
|
shows the conversation only.
|
||||||
|
|
||||||
|
| Client | Command | Use it when |
|
||||||
|
|---|---|---|
|
||||||
|
| Claude Code desktop app | `pnpm session ssh-config` once | You want the full desktop experience. |
|
||||||
|
| Claude Code in VS Code | Open the codespace in VS Code or the browser | You already work in VS Code. |
|
||||||
|
| Claude Code in a terminal | `pnpm session` | You want a plain terminal, or you are on a remote machine. |
|
||||||
|
| OpenCode | `pnpm session:opencode` | You use OpenCode. See [Local OpenCode clients](#local-opencode-clients). |
|
||||||
|
|
||||||
|
### Claude Code desktop app
|
||||||
|
|
||||||
|
1. From a local checkout, add an SSH host for your codespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm session ssh-config
|
||||||
|
```
|
||||||
|
|
||||||
|
The command creates or starts the codespace. It writes the host
|
||||||
|
`n8n-codespace` to `~/.ssh/n8n-codespace.conf` and includes that file from
|
||||||
|
`~/.ssh/config`.
|
||||||
|
2. In the desktop app, add an SSH connection to the host `n8n-codespace`.
|
||||||
|
3. Open the folder `/workspaces/n8n`, or a worktree under `/workspaces`.
|
||||||
|
|
||||||
|
The desktop app installs its own Claude Code on the codespace and signs in
|
||||||
|
with your desktop account. Sessions continue when you close the app. They stop
|
||||||
|
when the codespace stops.
|
||||||
|
|
||||||
|
- **Run `pnpm session ssh-config` again after you recreate the codespace.**
|
||||||
|
- **If the connection times out**, the codespace is probably starting. Run
|
||||||
|
`pnpm session ssh-config`, then connect again.
|
||||||
|
- **Test the connection** with `ssh n8n-codespace`.
|
||||||
|
|
||||||
|
### Claude Code in VS Code
|
||||||
|
|
||||||
|
The dev container installs the Claude Code extension. Open the codespace in
|
||||||
|
VS Code or the browser, then open the Claude Code panel. Sign in from the
|
||||||
|
extension if you did not add `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN`.
|
||||||
|
|
||||||
|
### Claude Code in a terminal
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm session # attach Claude Code (creates everything on first run)
|
pnpm session # attach Claude Code (creates everything on first run)
|
||||||
pnpm session:shell # open a shell in the default checkout
|
pnpm session:shell # open a shell in the default checkout
|
||||||
pnpm session:opencode # attach OpenCode in auto mode
|
pnpm session:opencode # connect the local OpenCode TUI
|
||||||
pnpm session:opencode fix-flaky # OpenCode in a separate worktree
|
pnpm session:opencode fix-flaky # use a separate remote worktree
|
||||||
|
pnpm session:opencode --web # open OpenCode in the local browser
|
||||||
|
pnpm session:opencode --legacy # use the remote TUI in tmux
|
||||||
pnpm session fix-flaky # Claude Code in a separate worktree
|
pnpm session fix-flaky # Claude Code in a separate worktree
|
||||||
pnpm session ls # what's running
|
pnpm session ls # what's running
|
||||||
pnpm session tunnel # forward n8n ports (default 5678, 8080); Ctrl-C to stop
|
pnpm session tunnel # forward n8n ports (default 5678, 8080); Ctrl-C to stop
|
||||||
|
pnpm session ssh-config # add the n8n-codespace SSH host for the desktop app
|
||||||
pnpm session stop # end of day: billing stops, disk survives
|
pnpm session stop # end of day: billing stops, disk survives
|
||||||
pnpm session rm # delete the codespace
|
pnpm session rm # delete the codespace
|
||||||
```
|
```
|
||||||
|
|
@ -38,15 +85,136 @@ pnpm session rm # delete the codespace
|
||||||
The dev container supports Codespaces with 2, 4, or 8 cores. The session commands
|
The dev container supports Codespaces with 2, 4, or 8 cores. The session commands
|
||||||
create an 8-core Codespace by default.
|
create an 8-core Codespace by default.
|
||||||
|
|
||||||
- **Detach** with `Ctrl-b d` — the agent keeps working without you.
|
- **Detach from tmux** with `Ctrl-b d` — the agent keeps working without you.
|
||||||
- **Scroll** with the mouse wheel (tmux mouse mode is on). To use the
|
Local OpenCode connections use the exit controls described below.
|
||||||
|
- **Scroll in tmux** with the mouse wheel (tmux mouse mode is on). To use the
|
||||||
terminal's own text selection, hold **Shift** and drag.
|
terminal's own text selection, hold **Shift** and drag.
|
||||||
- **Reattach** by running the same session command from any machine.
|
- **Reattach** by running the same session command from any machine.
|
||||||
- Each named session gets its own worktree (`/workspaces/wt-<name>`, branch
|
- Each named session gets its own worktree (`/workspaces/wt-<name>`, branch
|
||||||
`session/<name>`), so parallel agents never touch each other's tree. Builds
|
`session/<name>`), so parallel agents never touch each other's tree. A new
|
||||||
|
branch starts from the latest `origin/master`. Builds
|
||||||
in fresh worktrees are cache-hits via a shared turbo cache.
|
in fresh worktrees are cache-hits via a shared turbo cache.
|
||||||
- First codespace creation takes ~20 min uncached (image + full build). After
|
- First codespace creation takes ~20 min uncached (image + full build). After
|
||||||
that, sessions attach instantly; new worktrees cost a `pnpm install` (~1–2 min).
|
that, sessions attach instantly; new worktrees cost a `pnpm install` (~10 s: the
|
||||||
|
store lives on `/workspaces`, so `node_modules` is hardlinked, not copied).
|
||||||
|
|
||||||
|
## Configure the local OpenCode harness
|
||||||
|
|
||||||
|
Install the pinned shared harness:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm agent:harness
|
||||||
|
```
|
||||||
|
|
||||||
|
The command verifies the release checksum. It caches the bundle under
|
||||||
|
`~/.cache/n8n-agent-harness`. It then links the bundle plugin into
|
||||||
|
`~/.config/opencode/plugins`. Run the command again after the lock changes.
|
||||||
|
Restart OpenCode after the command completes.
|
||||||
|
|
||||||
|
## Local OpenCode clients
|
||||||
|
|
||||||
|
Run these commands from a local checkout. The TUI runs on your laptop. The
|
||||||
|
OpenCode server, repository, tools, and builds run in the Codespace. Browser
|
||||||
|
mode opens the remote web interface through a local connection.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm session:opencode fix-flaky # resume that workspace's latest conversation
|
||||||
|
pnpm session:opencode fix-flaky --web # open it in a browser
|
||||||
|
pnpm session:opencode fix-flaky --new # start a new conversation in that worktree
|
||||||
|
pnpm session:opencode --web --port 4100 # override the default browser port
|
||||||
|
pnpm session:opencode --help
|
||||||
|
```
|
||||||
|
|
||||||
|
For the TUI, install the same OpenCode version as the remote server. The
|
||||||
|
`OPENCODE_VERSION` argument in the [Dockerfile](Dockerfile) pins the version
|
||||||
|
for new images:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g opencode-ai@<version>
|
||||||
|
```
|
||||||
|
|
||||||
|
Use npm, not pnpm. The package gets its binary from a `postinstall` script.
|
||||||
|
pnpm does not run that script by default.
|
||||||
|
|
||||||
|
The launcher checks both versions. It reports a mismatch with both version
|
||||||
|
numbers before it opens the TUI. An existing Codespace can have a different
|
||||||
|
version. Install that version locally, or use `--web`. Browser mode does not
|
||||||
|
need a local OpenCode install.
|
||||||
|
The launcher sends its bootstrap code over SSH, so an existing Codespace does
|
||||||
|
not need a rebuild to use this connection method.
|
||||||
|
The remote server loads the shared OpenCode harness that the Codespace
|
||||||
|
post-start command installs. The local harness setup above is not required for
|
||||||
|
these commands.
|
||||||
|
|
||||||
|
The command prepares the worktree, starts or reuses one server, opens an SSH
|
||||||
|
tunnel, and connects the client. Each workspace opens its own conversation: the
|
||||||
|
most recently updated one in that worktree. A conversation moves to the front
|
||||||
|
when it receives a message. Switching to a conversation without sending a
|
||||||
|
message does not move it. Switching to another workspace's conversation does
|
||||||
|
not change what this workspace opens next. `--new` starts a new conversation
|
||||||
|
instead. It preserves the worktree and the old conversation.
|
||||||
|
|
||||||
|
- **Exit the TUI** with `/exit` or its quit shortcut. The launcher closes its
|
||||||
|
tunnel. The remote server stays running.
|
||||||
|
- **Disconnect browser mode** with `Ctrl-C` in the launcher terminal. Closing
|
||||||
|
the browser tab does not close the tunnel. Keep the launcher running while
|
||||||
|
you use the browser.
|
||||||
|
- **Reconnect** with the same command after a network interruption. After a
|
||||||
|
Codespace stop, the command restarts the server and opens the workspace's
|
||||||
|
most recently updated conversation.
|
||||||
|
A stop terminates running tools. It does not resume interrupted commands.
|
||||||
|
- **Browser mode uses local port 4096 by default.** Use `--port` to override it.
|
||||||
|
TUI mode selects an available port unless you specify one.
|
||||||
|
A fixed browser port preserves the browser origin across runs.
|
||||||
|
An occupied fixed port causes an error. It does not stop the existing listener.
|
||||||
|
- **Use model and permission controls in the client.** The new connection uses
|
||||||
|
the remote OpenCode configuration. It does not force the legacy `--auto` mode.
|
||||||
|
For the old CLI flags, use `pnpm session:opencode fix-flaky --legacy --model <model>`.
|
||||||
|
|
||||||
|
Both server and tunnel bind to `127.0.0.1`. The server uses a generated password.
|
||||||
|
The TUI receives it through its environment. Browser mode uses a local proxy
|
||||||
|
that adds authentication and rejects requests from other browser origins. The
|
||||||
|
proxy supports streamed responses, attachments, and terminal WebSockets. The
|
||||||
|
password does not appear in the URL or terminal output. Other processes on
|
||||||
|
your laptop can access the local browser proxy while it runs. Do not forward
|
||||||
|
this proxy or the OpenCode server port to other machines.
|
||||||
|
|
||||||
|
The server enables only OpenRouter. It reads `OPENROUTER_API_KEY` when it starts.
|
||||||
|
It enables OpenCode code mode by default to reduce the initial tool context.
|
||||||
|
Browser mode opens the workspace's most recently updated conversation directly.
|
||||||
|
The web UI stores opened projects in browser storage. If a new-session page
|
||||||
|
shows **New project**, open `/workspaces/n8n` there once. Keep the same browser
|
||||||
|
port when you reconnect to preserve this selection.
|
||||||
|
|
||||||
|
The server runs in the detached tmux session `n8n-opencode-server`. Its log is
|
||||||
|
`/workspaces/.n8n-opencode/server.log`. That directory also holds the server
|
||||||
|
credentials. It is readable only by its owner.
|
||||||
|
An unhealthy server produces an error without stopping active work. Inspect
|
||||||
|
the log through `pnpm session:shell`. To restart it after checking active work,
|
||||||
|
run `tmux kill-session -t '=n8n-opencode-server'` in that shell. Then reconnect.
|
||||||
|
Restart the server after changing provider secrets, server configuration, or
|
||||||
|
the pinned harness release.
|
||||||
|
|
||||||
|
### Limits
|
||||||
|
|
||||||
|
- The launcher supports macOS and Linux. On Windows, run it in WSL. If the
|
||||||
|
browser does not open automatically, open the printed URL yourself.
|
||||||
|
- Local clipboard and attachment controls depend on the client, terminal,
|
||||||
|
file type, and model. A laptop file path does not copy a file to the Codespace.
|
||||||
|
Use a supported attachment control or copy the file with `gh codespace cp`.
|
||||||
|
- Tools and local MCP processes run on the Codespace. Laptop configuration,
|
||||||
|
browser sessions, and files do not sync automatically.
|
||||||
|
- Workspace names identify worktrees. Two agents that use the same name share
|
||||||
|
files. Separate conversations alone do not isolate edits.
|
||||||
|
- The server survives a client disconnect while the Codespace stays running.
|
||||||
|
Codespaces idle timeouts still apply. An open tunnel is not a guarantee that
|
||||||
|
the Codespace will stay awake. Use `pnpm session stop` to stop compute billing.
|
||||||
|
- Existing tmux OpenCode conversations are not migrated automatically. Use
|
||||||
|
`--legacy` to return to them.
|
||||||
|
|
||||||
|
For upstream behavior, see the [OpenCode CLI](https://opencode.ai/docs/cli/),
|
||||||
|
[server](https://opencode.ai/docs/server/), and [web](https://opencode.ai/docs/web/)
|
||||||
|
documentation.
|
||||||
|
|
||||||
## PR previews (a running instance of someone else's PR)
|
## PR previews (a running instance of someone else's PR)
|
||||||
|
|
||||||
|
|
@ -59,12 +227,17 @@ PR instead of reading it. It is a different box from a `pnpm session`: it uses
|
||||||
[util-codespace-preview.yml](../../.github/workflows/util-codespace-preview.yml)
|
[util-codespace-preview.yml](../../.github/workflows/util-codespace-preview.yml)
|
||||||
creates the box, serves the PR head, shares port 5678 with the org, and comments
|
creates the box, serves the PR head, shares port 5678 with the org, and comments
|
||||||
the URL on the PR. A later push serves the new head in the same box. Remove the
|
the URL on the PR. A later push serves the new head in the same box. Remove the
|
||||||
label, or close the PR, to delete the box.
|
label, or close the PR, to delete the box. The same workflow runs by hand from
|
||||||
|
the Actions tab: give it a PR number and `up`, `refresh` or `down`.
|
||||||
|
|
||||||
**From your laptop:** `pnpm preview up <pr>` does the same thing, plus
|
**From your laptop:** `pnpm preview up <pr>` does the same thing, plus
|
||||||
`pnpm preview refresh <pr>`, `pnpm preview down <pr>` and `pnpm preview ls`. It
|
`pnpm preview refresh <pr>`, `pnpm preview down <pr>` and `pnpm preview ls`. It
|
||||||
needs `gh` with the codespace scope, the same as `pnpm session`.
|
needs `gh` with the codespace scope, the same as `pnpm session`.
|
||||||
|
|
||||||
|
- **Watch it come up on the PR.** The comment appears before the box work starts
|
||||||
|
and updates about once a minute with a checklist of the phases, so you can see
|
||||||
|
which step a slow preview is on. `pnpm preview up <pr>` prints the same phases as
|
||||||
|
plain progress — the markers the comment reads are `--json` only.
|
||||||
- **Sign in with one click** at `<url>/preview-signin`. It logs you in as the
|
- **Sign in with one click** at `<url>/preview-signin`. It logs you in as the
|
||||||
seeded owner and sends you to the editor. The credentials are
|
seeded owner and sends you to the editor. The credentials are
|
||||||
`preview@n8n.io` / `PreviewInstance1`. They are not secrets: the boundary is
|
`preview@n8n.io` / `PreviewInstance1`. They are not secrets: the boundary is
|
||||||
|
|
@ -75,12 +248,22 @@ needs `gh` with the codespace scope, the same as `pnpm session`.
|
||||||
present. `preview:debug` sets `N8N_LOG_LEVEL=debug`. Adding or removing one
|
present. `preview:debug` sets `N8N_LOG_LEVEL=debug`. Adding or removing one
|
||||||
re-serves the box; it never creates or deletes one. From a laptop the labels
|
re-serves the box; it never creates or deletes one. From a laptop the labels
|
||||||
apply the same way — `pnpm preview refresh <pr>` reads them from the PR. The
|
apply the same way — `pnpm preview refresh <pr>` reads them from the PR. The
|
||||||
toggles are defined in `scripts/preview-labels.mjs`; add new ones there.
|
toggles are defined in `scripts/codespace-preview/preview-labels.mjs`; add new ones there.
|
||||||
- **A preview sleeps after 30 minutes** of no use and GitHub deletes it after 24
|
- **Configure the instance from a webhook.** A preview also reads extra
|
||||||
hours. Add the label again to get a new one.
|
environment from an n8n webhook, so a value can change without a commit. It
|
||||||
|
needs the `CODESPACE_ENV_URL`, `CODESPACE_ENV_USER` and `CODESPACE_ENV_PASSWORD`
|
||||||
|
codespace secrets. Every key the webhook returns becomes an environment
|
||||||
|
variable, so editing that workflow runs code in the box. Without the secrets
|
||||||
|
the preview serves as usual. See [WORKFLOWS.md](../../.github/WORKFLOWS.md).
|
||||||
|
- **A preview sleeps after 2 hours** of no use and GitHub deletes it after 24
|
||||||
|
hours. A box that slept serves nothing and its port is private again, so wake
|
||||||
|
it with `pnpm preview up <pr>` or a manual run of
|
||||||
|
[util-codespace-preview.yml](../../.github/workflows/util-codespace-preview.yml)
|
||||||
|
with `up`. Removing and adding the label works too, but it deletes the box and
|
||||||
|
builds a new one.
|
||||||
- **A PR from a fork gets no preview.** A codespace's token is scoped to
|
- **A PR from a fork gets no preview.** A codespace's token is scoped to
|
||||||
`n8n-io/n8n`, so it cannot check out a fork head.
|
`n8n-io/n8n`, so it cannot check out a fork head.
|
||||||
- **A PR that predates this tooling has no `scripts/preview-serve.mjs`.** The
|
- **A PR that predates this tooling has no `scripts/codespace-preview/preview-serve.mjs`.** The
|
||||||
serve step says so and stops; rebase the PR on master and retry.
|
serve step says so and stops; rebase the PR on master and retry.
|
||||||
|
|
||||||
## Agent worker (drive a session from n8n)
|
## Agent worker (drive a session from n8n)
|
||||||
|
|
@ -99,7 +282,12 @@ instead. It asks n8n for a turn addressed to this box's owner (`$GITHUB_USER`).
|
||||||
It runs the turn. It sends the result to the turn's resume URL. It uses no
|
It runs the turn. It sends the result to the turn's resume URL. It uses no
|
||||||
tunnel, no open port, and no domain.
|
tunnel, no open port, and no domain.
|
||||||
|
|
||||||
The worker starts on each container start (`postStartCommand`). It needs three
|
The post-start command installs the pinned OpenCode harness before it starts the
|
||||||
|
worker. It verifies a valid cached bundle before reuse. The worker does not start
|
||||||
|
if the harness is unavailable. `/tmp/post-start-status.json` contains the harness
|
||||||
|
and worker status.
|
||||||
|
|
||||||
|
The worker needs three
|
||||||
secrets and uses three optional secrets. Add them at
|
secrets and uses three optional secrets. Add them at
|
||||||
[github.com/settings/codespaces](https://github.com/settings/codespaces), the
|
[github.com/settings/codespaces](https://github.com/settings/codespaces), the
|
||||||
same way as `ANTHROPIC_API_KEY`:
|
same way as `ANTHROPIC_API_KEY`:
|
||||||
|
|
@ -119,8 +307,12 @@ worker posts one placeholder in that thread. It coalesces completed tool calls.
|
||||||
It updates the message at most once every 1.5 seconds. It does not send reasoning
|
It updates the message at most once every 1.5 seconds. It does not send reasoning
|
||||||
text. The worker replaces the placeholder with the final answer.
|
text. The worker replaces the placeholder with the final answer.
|
||||||
If the Slack API fails, the turn still completes through the n8n resume URL.
|
If the Slack API fails, the turn still completes through the n8n resume URL.
|
||||||
The worker does not export its dequeue or Slack credentials to OpenCode.
|
The worker does not export its dequeue or Slack credentials to OpenCode. It uses
|
||||||
|
the harness `sandbox` runtime and `slack` profile. The profile supplies the
|
||||||
|
atomic-turn instruction.
|
||||||
Interactive sessions remove all worker-only credentials before they start.
|
Interactive sessions remove all worker-only credentials before they start.
|
||||||
|
Interactive OpenCode uses the global harness plugin with the `sandbox` runtime.
|
||||||
|
It does not set a profile. It keeps the dynamic OpenRouter configuration.
|
||||||
|
|
||||||
An idle worker starts with a 3-second poll interval. After each empty dequeue,
|
An idle worker starts with a 3-second poll interval. After each empty dequeue,
|
||||||
it doubles the interval and limits it to 30 seconds. Work resets the interval
|
it doubles the interval and limits it to 30 seconds. Work resets the interval
|
||||||
|
|
@ -134,16 +326,15 @@ A turn stops after about 25 minutes (`TURN_TIMEOUT_MS`). This limit is below the
|
||||||
n8n Wait limit. So the worker reports a clear message before n8n reports a
|
n8n Wait limit. So the worker reports a clear message before n8n reports a
|
||||||
generic timeout. Keep the worker limit below the n8n limit if you change either.
|
generic timeout. Keep the worker limit below the n8n limit if you change either.
|
||||||
|
|
||||||
**A turn is atomic, and the worker tells the session so.** The turn ends on the
|
**A turn is atomic, and the harness tells the session so.** The turn ends on the
|
||||||
session's final message, and its children end with it: a background `Bash` task
|
session's final message, and its children end with it: a background `Bash` task
|
||||||
is killed, `Monitor` events never arrive, `PushNotification` has nowhere to go,
|
is killed, `Monitor` events never arrive, `PushNotification` has nowhere to go,
|
||||||
and `ScheduleWakeup` never fires. The session also gets no turn of its own to
|
and `ScheduleWakeup` never fires. The session also gets no turn of its own to
|
||||||
report back in — the turn's resume URL continues one waiting n8n execution and is
|
report back in — the turn's resume URL continues one waiting n8n execution and is
|
||||||
then spent, so nothing on the box can post to the thread unprompted. A session
|
then spent, so nothing on the box can post to the thread unprompted. A session
|
||||||
that backgrounds a build and signs off with "I'll verify once it finishes" is
|
that backgrounds a build and signs off with "I'll verify once it finishes" is
|
||||||
therefore describing something that cannot happen. The worker states this in
|
therefore describing something that cannot happen. The harness `slack` profile
|
||||||
each OpenCode prompt (`turnContract`), together with a pointer to this file for
|
states this contract. This is only the n8n/Slack path: an
|
||||||
the box-specific parts. This is only the n8n/Slack path: an
|
|
||||||
interactive session (`pnpm session`, tmux) is long-lived, so background work,
|
interactive session (`pnpm session`, tmux) is long-lived, so background work,
|
||||||
monitors and notifications behave normally there.
|
monitors and notifications behave normally there.
|
||||||
|
|
||||||
|
|
@ -186,11 +377,15 @@ session rarely needs a cold `pnpm install` or a full `pnpm build`. Both are slow
|
||||||
Claude sessions and the headless OpenCode worker get the `flaky` MCP server automatically: Currents
|
Claude sessions and the headless OpenCode worker get the `flaky` MCP server automatically: Currents
|
||||||
flaky/quarantine data, the `qa_*` BigQuery dataset, Sentry RCA, live Linear,
|
flaky/quarantine data, the `qa_*` BigQuery dataset, Sentry RCA, live Linear,
|
||||||
and repo investigation. The worker keeps the token in its environment and puts
|
and repo investigation. The worker keeps the token in its environment and puts
|
||||||
only an environment reference in the OpenCode config. Claude login registers
|
only an environment reference in the OpenCode config. Forks have no secrets and
|
||||||
the same server without writing the token to disk. Forks have no secrets and
|
|
||||||
skip it. Tell the agent to call `get_flaky_context` first — it returns the rules
|
skip it. Tell the agent to call `get_flaky_context` first — it returns the rules
|
||||||
the tools assume.
|
the tools assume.
|
||||||
|
|
||||||
|
`post-start.mjs` registers the server for Claude Code on each container start.
|
||||||
|
Its `headersHelper` reads the token from the secrets file on each connect, so
|
||||||
|
the server works in every client. The token is not copied into the Claude Code
|
||||||
|
MCP configuration.
|
||||||
|
|
||||||
## Quality and security skills (Claude plugins)
|
## Quality and security skills (Claude plugins)
|
||||||
|
|
||||||
Claude sessions can also load the private skills from the
|
Claude sessions can also load the private skills from the
|
||||||
|
|
@ -252,7 +447,8 @@ to pull the skills into context.
|
||||||
|
|
||||||
## Viewing the dev UI locally
|
## Viewing the dev UI locally
|
||||||
|
|
||||||
Two terminal windows:
|
`pnpm session tunnel` works with every client. With the terminal client, use
|
||||||
|
two terminal windows:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm session # window 1: attach the agent session
|
pnpm session # window 1: attach the agent session
|
||||||
|
|
@ -282,7 +478,7 @@ partial mapping breaks it.
|
||||||
| Event | Running processes | Disk (checkout, worktrees, chat history) |
|
| Event | Running processes | Disk (checkout, worktrees, chat history) |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Detach / close laptop / network drop | ✅ keep running | ✅ |
|
| Detach / close laptop / network drop | ✅ keep running | ✅ |
|
||||||
| Stop, or idle timeout (default 30 min, max 4 h) | ❌ killed | ✅ |
|
| Stop, or idle timeout (2 h for a codespace that `pnpm session` creates, max 4 h) | ❌ killed | ✅ |
|
||||||
| Delete (`pnpm session rm`) | ❌ | ❌ (push your branches first) |
|
| Delete (`pnpm session rm`) | ❌ | ❌ (push your branches first) |
|
||||||
|
|
||||||
After a stop, `pnpm session <name>` restarts the codespace (~30–60 s); run
|
After a stop, `pnpm session <name>` restarts the codespace (~30–60 s); run
|
||||||
|
|
@ -302,10 +498,10 @@ After a stop, `pnpm session <name>` restarts the codespace (~30–60 s); run
|
||||||
agent injects them into VS Code sessions only; they're delivered
|
agent injects them into VS Code sessions only; they're delivered
|
||||||
base64-encoded to `/workspaces/.codespaces/shared/.env-secrets`. The image
|
base64-encoded to `/workspaces/.codespaces/shared/.env-secrets`. The image
|
||||||
sources `/usr/local/lib/codespaces-env.sh` in login shells (profile.d), in
|
sources `/usr/local/lib/codespaces-env.sh` in login shells (profile.d), in
|
||||||
interactive shells (bashrc), and in the `pnpm session` prelude. If Claude
|
interactive shells (bashrc), and in the `pnpm session` prelude. Desktop app
|
||||||
Code shows `Missing environment variables: FLAKY_MCP_TOKEN`, the shell that
|
sessions do not source it. `git`, `gh`, `scripts/codespace-env.mjs`, and the
|
||||||
started Claude did not source the file. Run
|
`flaky` MCP entry read the file when they run, so they work everywhere. New
|
||||||
`. /usr/local/lib/codespaces-env.sh` and start Claude again.
|
code that needs a secret must do the same.
|
||||||
- **Do not read `CODESPACE_NAME` or `GITHUB_USER` from the process env** — use
|
- **Do not read `CODESPACE_NAME` or `GITHUB_USER` from the process env** — use
|
||||||
`scripts/codespace-env.mjs`. Codespaces gives these variables to VS Code
|
`scripts/codespace-env.mjs`. Codespaces gives these variables to VS Code
|
||||||
sessions only. Other processes read them from `codespaces-env.sh`, and a
|
sessions only. Other processes read them from `codespaces-env.sh`, and a
|
||||||
|
|
@ -314,7 +510,7 @@ After a stop, `pnpm session <name>` restarts the codespace (~30–60 s); run
|
||||||
polled correctly as its owner while `dev:up` in the same session saw an empty
|
polled correctly as its owner while `dev:up` in the same session saw an empty
|
||||||
box name, printed the localhost URL, and did not share the port. The helper
|
box name, printed the localhost URL, and did not share the port. The helper
|
||||||
reads `/workspaces/.codespaces/shared`, which is always correct.
|
reads `/workspaces/.codespaces/shared`, which is always correct.
|
||||||
- **You cannot paste images into a remote Claude session.** Image paste reads
|
- **You cannot paste images into a terminal Claude session.** Image paste reads
|
||||||
the clipboard of the machine where `claude` runs — the codespace, not your
|
the clipboard of the machine where `claude` runs — the codespace, not your
|
||||||
laptop. Drag the file into the VS Code explorer (or
|
laptop. Drag the file into the VS Code explorer (or
|
||||||
`gh codespace cp shot.png remote:/workspaces/n8n/`) and give Claude the
|
`gh codespace cp shot.png remote:/workspaces/n8n/`) and give Claude the
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ export function openCodeEnvironment(environment) {
|
||||||
delete childEnvironment.N8N_DEQUEUE_URL;
|
delete childEnvironment.N8N_DEQUEUE_URL;
|
||||||
delete childEnvironment.SLACK_BOT_TOKEN;
|
delete childEnvironment.SLACK_BOT_TOKEN;
|
||||||
childEnvironment.OPENCODE_CONFIG_CONTENT = JSON.stringify(openCodeConfig(childEnvironment));
|
childEnvironment.OPENCODE_CONFIG_CONTENT = JSON.stringify(openCodeConfig(childEnvironment));
|
||||||
|
childEnvironment.N8N_AGENT_RUNTIME = 'sandbox';
|
||||||
|
childEnvironment.N8N_AGENT_PROFILE = 'slack';
|
||||||
return childEnvironment;
|
return childEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,37 +100,6 @@ const TURN_ENV = openCodeEnvironment(process.env);
|
||||||
if (BOX_ID) TURN_ENV.CODESPACE_NAME = BOX_ID;
|
if (BOX_ID) TURN_ENV.CODESPACE_NAME = BOX_ID;
|
||||||
if (GITHUB_USER) TURN_ENV.GITHUB_USER = GITHUB_USER;
|
if (GITHUB_USER) TURN_ENV.GITHUB_USER = GITHUB_USER;
|
||||||
|
|
||||||
const CODESPACE_DOCS = '.devcontainer/codespaces/README.md';
|
|
||||||
|
|
||||||
// The worker has no later turn, so each prompt must define the atomic runtime contract.
|
|
||||||
function turnContract(author) {
|
|
||||||
return [
|
|
||||||
'# Your runtime',
|
|
||||||
'You are one turn of a Slack thread, driven by an n8n workflow that runs you as a headless',
|
|
||||||
'OpenCode session on a GitHub codespace. Your final message is the reply that reaches Slack, so keep',
|
|
||||||
'it short and skip heavy markdown.',
|
|
||||||
author ? `You are replying to ${author}.` : '',
|
|
||||||
'',
|
|
||||||
'# A turn is atomic',
|
|
||||||
'The turn ends when you emit your final message, and everything you started ends with it:',
|
|
||||||
'background Bash tasks are killed, Monitor events never arrive, PushNotification has nowhere to',
|
|
||||||
'go, and ScheduleWakeup never fires. You get no turn of your own afterwards — you cannot speak',
|
|
||||||
'again until a human writes again. So run long work (builds, test suites, restarts) in the',
|
|
||||||
'foreground of this turn and wait for it, or do not start it at all. Never end a turn promising',
|
|
||||||
`to verify, check back, or follow up. Work that will not fit the turn limit of ~${Math.round(
|
|
||||||
TURN_TIMEOUT_MS / 60_000,
|
|
||||||
)} minutes`,
|
|
||||||
'should be split: do the part that fits, then say what to ask for next.',
|
|
||||||
'',
|
|
||||||
'# This box',
|
|
||||||
`You are on codespace ${BOX_ID ?? '(unknown)'}, not a laptop. Before you build, start, or expose`,
|
|
||||||
`the app, read ${CODESPACE_DOCS} ("Build and run the app in a session"). It is box-specific and`,
|
|
||||||
'the repo AGENTS.md does not cover it.',
|
|
||||||
]
|
|
||||||
.filter(Boolean)
|
|
||||||
.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
function safeCwd(cwd) {
|
function safeCwd(cwd) {
|
||||||
const safeCwd = resolvePath(typeof cwd === 'string' && cwd ? cwd : `${ROOT}/n8n`);
|
const safeCwd = resolvePath(typeof cwd === 'string' && cwd ? cwd : `${ROOT}/n8n`);
|
||||||
if (safeCwd !== ROOT && !safeCwd.startsWith(ROOT + sep))
|
if (safeCwd !== ROOT && !safeCwd.startsWith(ROOT + sep))
|
||||||
|
|
@ -150,7 +121,7 @@ function eventError(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runOpenCode(
|
export function runOpenCode(
|
||||||
{ message, sessionId, cwd, author },
|
{ message, sessionId, cwd },
|
||||||
onEvent,
|
onEvent,
|
||||||
onSession,
|
onSession,
|
||||||
{
|
{
|
||||||
|
|
@ -238,9 +209,7 @@ export function runOpenCode(
|
||||||
resolve({ result: text.join('\n').trim(), session_id: activeSessionId });
|
resolve({ result: text.join('\n').trim(), session_id: activeSessionId });
|
||||||
});
|
});
|
||||||
|
|
||||||
child.stdin.end(
|
child.stdin.end(message);
|
||||||
`${turnContract(typeof author === 'string' ? author : '')}\n\n# Request\n${message}`,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ test('reloads Codespaces secrets before the worker starts', () => {
|
||||||
postStart,
|
postStart,
|
||||||
/bash -lc "\. \/usr\/local\/lib\/codespaces-env\.sh; .*node \/workspaces\/n8n\/\.devcontainer\/codespaces\/agent-worker\.mjs/,
|
/bash -lc "\. \/usr\/local\/lib\/codespaces-env\.sh; .*node \/workspaces\/n8n\/\.devcontainer\/codespaces\/agent-worker\.mjs/,
|
||||||
);
|
);
|
||||||
|
assert.match(postStart, /installAgentHarness\(\)/);
|
||||||
|
assert.match(postStart, /harness\.status === 'active' &&\s+tryRun\('worker start'/);
|
||||||
|
assert.match(postStart, /JSON\.stringify\(\{ installed, failed, harness, workerStarted \}/);
|
||||||
});
|
});
|
||||||
|
|
||||||
function slackRecorder() {
|
function slackRecorder() {
|
||||||
|
|
@ -296,7 +299,7 @@ test('streams OpenCode CLI events and resumes an OpenCode session', async () =>
|
||||||
'ses_existing',
|
'ses_existing',
|
||||||
]);
|
]);
|
||||||
assert.equal(invocation.options.detached, true);
|
assert.equal(invocation.options.detached, true);
|
||||||
assert.match(prompt, /# Request\nTest message/);
|
assert.equal(prompt, 'Test message');
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
events.map((event) => event.type),
|
events.map((event) => event.type),
|
||||||
['step_start', 'tool_use', 'text'],
|
['step_start', 'tool_use', 'text'],
|
||||||
|
|
@ -345,6 +348,8 @@ test('keeps broker credentials out of the OpenCode process', () => {
|
||||||
ANTHROPIC_API_KEY: 'model',
|
ANTHROPIC_API_KEY: 'model',
|
||||||
OPENROUTER_API_KEY: 'openrouter',
|
OPENROUTER_API_KEY: 'openrouter',
|
||||||
GITHUB_TOKEN: 'github',
|
GITHUB_TOKEN: 'github',
|
||||||
|
N8N_AGENT_RUNTIME: 'sandbox',
|
||||||
|
N8N_AGENT_PROFILE: 'slack',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ if (args[0] === 'codespace' && args[1] === 'list') {
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
chmodSync(mockGh, 0o755);
|
chmodSync(mockGh, 0o755);
|
||||||
|
for (const [name, script] of Object.entries({
|
||||||
|
infocmp: '[ "$1" = "$SUPPORTED_TERM" ]',
|
||||||
|
tmux: 'printf "%s" "$TERM"',
|
||||||
|
})) {
|
||||||
|
const executable = join(fixtureDir, name);
|
||||||
|
writeFileSync(executable, `#!/bin/sh\n${script}\n`);
|
||||||
|
chmodSync(executable, 0o755);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => rmSync(fixtureDir, { recursive: true, force: true }));
|
after(() => rmSync(fixtureDir, { recursive: true, force: true }));
|
||||||
|
|
@ -58,18 +66,59 @@ function remoteCommand(args) {
|
||||||
return invocationArgs[6];
|
return invocationArgs[6];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const { name, supportedTerm, expectedTerm } of [
|
||||||
|
{
|
||||||
|
name: 'uses xterm-256color when the remote terminal definition is missing',
|
||||||
|
supportedTerm: 'xterm-256color',
|
||||||
|
expectedTerm: 'xterm-256color',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'keeps the terminal type when the remote definition is available',
|
||||||
|
supportedTerm: 'xterm-ghostty',
|
||||||
|
expectedTerm: 'xterm-ghostty',
|
||||||
|
},
|
||||||
|
]) {
|
||||||
|
test(name, () => {
|
||||||
|
const result = spawnSync('/bin/sh', ['-c', remoteCommand(['--opencode', '--legacy'])], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
PATH: `${fixtureDir}:${process.env.PATH}`,
|
||||||
|
TERM: 'xterm-ghostty',
|
||||||
|
SUPPORTED_TERM: supportedTerm,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(result.status, 0, result.stderr);
|
||||||
|
assert.equal(result.stdout, expectedTerm);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
test('starts a named OpenCode session in a worktree', () => {
|
test('starts a named OpenCode session in a worktree', () => {
|
||||||
const command = remoteCommand(['--opencode', 'fix-flaky', '--model', 'test']);
|
const command = remoteCommand(['--opencode', 'fix-flaky', '--legacy', '--model', 'test']);
|
||||||
|
|
||||||
assert.match(command, /tmux new -As fix-flaky-opencode/);
|
assert.match(command, /tmux new -As fix-flaky-opencode/);
|
||||||
assert.match(command, /unset AGENT_WORKER_TOKEN N8N_DEQUEUE_URL SLACK_BOT_TOKEN/);
|
assert.match(command, /unset AGENT_WORKER_TOKEN N8N_DEQUEUE_URL SLACK_BOT_TOKEN/);
|
||||||
assert.match(command, /OPENCODE_CONFIG_CONTENT/);
|
assert.match(command, /OPENCODE_CONFIG_CONTENT/);
|
||||||
assert.match(command, /git -C \/workspaces\/n8n worktree add "\/workspaces\/wt-fix-flaky"/);
|
assert.match(command, /export N8N_AGENT_RUNTIME=sandbox; unset N8N_AGENT_PROFILE/);
|
||||||
|
assert.match(
|
||||||
|
command,
|
||||||
|
/git -C \/workspaces\/n8n fetch origin master; git -C \/workspaces\/n8n worktree add --no-track -b "session\/fix-flaky" "\/workspaces\/wt-fix-flaky" origin\/master/,
|
||||||
|
);
|
||||||
assert.match(command, /cd "\/workspaces\/wt-fix-flaky" && opencode --auto --model test/);
|
assert.match(command, /cd "\/workspaces\/wt-fix-flaky" && opencode --auto --model test/);
|
||||||
assert.doesNotMatch(command, /unset OPENROUTER_API_KEY/);
|
assert.doesNotMatch(command, /unset OPENROUTER_API_KEY/);
|
||||||
assert.doesNotMatch(command, /claude plugin/);
|
assert.doesNotMatch(command, /claude plugin/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('forwards legacy flags without a workspace name to the main checkout', () => {
|
||||||
|
for (const flags of [['--help'], ['--model', 'test']]) {
|
||||||
|
const command = remoteCommand(['--opencode', '--legacy', ...flags]);
|
||||||
|
assert.match(command, /tmux new -As agent-opencode/);
|
||||||
|
assert.ok(command.includes(`cd /workspaces/n8n && opencode --auto ${flags.join(' ')}`));
|
||||||
|
assert.doesNotMatch(command, /git .*worktree add/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('keeps removed credentials out of the login shell', () => {
|
test('keeps removed credentials out of the login shell', () => {
|
||||||
const command = remoteCommand(['--shell']);
|
const command = remoteCommand(['--shell']);
|
||||||
const profile = readFileSync(new URL('./codespaces-secrets.sh', import.meta.url), 'utf8');
|
const profile = readFileSync(new URL('./codespaces-secrets.sh', import.meta.url), 'utf8');
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,6 @@
|
||||||
'{"hasCompletedOnboarding":true,"theme":"dark","projects":{"/workspaces/n8n":{"hasTrustDialogAccepted":true}}}' \
|
'{"hasCompletedOnboarding":true,"theme":"dark","projects":{"/workspaces/n8n":{"hasTrustDialogAccepted":true}}}' \
|
||||||
>"$HOME/.claude.json"
|
>"$HOME/.claude.json"
|
||||||
|
|
||||||
# Register the Flaky MCP server for Claude Code. The config keeps a literal
|
|
||||||
# ${FLAKY_MCP_TOKEN}; Claude Code expands it at connect time, so the token is
|
|
||||||
# not written to disk. Forks have no repo secrets and skip this.
|
|
||||||
if [ -n "$FLAKY_MCP_URL" ] && ! grep -qs '"flaky"' "$HOME/.claude.json" && command -v claude >/dev/null 2>&1; then
|
|
||||||
claude mcp add --scope user --transport http flaky "$FLAKY_MCP_URL" \
|
|
||||||
--header 'Authorization: Bearer ${FLAKY_MCP_TOKEN}' >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Register the credential helper in the user config, because Codespaces
|
# Register the credential helper in the user config, because Codespaces
|
||||||
# regenerates the managed /etc/gitconfig. When the env token is missing, the
|
# regenerates the managed /etc/gitconfig. When the env token is missing, the
|
||||||
# system helper exits 0 without output, and git falls through to ours.
|
# system helper exits 0 without output, and git falls through to ours.
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,17 @@
|
||||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
||||||
},
|
},
|
||||||
"forwardPorts": [8080, 5678],
|
"forwardPorts": [8080, 5678],
|
||||||
// Grant the codespace's own GitHub token read access to the private skills
|
|
||||||
// marketplace (same org), so Claude can install it with the codespace's normal
|
|
||||||
// git auth — no extra PAT. Each user authorizes this once at codespace creation.
|
|
||||||
"customizations": {
|
"customizations": {
|
||||||
|
// Claude Code in VS Code or the browser editor. It runs in the codespace.
|
||||||
|
"vscode": {
|
||||||
|
"extensions": ["anthropic.claude-code"]
|
||||||
|
},
|
||||||
|
// Grant the Codespace token read access to the private skills and harness repositories.
|
||||||
|
// Each user authorizes this access once when they create the Codespace.
|
||||||
"codespaces": {
|
"codespaces": {
|
||||||
"repositories": {
|
"repositories": {
|
||||||
"n8n-io/n8n-agent-skills": { "permissions": { "contents": "read" } }
|
"n8n-io/n8n-agent-skills": { "permissions": { "contents": "read" } },
|
||||||
|
"n8n-io/cat-bot": { "permissions": { "contents": "read" } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
36
.devcontainer/codespaces/fake-bin.mjs
Normal file
36
.devcontainer/codespaces/fake-bin.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Fake executables for tests. Each shim is a Node script. It receives `args`, `root`,
|
||||||
|
// `file(name)` under the root, and `log(event)`, which appends to calls.jsonl in the root.
|
||||||
|
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
|
||||||
|
const COMMON = `
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const root = process.env.TEST_ROOT;
|
||||||
|
const file = (name) => path.join(root, name);
|
||||||
|
const log = (event) => fs.appendFileSync(file('calls.jsonl'), JSON.stringify(event) + '\\n');
|
||||||
|
`;
|
||||||
|
|
||||||
|
export function fakeBinaries(prefix) {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), prefix));
|
||||||
|
const binDir = join(root, 'bin');
|
||||||
|
mkdirSync(binDir);
|
||||||
|
const logFile = join(root, 'calls.jsonl');
|
||||||
|
writeFileSync(logFile, '');
|
||||||
|
return {
|
||||||
|
root,
|
||||||
|
env: { PATH: `${binDir}:${process.env.PATH}`, TEST_ROOT: root },
|
||||||
|
bin: (name, body) =>
|
||||||
|
writeFileSync(join(binDir, name), `#!${process.execPath}\n${COMMON}\n${body}`, {
|
||||||
|
mode: 0o755,
|
||||||
|
}),
|
||||||
|
calls: () =>
|
||||||
|
readFileSync(logFile, 'utf8')
|
||||||
|
.trim()
|
||||||
|
.split('\n')
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((line) => JSON.parse(line)),
|
||||||
|
};
|
||||||
|
}
|
||||||
224
.devcontainer/codespaces/opencode-client.test.mjs
Normal file
224
.devcontainer/codespaces/opencode-client.test.mjs
Normal file
|
|
@ -0,0 +1,224 @@
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import { rmSync, readFileSync } from 'node:fs';
|
||||||
|
import { test } from 'node:test';
|
||||||
|
import { setTimeout as delay } from 'node:timers/promises';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
import { fakeBinaries } from './fake-bin.mjs';
|
||||||
|
import { parseOpenCodeArgs } from '../../scripts/cloud-session-opencode.mjs';
|
||||||
|
|
||||||
|
const script = fileURLToPath(new URL('../../scripts/cloud-session.mjs', import.meta.url));
|
||||||
|
const secret = 'a'.repeat(64);
|
||||||
|
|
||||||
|
function fixture(t, env = {}) {
|
||||||
|
const { root, bin, calls, env: binEnv } = fakeBinaries('opencode-client-');
|
||||||
|
t.after(() => rmSync(root, { recursive: true, force: true }));
|
||||||
|
bin(
|
||||||
|
'gh',
|
||||||
|
`
|
||||||
|
log({ command: 'gh', args });
|
||||||
|
if (args[0] === 'codespace' && args[1] === 'list') {
|
||||||
|
console.log(JSON.stringify([
|
||||||
|
{ name: 'dev-box', state: 'Available' },
|
||||||
|
]));
|
||||||
|
} else if (args.includes('-N')) {
|
||||||
|
if (process.env.TEST_TUNNEL_FAIL) process.exit(1);
|
||||||
|
const mapping = args[args.indexOf('-L') + 1];
|
||||||
|
const port = +mapping.split(':')[1];
|
||||||
|
const ssh = require('node:child_process').spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { stdio: 'ignore' });
|
||||||
|
log({ event: 'ssh-child', pid: ssh.pid });
|
||||||
|
const server = require('node:http').createServer((req, res) => {
|
||||||
|
const expected = 'Basic ' + Buffer.from('opencode:' + '${secret}').toString('base64');
|
||||||
|
if (process.env.TEST_UNAUTHORIZED || req.headers.authorization !== expected) { res.writeHead(401).end(); return; }
|
||||||
|
res.setHeader('content-type', 'application/json');
|
||||||
|
res.end(JSON.stringify({ healthy: true, version: process.env.TEST_SERVER_VERSION || '1.2.3' }));
|
||||||
|
});
|
||||||
|
server.listen(port, '127.0.0.1');
|
||||||
|
if (process.env.TEST_TUNNEL_DROP) setTimeout(() => process.exit(1), 500);
|
||||||
|
process.on('SIGTERM', () => { log({ event: 'tunnel-stopped' }); server.closeAllConnections(); server.close(() => process.exit(0)); });
|
||||||
|
} else if (args.at(-1).includes('node --input-type=module')) {
|
||||||
|
let source = '';
|
||||||
|
process.stdin.on('data', chunk => source += chunk);
|
||||||
|
process.stdin.on('end', () => {
|
||||||
|
log({ event: 'bootstrap', hasSource: source.includes('prepareOpenCode') });
|
||||||
|
if (process.env.TEST_BOOTSTRAP_FAIL) process.exit(1);
|
||||||
|
const parts = args.at(-1).split(' ');
|
||||||
|
const name = parts.at(-3);
|
||||||
|
const fresh = parts.at(-2) === 'true';
|
||||||
|
const web = parts.at(-1) === 'true';
|
||||||
|
console.log(JSON.stringify({ port: 4242, password: '${secret}',
|
||||||
|
...(fresh && !web ? {} : { sessionID: 'ses_saved' }),
|
||||||
|
directory: name === 'agent' ? '/workspaces/n8n' : '/workspaces/wt-' + name }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
bin(
|
||||||
|
'opencode',
|
||||||
|
`
|
||||||
|
if (args[0] === '--version') {
|
||||||
|
if (process.env.TEST_NO_CLIENT) process.exit(1);
|
||||||
|
console.log(process.env.TEST_CLIENT_VERSION || '1.2.3');
|
||||||
|
} else {
|
||||||
|
log({ command: 'opencode', args, password: process.env.OPENCODE_SERVER_PASSWORD });
|
||||||
|
if (process.env.TEST_CLIENT_WAIT) setInterval(() => {}, 1000);
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
for (const opener of ['open', 'xdg-open']) bin(opener, `log({ command: 'browser', args });`);
|
||||||
|
return {
|
||||||
|
calls,
|
||||||
|
start(args) {
|
||||||
|
const child = spawn(process.execPath, [script, '--opencode', ...args], {
|
||||||
|
env: { ...process.env, ...binEnv, ...env },
|
||||||
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
});
|
||||||
|
let output = '';
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
output += chunk;
|
||||||
|
});
|
||||||
|
child.stderr.on('data', (chunk) => {
|
||||||
|
output += chunk;
|
||||||
|
});
|
||||||
|
const done = new Promise((resolve) => child.on('exit', (code) => resolve({ code, output })));
|
||||||
|
t.after(() => child.kill('SIGKILL'));
|
||||||
|
return { child, done };
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitFor(check) {
|
||||||
|
for (let attempt = 0; attempt < 100; attempt++) {
|
||||||
|
const result = check();
|
||||||
|
if (result) return result;
|
||||||
|
await delay(50);
|
||||||
|
}
|
||||||
|
throw new Error('Fixture did not become ready.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// An orphaned fixture process can linger as a zombie where PID 1 does not reap
|
||||||
|
// it, and kill(pid, 0) still succeeds for one. Read the process state where the
|
||||||
|
// kernel exposes it; without /proc only the signal error can tell.
|
||||||
|
function stopped(pid) {
|
||||||
|
try {
|
||||||
|
process.kill(pid, 0);
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return readFileSync(`/proc/${pid}/stat`, 'utf8').split(' ')[2] === 'Z';
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('parses options before or after the workspace and rejects unsupported flags', () => {
|
||||||
|
assert.equal(parseOpenCodeArgs(['--web']).port, 4096);
|
||||||
|
assert.equal(parseOpenCodeArgs([]).port, 0);
|
||||||
|
assert.equal(parseOpenCodeArgs(['--port', '4100', '--web']).port, 4100);
|
||||||
|
assert.deepEqual(parseOpenCodeArgs(['--web', 'fix-flaky', '--new', '--port', '4100']), {
|
||||||
|
name: 'fix-flaky',
|
||||||
|
web: true,
|
||||||
|
fresh: true,
|
||||||
|
port: 4100,
|
||||||
|
});
|
||||||
|
for (const args of [
|
||||||
|
['--port'],
|
||||||
|
['--port', '0'],
|
||||||
|
['--port', '65536'],
|
||||||
|
['--model', 'test'],
|
||||||
|
['a/b'],
|
||||||
|
['one', 'two'],
|
||||||
|
]) {
|
||||||
|
assert.throws(() => parseOpenCodeArgs(args));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'attaches the local TUI to the selected workspace and closes the whole tunnel',
|
||||||
|
{ timeout: 15000 },
|
||||||
|
async (t) => {
|
||||||
|
const f = fixture(t);
|
||||||
|
const result = await f.start(['fix-flaky']).done;
|
||||||
|
assert.equal(result.code, 0, result.output);
|
||||||
|
const calls = f.calls();
|
||||||
|
assert.ok(calls.find((call) => call.event === 'bootstrap').hasSource);
|
||||||
|
assert.ok(
|
||||||
|
calls
|
||||||
|
.filter((call) => call.command === 'gh' && call.args[1] === 'ssh')
|
||||||
|
.every((call) => call.args[3] === 'dev-box'),
|
||||||
|
);
|
||||||
|
const tunnel = calls.find((call) => call.command === 'gh' && call.args.includes('-N'));
|
||||||
|
assert.match(tunnel.args.at(-1), /^127\.0\.0\.1:\d+:127\.0\.0\.1:4242$/);
|
||||||
|
const client = calls.find((call) => call.command === 'opencode');
|
||||||
|
assert.deepEqual(client.args.slice(2), [
|
||||||
|
'--dir',
|
||||||
|
'/workspaces/wt-fix-flaky',
|
||||||
|
'--session',
|
||||||
|
'ses_saved',
|
||||||
|
]);
|
||||||
|
assert.equal(client.password, secret);
|
||||||
|
assert.ok(!result.output.includes(secret));
|
||||||
|
assert.ok(calls.some((call) => call.event === 'tunnel-stopped'));
|
||||||
|
const pid = calls.find((call) => call.event === 'ssh-child').pid;
|
||||||
|
await waitFor(() => stopped(pid));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('starts a new conversation for --new instead of continuing', { timeout: 15000 }, async (t) => {
|
||||||
|
const f = fixture(t);
|
||||||
|
const result = await f.start(['fix-flaky', '--new']).done;
|
||||||
|
assert.equal(result.code, 0, result.output);
|
||||||
|
const client = f.calls().find((call) => call.command === 'opencode');
|
||||||
|
assert.deepEqual(client.args.slice(2), ['--dir', '/workspaces/wt-fix-flaky']);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const signal of ['SIGINT', 'SIGHUP']) {
|
||||||
|
test(
|
||||||
|
`opens the newest web conversation and cleans up on ${signal}`,
|
||||||
|
{ timeout: 15000 },
|
||||||
|
async (t) => {
|
||||||
|
const f = fixture(t, { TEST_NO_CLIENT: '1' });
|
||||||
|
const run = f.start(['--web', 'fix-flaky']);
|
||||||
|
const browser = await waitFor(() => f.calls().find((call) => call.command === 'browser'));
|
||||||
|
const url = new URL(browser.args[0]);
|
||||||
|
assert.equal(
|
||||||
|
url.pathname,
|
||||||
|
`/${Buffer.from('/workspaces/wt-fix-flaky').toString('base64url')}/session/ses_saved`,
|
||||||
|
);
|
||||||
|
assert.equal(url.password, '');
|
||||||
|
const response = await fetch(`${url.origin}/global/health`);
|
||||||
|
assert.equal(response.status, 200);
|
||||||
|
await response.text();
|
||||||
|
run.child.kill(signal);
|
||||||
|
const result = await run.done;
|
||||||
|
assert.equal(result.code, 0, result.output);
|
||||||
|
assert.ok(f.calls().some((call) => call.event === 'tunnel-stopped'));
|
||||||
|
await assert.rejects(fetch(url.origin));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [label, env, message] of [
|
||||||
|
[
|
||||||
|
'a version mismatch',
|
||||||
|
{ TEST_SERVER_VERSION: '1.14.22' },
|
||||||
|
/versions differ.*npm install -g opencode-ai@1\.14\.22/,
|
||||||
|
],
|
||||||
|
['an authentication failure', { TEST_UNAUTHORIZED: '1' }, /health check failed \(401\)/],
|
||||||
|
['a tunnel startup failure', { TEST_TUNNEL_FAIL: '1' }, /SSH tunnel closed/],
|
||||||
|
['a remote preparation failure', { TEST_BOOTSTRAP_FAIL: '1' }, /Could not prepare/],
|
||||||
|
['a missing local client', { TEST_NO_CLIENT: '1' }, /Install OpenCode locally/],
|
||||||
|
['a connection loss', { TEST_CLIENT_WAIT: '1', TEST_TUNNEL_DROP: '1' }, /SSH connection closed/],
|
||||||
|
]) {
|
||||||
|
test(`reports ${label} without printing credentials`, { timeout: 15000 }, async (t) => {
|
||||||
|
const f = fixture(t, env);
|
||||||
|
const result = await f.start([]).done;
|
||||||
|
assert.equal(result.code, 1, result.output);
|
||||||
|
assert.match(result.output, message);
|
||||||
|
assert.ok(!result.output.includes(secret));
|
||||||
|
if (label !== 'a connection loss')
|
||||||
|
assert.ok(!f.calls().some((call) => call.command === 'opencode'));
|
||||||
|
});
|
||||||
|
}
|
||||||
147
.devcontainer/codespaces/opencode-proxy.test.mjs
Normal file
147
.devcontainer/codespaces/opencode-proxy.test.mjs
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { createServer, request } from 'node:http';
|
||||||
|
import { connect } from 'node:net';
|
||||||
|
import { test } from 'node:test';
|
||||||
|
|
||||||
|
import { openCodeProxy } from '../../scripts/cloud-session-opencode-proxy.mjs';
|
||||||
|
|
||||||
|
test('proxies uploads and event streams with authentication and rejects other origins', async (t) => {
|
||||||
|
const requests = [];
|
||||||
|
const backend = createServer(async (req, res) => {
|
||||||
|
requests.push(req.headers);
|
||||||
|
res.writeHead(200, { 'content-type': 'text/event-stream' });
|
||||||
|
for await (const chunk of req) res.write(chunk);
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
await new Promise((resolve) => backend.listen(0, '127.0.0.1', resolve));
|
||||||
|
t.after(() => {
|
||||||
|
backend.closeAllConnections();
|
||||||
|
backend.close();
|
||||||
|
});
|
||||||
|
const proxy = await openCodeProxy({ password: 'test-secret' });
|
||||||
|
proxy.targetPort = backend.address().port;
|
||||||
|
t.after(proxy.close);
|
||||||
|
const response = await fetch(`${proxy.origin}/session`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: 'data: attached image\n\n',
|
||||||
|
headers: { origin: proxy.origin },
|
||||||
|
});
|
||||||
|
assert.equal(response.status, 200);
|
||||||
|
assert.equal(await response.text(), 'data: attached image\n\n');
|
||||||
|
assert.equal(
|
||||||
|
requests[0].authorization,
|
||||||
|
`Basic ${Buffer.from('opencode:test-secret').toString('base64')}`,
|
||||||
|
);
|
||||||
|
assert.ok(!proxy.origin.includes('test-secret'));
|
||||||
|
for (const headers of [
|
||||||
|
{ origin: 'https://example.com' },
|
||||||
|
{ host: 'example.com' },
|
||||||
|
{ 'sec-fetch-site': 'cross-site' },
|
||||||
|
]) {
|
||||||
|
const status = await new Promise((resolve, reject) => {
|
||||||
|
const req = request(proxy.origin, { headers }, (response) => {
|
||||||
|
response.resume();
|
||||||
|
resolve(response.statusCode);
|
||||||
|
});
|
||||||
|
req.on('error', reject);
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
assert.equal(status, 403);
|
||||||
|
}
|
||||||
|
assert.equal(requests.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('forwards WebSocket upgrades and closes their sockets', async (t) => {
|
||||||
|
const peers = new Set();
|
||||||
|
const backend = createServer();
|
||||||
|
backend.on('upgrade', (req, socket) => {
|
||||||
|
assert.equal(
|
||||||
|
req.headers.authorization,
|
||||||
|
`Basic ${Buffer.from('opencode:test-secret').toString('base64')}`,
|
||||||
|
);
|
||||||
|
peers.add(socket);
|
||||||
|
socket.on('close', () => peers.delete(socket));
|
||||||
|
socket.write(
|
||||||
|
'HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nUpgrade: websocket\r\n\r\n',
|
||||||
|
);
|
||||||
|
socket.pipe(socket);
|
||||||
|
});
|
||||||
|
await new Promise((resolve) => backend.listen(0, '127.0.0.1', resolve));
|
||||||
|
t.after(() => {
|
||||||
|
for (const peer of peers) peer.destroy();
|
||||||
|
backend.close();
|
||||||
|
});
|
||||||
|
const proxy = await openCodeProxy({ password: 'test-secret' });
|
||||||
|
proxy.targetPort = backend.address().port;
|
||||||
|
t.after(proxy.close);
|
||||||
|
const socket = await new Promise((resolve, reject) => {
|
||||||
|
const req = request(`${proxy.origin}/pty/test/connect`, {
|
||||||
|
headers: { origin: proxy.origin, connection: 'Upgrade', upgrade: 'websocket' },
|
||||||
|
});
|
||||||
|
req.on('upgrade', (_response, peer) => resolve(peer));
|
||||||
|
req.on('error', reject);
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
t.after(() => socket.destroy());
|
||||||
|
const echoed = new Promise((resolve) => socket.once('data', (data) => resolve(data.toString())));
|
||||||
|
socket.write('terminal input');
|
||||||
|
assert.equal(await echoed, 'terminal input');
|
||||||
|
const closed = new Promise((resolve) => socket.once('close', resolve));
|
||||||
|
proxy.close();
|
||||||
|
await closed;
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'closes the browser response when the upstream stream disconnects',
|
||||||
|
{ timeout: 5000 },
|
||||||
|
async (t) => {
|
||||||
|
const backend = createServer((_req, res) => {
|
||||||
|
res.writeHead(200, { 'content-type': 'text/event-stream' });
|
||||||
|
res.write('data: partial\n\n');
|
||||||
|
setTimeout(() => res.destroy(), 50);
|
||||||
|
});
|
||||||
|
await new Promise((resolve) => backend.listen(0, '127.0.0.1', resolve));
|
||||||
|
t.after(() => {
|
||||||
|
backend.closeAllConnections();
|
||||||
|
backend.close();
|
||||||
|
});
|
||||||
|
const proxy = await openCodeProxy({ password: 'test' });
|
||||||
|
proxy.targetPort = backend.address().port;
|
||||||
|
t.after(proxy.close);
|
||||||
|
const signal = AbortSignal.timeout(3000);
|
||||||
|
const response = await fetch(proxy.origin, { signal });
|
||||||
|
await assert.rejects(response.text());
|
||||||
|
assert.equal(
|
||||||
|
signal.aborted,
|
||||||
|
false,
|
||||||
|
'The proxy must close the response before the client times out.',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('rejects an occupied browser port and reports a missing or closed upstream', async (t) => {
|
||||||
|
const proxy = await openCodeProxy({ password: 'test' });
|
||||||
|
t.after(proxy.close);
|
||||||
|
await assert.rejects(openCodeProxy({ password: 'test', port: +new URL(proxy.origin).port }), {
|
||||||
|
code: 'EADDRINUSE',
|
||||||
|
});
|
||||||
|
const waiting = await fetch(proxy.origin);
|
||||||
|
assert.equal(waiting.status, 503);
|
||||||
|
await waiting.text();
|
||||||
|
proxy.targetPort = 1;
|
||||||
|
const response = await fetch(proxy.origin);
|
||||||
|
assert.equal(response.status, 502);
|
||||||
|
await response.text();
|
||||||
|
const rejection = await new Promise((resolve) => {
|
||||||
|
const socket = connect(+new URL(proxy.origin).port, '127.0.0.1', () => {
|
||||||
|
socket.write(
|
||||||
|
'GET /pty/test/connect HTTP/1.1\r\nHost: example.com\r\nConnection: Upgrade\r\nUpgrade: websocket\r\n\r\n',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
socket.once('data', (data) => {
|
||||||
|
socket.destroy();
|
||||||
|
resolve(data.toString());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
assert.match(rejection, /403 Forbidden/);
|
||||||
|
});
|
||||||
228
.devcontainer/codespaces/opencode-server.mjs
Normal file
228
.devcontainer/codespaces/opencode-server.mjs
Normal file
|
|
@ -0,0 +1,228 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
// The laptop sends this file over SSH as one standalone module. Do not import sibling files.
|
||||||
|
// It also works in an older Codespace checkout.
|
||||||
|
import { execFileSync, spawnSync } from 'node:child_process';
|
||||||
|
import { randomBytes } from 'node:crypto';
|
||||||
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
||||||
|
import { createServer } from 'node:net';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { setTimeout as delay } from 'node:timers/promises';
|
||||||
|
|
||||||
|
const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
||||||
|
|
||||||
|
function readJson(file) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(readFileSync(file, 'utf8'));
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code === 'ENOENT') return undefined;
|
||||||
|
throw new Error(`Cannot read ${file}. Restore or remove this state file, then retry.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveJson(file, value) {
|
||||||
|
writeFileSync(`${file}.tmp`, JSON.stringify(value), { mode: 0o600 });
|
||||||
|
renameSync(`${file}.tmp`, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(command, args, options = {}) {
|
||||||
|
const result = spawnSync(command, args, {
|
||||||
|
stdio: ['ignore', 'inherit', 'inherit'],
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
if (result.error || result.status !== 0) {
|
||||||
|
throw new Error(`${command} failed. Check the output above, then retry.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function freePort() {
|
||||||
|
const server = createServer();
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
server.once('error', reject);
|
||||||
|
server.listen(0, '127.0.0.1', resolve);
|
||||||
|
});
|
||||||
|
const { port } = server.address();
|
||||||
|
await new Promise((resolve) => server.close(resolve));
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function request(server, path, directory, options = {}, timeout = 60_000) {
|
||||||
|
return await fetch(`http://127.0.0.1:${server.port}${path}`, {
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
authorization: `Basic ${Buffer.from(`opencode:${server.password}`).toString('base64')}`,
|
||||||
|
'x-opencode-directory': encodeURIComponent(directory),
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
signal: AbortSignal.timeout(timeout),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function health(server, directory) {
|
||||||
|
try {
|
||||||
|
const response = await request(server, '/global/health', directory, {}, 3000);
|
||||||
|
if (!response.ok) return undefined;
|
||||||
|
const result = await response.json();
|
||||||
|
return result.healthy === true && typeof result.version === 'string' ? result : undefined;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const serverFile = (stateDir) => join(stateDir, 'server.json');
|
||||||
|
|
||||||
|
async function runningServer({ stateDir, mainDirectory }) {
|
||||||
|
const previous = readJson(serverFile(stateDir));
|
||||||
|
return previous && (await health(previous, mainDirectory)) ? previous : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function startServer({ stateDir, mainDirectory, workspaces }) {
|
||||||
|
const tmuxSession = 'n8n-opencode-server';
|
||||||
|
if (spawnSync('tmux', ['has-session', '-t', `=${tmuxSession}`]).status === 0) {
|
||||||
|
throw new Error(
|
||||||
|
`OpenCode is still starting or is unhealthy. Check ${stateDir}/server.log, then retry. The running server was not stopped.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const server = { port: await freePort(), password: randomBytes(32).toString('hex') };
|
||||||
|
const launcher = join(stateDir, 'serve.sh');
|
||||||
|
// Read secrets when the server starts. Do not store provider keys in the launcher.
|
||||||
|
writeFileSync(
|
||||||
|
launcher,
|
||||||
|
[
|
||||||
|
'#!/bin/bash',
|
||||||
|
'. /usr/local/lib/codespaces-env.sh 2>/dev/null || true',
|
||||||
|
'unset AGENT_WORKER_TOKEN N8N_DEQUEUE_URL SLACK_BOT_TOKEN',
|
||||||
|
`export TURBO_CACHE_DIR=${quote(join(workspaces, '.turbo-cache'))}`,
|
||||||
|
`[ -d "$TURBO_CACHE_DIR" ] || cp -r ${quote(join(mainDirectory, '.turbo/cache'))} "$TURBO_CACHE_DIR" 2>/dev/null || mkdir -p "$TURBO_CACHE_DIR"`,
|
||||||
|
`export OPENCODE_SERVER_USERNAME=opencode OPENCODE_SERVER_PASSWORD=${quote(server.password)}`,
|
||||||
|
'export OPENCODE_EXPERIMENTAL_CODE_MODE=true',
|
||||||
|
`export OPENCODE_CONFIG_CONTENT=${quote(
|
||||||
|
JSON.stringify({
|
||||||
|
enabled_providers: ['openrouter'],
|
||||||
|
provider: { openrouter: { options: { apiKey: '{env:OPENROUTER_API_KEY}' } } },
|
||||||
|
}),
|
||||||
|
)}`,
|
||||||
|
// Interactive sessions use the harness sandbox runtime without a profile.
|
||||||
|
'export N8N_AGENT_RUNTIME=sandbox; unset N8N_AGENT_PROFILE',
|
||||||
|
`cd ${quote(mainDirectory)} || exit 1`,
|
||||||
|
`exec opencode serve --hostname 127.0.0.1 --port ${server.port} >> ${quote(join(stateDir, 'server.log'))} 2>&1`,
|
||||||
|
'',
|
||||||
|
].join('\n'),
|
||||||
|
{ mode: 0o600 },
|
||||||
|
);
|
||||||
|
saveJson(serverFile(stateDir), server);
|
||||||
|
run('tmux', ['new-session', '-d', '-s', tmuxSession, `bash ${quote(launcher)}`]);
|
||||||
|
console.error('Starting the OpenCode server…');
|
||||||
|
for (let attempt = 0; attempt < 60; attempt++) {
|
||||||
|
if (await health(server, mainDirectory)) return server;
|
||||||
|
await delay(500);
|
||||||
|
}
|
||||||
|
throw new Error(`OpenCode did not become ready. Check ${stateDir}/server.log.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareWorkspace({ name, directory, mainDirectory, stateDir }) {
|
||||||
|
if (!existsSync(directory)) {
|
||||||
|
console.error(`Creating worktree ${directory}…`);
|
||||||
|
const branch = `session/${name}`;
|
||||||
|
const exists =
|
||||||
|
spawnSync('git', [
|
||||||
|
'-C',
|
||||||
|
mainDirectory,
|
||||||
|
'show-ref',
|
||||||
|
'--verify',
|
||||||
|
'--quiet',
|
||||||
|
`refs/heads/${branch}`,
|
||||||
|
]).status === 0;
|
||||||
|
if (!exists)
|
||||||
|
spawnSync('git', ['-C', mainDirectory, 'fetch', 'origin', 'master'], {
|
||||||
|
stdio: ['ignore', 2, 2],
|
||||||
|
});
|
||||||
|
run(
|
||||||
|
'git',
|
||||||
|
[
|
||||||
|
'-C',
|
||||||
|
mainDirectory,
|
||||||
|
'worktree',
|
||||||
|
'add',
|
||||||
|
...(exists ? [] : ['--no-track', '-b', branch]),
|
||||||
|
directory,
|
||||||
|
exists ? branch : 'origin/master',
|
||||||
|
],
|
||||||
|
{ stdio: ['ignore', 2, 2] },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// A failed install must be retried even if it left a node_modules directory.
|
||||||
|
const installed = join(stateDir, `${name}.installed`);
|
||||||
|
const installing = join(stateDir, `${name}.installing`);
|
||||||
|
if (
|
||||||
|
!existsSync(join(directory, 'node_modules')) ||
|
||||||
|
existsSync(installing) ||
|
||||||
|
(name !== 'agent' && !existsSync(installed))
|
||||||
|
) {
|
||||||
|
console.error(`Installing dependencies in ${directory}…`);
|
||||||
|
writeFileSync(installing, '', { mode: 0o600 });
|
||||||
|
run('pnpm', ['install'], { cwd: directory, stdio: ['ignore', 2, 2] });
|
||||||
|
writeFileSync(installed, '', { mode: 0o600 });
|
||||||
|
rmSync(installing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenCode's own resume is scoped to the repository project, so all worktrees
|
||||||
|
// share one pool. Scope the selection to the workspace directory instead, so
|
||||||
|
// each worktree resumes its own most recently updated root conversation.
|
||||||
|
async function resolveSession({ name, fresh, directory, server }) {
|
||||||
|
if (!fresh) {
|
||||||
|
const query = new URLSearchParams({ directory, roots: 'true' });
|
||||||
|
const response = await request(server, `/session?${query}`, directory);
|
||||||
|
if (!response.ok) throw new Error(`Cannot list OpenCode sessions (${response.status}).`);
|
||||||
|
const sessions = await response.json();
|
||||||
|
const latest = Array.isArray(sessions)
|
||||||
|
? sessions.find((entry) => typeof entry?.id === 'string' && entry.id.length > 0)
|
||||||
|
: undefined;
|
||||||
|
if (latest) return latest.id;
|
||||||
|
}
|
||||||
|
const response = await request(server, '/session', directory, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ title: `n8n: ${name}` }),
|
||||||
|
});
|
||||||
|
if (!response.ok) throw new Error(`Cannot create OpenCode session (${response.status}).`);
|
||||||
|
const session = await response.json();
|
||||||
|
if (typeof session.id !== 'string' || session.directory !== directory)
|
||||||
|
throw new Error('OpenCode returned an invalid session.');
|
||||||
|
return session.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function prepareOpenCode({
|
||||||
|
name = 'agent',
|
||||||
|
fresh = false,
|
||||||
|
web = false,
|
||||||
|
workspaces = '/workspaces',
|
||||||
|
} = {}) {
|
||||||
|
const stateDir = join(workspaces, '.n8n-opencode');
|
||||||
|
const mainDirectory = join(workspaces, 'n8n');
|
||||||
|
if (!/^\w[\w-]*$/.test(name)) throw new Error('Invalid OpenCode workspace name.');
|
||||||
|
mkdirSync(stateDir, { recursive: true, mode: 0o700 });
|
||||||
|
const directory = name === 'agent' ? mainDirectory : join(workspaces, `wt-${name}`);
|
||||||
|
let server = await runningServer({ stateDir, mainDirectory });
|
||||||
|
// On a cold start, fail before the worktree install when OpenCode is missing on the Codespace.
|
||||||
|
if (!server) execFileSync('opencode', ['--version'], { stdio: ['ignore', 'pipe', 'inherit'] });
|
||||||
|
prepareWorkspace({ name, directory, mainDirectory, stateDir });
|
||||||
|
server ??= await startServer({ stateDir, mainDirectory, workspaces });
|
||||||
|
const state = { ...server, directory };
|
||||||
|
// A fresh TUI conversation needs no record. The TUI creates it on the first message.
|
||||||
|
if (fresh && !web) return state;
|
||||||
|
// Only the parent process reads stdout. Never send this record to terminal output.
|
||||||
|
return { ...state, sessionID: await resolveSession({ name, fresh, directory, server }) };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === '-') {
|
||||||
|
try {
|
||||||
|
const [name, fresh, web] = process.argv.slice(2);
|
||||||
|
console.log(
|
||||||
|
JSON.stringify(await prepareOpenCode({ name, fresh: fresh === 'true', web: web === 'true' })),
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error.message);
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
275
.devcontainer/codespaces/opencode-server.test.mjs
Normal file
275
.devcontainer/codespaces/opencode-server.test.mjs
Normal file
|
|
@ -0,0 +1,275 @@
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { test } from 'node:test';
|
||||||
|
import { setTimeout as delay } from 'node:timers/promises';
|
||||||
|
|
||||||
|
import { fakeBinaries } from './fake-bin.mjs';
|
||||||
|
import { prepareOpenCode } from './opencode-server.mjs';
|
||||||
|
|
||||||
|
// An orphaned fixture process can linger as a zombie where PID 1 does not reap
|
||||||
|
// it, and kill(pid, 0) still succeeds for one. Read the process state where the
|
||||||
|
// kernel exposes it; without /proc only the signal error can tell.
|
||||||
|
function stopped(pid) {
|
||||||
|
try {
|
||||||
|
process.kill(pid, 0);
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return readFileSync(`/proc/${pid}/stat`, 'utf8').split(' ')[2] === 'Z';
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixture(t) {
|
||||||
|
const fake = fakeBinaries('opencode-server-');
|
||||||
|
const dir = fake.root;
|
||||||
|
mkdirSync(join(dir, 'n8n', 'node_modules'), { recursive: true });
|
||||||
|
const savedEnv = { ...process.env };
|
||||||
|
// prepareOpenCode spawns the shims in this process. Log every call before the shim body runs.
|
||||||
|
Object.assign(process.env, fake.env, {
|
||||||
|
AGENT_WORKER_TOKEN: 'test-worker',
|
||||||
|
N8N_DEQUEUE_URL: 'test-queue',
|
||||||
|
SLACK_BOT_TOKEN: 'test-slack',
|
||||||
|
});
|
||||||
|
const bin = (name, body) =>
|
||||||
|
fake.bin(name, `log({ command: ${JSON.stringify(name)}, args });\n${body}`);
|
||||||
|
bin(
|
||||||
|
'git',
|
||||||
|
`
|
||||||
|
if (args.includes('show-ref')) process.exit(fs.existsSync(file('branch-exists')) ? 0 : 1);
|
||||||
|
if (args.includes('fetch')) process.exit(0);
|
||||||
|
fs.mkdirSync(args.at(-2), { recursive: true });
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
bin(
|
||||||
|
'pnpm',
|
||||||
|
`
|
||||||
|
fs.mkdirSync(path.join(process.cwd(), 'node_modules'), {recursive:true});
|
||||||
|
if (process.env.TEST_INSTALL_FAIL) process.exit(1);
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
bin(
|
||||||
|
'tmux',
|
||||||
|
`
|
||||||
|
if (args[0] === 'has-session') {
|
||||||
|
const pid = +fs.readFileSync(file('pid'), 'utf8');
|
||||||
|
let gone = false;
|
||||||
|
try { process.kill(pid, 0); } catch { gone = true; }
|
||||||
|
if (!gone) {
|
||||||
|
try { gone = fs.readFileSync('/proc/' + pid + '/stat', 'utf8').split(' ')[2] === 'Z'; } catch {}
|
||||||
|
}
|
||||||
|
if (gone) process.exit(1);
|
||||||
|
} else {
|
||||||
|
const child = require('node:child_process').spawn('bash', ['-c', args.at(-1)], { detached:true, stdio:'ignore' });
|
||||||
|
fs.writeFileSync(file('pid'), String(child.pid)); child.unref();
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
bin(
|
||||||
|
'opencode',
|
||||||
|
`
|
||||||
|
if (args[0] === '--version') { console.log('1.2.3'); process.exit(0); }
|
||||||
|
fs.writeFileSync(file('server-env.json'), JSON.stringify({
|
||||||
|
worker: !!process.env.AGENT_WORKER_TOKEN, queue: !!process.env.N8N_DEQUEUE_URL, slack: !!process.env.SLACK_BOT_TOKEN,
|
||||||
|
cache: process.env.TURBO_CACHE_DIR, config: JSON.parse(process.env.OPENCODE_CONFIG_CONTENT),
|
||||||
|
runtime: process.env.N8N_AGENT_RUNTIME, profile: process.env.N8N_AGENT_PROFILE ?? null,
|
||||||
|
}));
|
||||||
|
let sessions = fs.existsSync(file('sessions.json')) ? JSON.parse(fs.readFileSync(file('sessions.json'), 'utf8')) : {};
|
||||||
|
const server = require('node:http').createServer(async (req, res) => {
|
||||||
|
res.setHeader('content-type', 'application/json');
|
||||||
|
const expected = 'Basic ' + Buffer.from('opencode:' + process.env.OPENCODE_SERVER_PASSWORD).toString('base64');
|
||||||
|
if (req.headers.authorization !== expected) { res.writeHead(401).end('{}'); return; }
|
||||||
|
const directory = decodeURIComponent(req.headers['x-opencode-directory']);
|
||||||
|
if (req.url === '/global/health') { res.end(JSON.stringify({ healthy:true, version:'1.2.3' })); return; }
|
||||||
|
if (req.method === 'POST' && req.url === '/session') {
|
||||||
|
if (fs.existsSync(file('reject-create'))) { res.writeHead(503).end('{}'); return; }
|
||||||
|
let body = '';
|
||||||
|
for await (const chunk of req) body += chunk;
|
||||||
|
const id = 'ses_' + (Object.keys(sessions).length + 1);
|
||||||
|
sessions[id] = { id, directory, title: JSON.parse(body).title };
|
||||||
|
fs.writeFileSync(file('sessions.json'), JSON.stringify(sessions));
|
||||||
|
res.end(JSON.stringify(sessions[id])); return;
|
||||||
|
}
|
||||||
|
if (fs.existsSync(file('reject-session'))) { res.writeHead(503).end('{}'); return; }
|
||||||
|
const url = new URL(req.url, 'http://localhost');
|
||||||
|
if (url.pathname === '/session') {
|
||||||
|
// Newest first, like the real server. Filter on the query, not the header,
|
||||||
|
// so the test fails when the launcher omits either parameter. The
|
||||||
|
// child-session file models a subagent conversation that the roots query
|
||||||
|
// flag must exclude.
|
||||||
|
const directory = url.searchParams.get('directory');
|
||||||
|
const roots = url.searchParams.get('roots') === 'true';
|
||||||
|
const stored = Object.values(sessions);
|
||||||
|
if (fs.existsSync(file('child-session')))
|
||||||
|
stored.push({ id: 'ses_child', directory, title: 'child', parentID: 'ses_1' });
|
||||||
|
const list = stored
|
||||||
|
.filter(s => s.directory === directory && (!roots || !s.parentID))
|
||||||
|
.reverse();
|
||||||
|
if (fs.existsSync(file('extra-session'))) list.unshift({ id: 'ses_extra', directory, title: 'TUI session' });
|
||||||
|
res.end(JSON.stringify(list)); return;
|
||||||
|
}
|
||||||
|
const session = sessions[req.url.split('/').at(-1)];
|
||||||
|
if (!session) { res.writeHead(404).end('{}'); return; }
|
||||||
|
res.end(JSON.stringify(session));
|
||||||
|
});
|
||||||
|
server.listen(+args[args.indexOf('--port') + 1], '127.0.0.1');
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
const stop = async () => {
|
||||||
|
try {
|
||||||
|
const pid = +readFileSync(join(dir, 'pid'), 'utf8');
|
||||||
|
process.kill(-pid, 'SIGTERM');
|
||||||
|
for (let count = 0; count < 100; count++) {
|
||||||
|
if (stopped(pid)) return;
|
||||||
|
await delay(20);
|
||||||
|
}
|
||||||
|
throw new Error('Fixture server did not stop.');
|
||||||
|
} catch (error) {
|
||||||
|
if (!['ENOENT', 'ESRCH'].includes(error.code)) throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
t.after(async () => {
|
||||||
|
await stop();
|
||||||
|
for (const key of Object.keys(process.env)) if (!(key in savedEnv)) delete process.env[key];
|
||||||
|
Object.assign(process.env, savedEnv);
|
||||||
|
rmSync(dir, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
dir,
|
||||||
|
stop,
|
||||||
|
prepare: (options = {}) => prepareOpenCode({ workspaces: dir, ...options }),
|
||||||
|
commands: fake.calls,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
test(
|
||||||
|
'reuses the server, serves each workspace its newest conversation, and resumes after restart',
|
||||||
|
{ timeout: 15000 },
|
||||||
|
async (t) => {
|
||||||
|
const f = fixture(t);
|
||||||
|
const first = await f.prepare({ name: 'fix-flaky' });
|
||||||
|
assert.equal(first.directory, join(f.dir, 'wt-fix-flaky'));
|
||||||
|
const git = f.commands().filter((entry) => entry.command === 'git');
|
||||||
|
assert.deepEqual(
|
||||||
|
git.map((entry) => entry.args.slice(2)),
|
||||||
|
[
|
||||||
|
['show-ref', '--verify', '--quiet', 'refs/heads/session/fix-flaky'],
|
||||||
|
['fetch', 'origin', 'master'],
|
||||||
|
[
|
||||||
|
'worktree',
|
||||||
|
'add',
|
||||||
|
'--no-track',
|
||||||
|
'-b',
|
||||||
|
'session/fix-flaky',
|
||||||
|
first.directory,
|
||||||
|
'origin/master',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
assert.equal(first.sessionID, 'ses_1');
|
||||||
|
assert.deepEqual(await f.prepare({ name: 'fix-flaky' }), first);
|
||||||
|
const second = await f.prepare({ name: 'another-task' });
|
||||||
|
assert.equal(second.port, first.port);
|
||||||
|
assert.equal(second.sessionID, 'ses_2');
|
||||||
|
const webbed = await f.prepare({ name: 'fix-flaky', web: true });
|
||||||
|
assert.equal(webbed.sessionID, 'ses_1');
|
||||||
|
const created = JSON.parse(readFileSync(join(f.dir, 'sessions.json'), 'utf8'));
|
||||||
|
assert.equal(created.ses_1.title, 'n8n: fix-flaky');
|
||||||
|
assert.equal(created.ses_1.directory, join(f.dir, 'wt-fix-flaky'));
|
||||||
|
assert.equal((await f.prepare({ name: 'fix-flaky', web: true })).sessionID, 'ses_1');
|
||||||
|
assert.equal((await f.prepare({ name: 'another-task', web: true })).sessionID, 'ses_2');
|
||||||
|
writeFileSync(join(f.dir, 'extra-session'), '');
|
||||||
|
assert.equal((await f.prepare({ name: 'fix-flaky', web: true })).sessionID, 'ses_extra');
|
||||||
|
rmSync(join(f.dir, 'extra-session'));
|
||||||
|
writeFileSync(join(f.dir, 'child-session'), '');
|
||||||
|
assert.equal((await f.prepare({ name: 'fix-flaky', web: true })).sessionID, 'ses_1');
|
||||||
|
rmSync(join(f.dir, 'child-session'));
|
||||||
|
const fresh = await f.prepare({ name: 'fix-flaky', web: true, fresh: true });
|
||||||
|
assert.notEqual(fresh.sessionID, 'ses_1');
|
||||||
|
assert.equal((await f.prepare({ name: 'fix-flaky', web: true })).sessionID, fresh.sessionID);
|
||||||
|
const env = JSON.parse(readFileSync(join(f.dir, 'server-env.json'), 'utf8'));
|
||||||
|
assert.deepEqual([env.worker, env.queue, env.slack], [false, false, false]);
|
||||||
|
assert.equal(env.cache, join(f.dir, '.turbo-cache'));
|
||||||
|
assert.equal(env.config.provider.openrouter.options.apiKey, '{env:OPENROUTER_API_KEY}');
|
||||||
|
assert.deepEqual(env.config.enabled_providers, ['openrouter']);
|
||||||
|
assert.deepEqual([env.runtime, env.profile], ['sandbox', null]);
|
||||||
|
assert.equal(statSync(join(f.dir, '.n8n-opencode')).mode & 0o777, 0o700);
|
||||||
|
for (const file of ['serve.sh', 'server.json']) {
|
||||||
|
assert.equal(statSync(join(f.dir, '.n8n-opencode', file)).mode & 0o777, 0o600);
|
||||||
|
}
|
||||||
|
assert.ok(!f.commands().some((entry) => JSON.stringify(entry.args).includes(first.password)));
|
||||||
|
assert.equal(f.commands().filter((entry) => entry.command === 'pnpm').length, 2);
|
||||||
|
await f.stop();
|
||||||
|
const restarted = await f.prepare({ name: 'fix-flaky', web: true });
|
||||||
|
assert.equal(restarted.sessionID, fresh.sessionID);
|
||||||
|
assert.notEqual(restarted.password, first.password);
|
||||||
|
rmSync(first.directory, { recursive: true });
|
||||||
|
writeFileSync(join(f.dir, 'branch-exists'), '');
|
||||||
|
assert.equal((await f.prepare({ name: 'fix-flaky' })).directory, join(f.dir, 'wt-fix-flaky'));
|
||||||
|
const worktree = f
|
||||||
|
.commands()
|
||||||
|
.filter((entry) => entry.command === 'git' && entry.args.includes('add'))
|
||||||
|
.at(-1);
|
||||||
|
assert.deepEqual(worktree.args, [
|
||||||
|
'-C',
|
||||||
|
join(f.dir, 'n8n'),
|
||||||
|
'worktree',
|
||||||
|
'add',
|
||||||
|
first.directory,
|
||||||
|
'session/fix-flaky',
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'retries a failed worktree install before starting the server',
|
||||||
|
{ timeout: 10000 },
|
||||||
|
async (t) => {
|
||||||
|
const f = fixture(t);
|
||||||
|
process.env.TEST_INSTALL_FAIL = '1';
|
||||||
|
await assert.rejects(f.prepare({ name: 'retry' }), /pnpm failed/);
|
||||||
|
assert.ok(!f.commands().some((entry) => entry.command === 'tmux'));
|
||||||
|
delete process.env.TEST_INSTALL_FAIL;
|
||||||
|
assert.equal((await f.prepare({ name: 'retry' })).directory, join(f.dir, 'wt-retry'));
|
||||||
|
assert.equal(f.commands().filter((entry) => entry.command === 'pnpm').length, 2);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'retries a failed main checkout install even when node_modules exists',
|
||||||
|
{ timeout: 10000 },
|
||||||
|
async (t) => {
|
||||||
|
const f = fixture(t);
|
||||||
|
rmSync(join(f.dir, 'n8n', 'node_modules'), { recursive: true });
|
||||||
|
process.env.TEST_INSTALL_FAIL = '1';
|
||||||
|
await assert.rejects(f.prepare(), /pnpm failed/);
|
||||||
|
delete process.env.TEST_INSTALL_FAIL;
|
||||||
|
assert.equal((await f.prepare()).directory, join(f.dir, 'n8n'));
|
||||||
|
assert.equal(f.commands().filter((entry) => entry.command === 'pnpm').length, 2);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'reports session API errors and creates conversations only when none exist',
|
||||||
|
{ timeout: 10000 },
|
||||||
|
async (t) => {
|
||||||
|
const f = fixture(t);
|
||||||
|
const first = await f.prepare({ web: true });
|
||||||
|
assert.equal(first.sessionID, 'ses_1');
|
||||||
|
writeFileSync(join(f.dir, 'reject-session'), '');
|
||||||
|
await assert.rejects(f.prepare({ web: true }), /Cannot list OpenCode sessions \(503\)/);
|
||||||
|
assert.ok(JSON.parse(readFileSync(join(f.dir, 'sessions.json'), 'utf8')).ses_1);
|
||||||
|
rmSync(join(f.dir, 'reject-session'));
|
||||||
|
assert.equal((await f.prepare({ web: true })).sessionID, first.sessionID);
|
||||||
|
writeFileSync(join(f.dir, 'reject-create'), '');
|
||||||
|
await assert.rejects(
|
||||||
|
f.prepare({ name: 'fresh-task', web: true }),
|
||||||
|
/Cannot create OpenCode session \(503\)/,
|
||||||
|
);
|
||||||
|
rmSync(join(f.dir, 'reject-create'));
|
||||||
|
assert.equal((await f.prepare({ name: 'fresh-task', web: true })).sessionID, 'ses_2');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
// Runs on each codespace start. Installs the skills marketplace, starts the worker.
|
// Runs on each Codespace start. Installs the skills and harness, then starts the worker.
|
||||||
import { execFileSync } from 'node:child_process';
|
import { execFileSync } from 'node:child_process';
|
||||||
import { rmSync, writeFileSync } from 'node:fs';
|
import { readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||||
import { homedir } from 'node:os';
|
import { homedir } from 'node:os';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { installAgentHarness } from '../../scripts/agent-harness.mjs';
|
||||||
|
import { codespaceSecret } from '../../scripts/codespace-env.mjs';
|
||||||
import { MARKETPLACE, PLUGINS } from './plugins.mjs';
|
import { MARKETPLACE, PLUGINS } from './plugins.mjs';
|
||||||
|
|
||||||
const STATUS_FILE = '/tmp/post-start-status.json';
|
const STATUS_FILE = '/tmp/post-start-status.json';
|
||||||
|
|
@ -48,6 +50,42 @@ function addMarketplace() {
|
||||||
return add('marketplace add (retry)');
|
return add('marketplace add (retry)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Claude Code reads the Flaky token when it connects. An env reference such as
|
||||||
|
// ${FLAKY_MCP_TOKEN} fails in processes that did not load the secrets file, for
|
||||||
|
// example the desktop app's SSH server. The helper reads the file on each connect,
|
||||||
|
// so it also gets a rotated token. The token is not copied into ~/.claude.json.
|
||||||
|
const FLAKY_HEADERS_HELPER =
|
||||||
|
'. /usr/local/lib/codespaces-env.sh; printf %s "{\\"Authorization\\":\\"Bearer $FLAKY_MCP_TOKEN\\"}"';
|
||||||
|
|
||||||
|
function registerFlakyMcp() {
|
||||||
|
// Forks have no repository secrets.
|
||||||
|
const url = codespaceSecret('FLAKY_MCP_URL');
|
||||||
|
if (!url || !codespaceSecret('FLAKY_MCP_TOKEN')) return;
|
||||||
|
|
||||||
|
let current;
|
||||||
|
try {
|
||||||
|
current = JSON.parse(readFileSync(join(homedir(), '.claude.json'), 'utf8')).mcpServers?.flaky;
|
||||||
|
} catch {
|
||||||
|
// No readable config yet: register the server below.
|
||||||
|
}
|
||||||
|
if (current?.url === url && current.headersHelper === FLAKY_HEADERS_HELPER && !current.headers) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current) tryRun('flaky mcp remove', 'claude', ['mcp', 'remove', '--scope', 'user', 'flaky']);
|
||||||
|
const config = { type: 'http', url, headersHelper: FLAKY_HEADERS_HELPER };
|
||||||
|
tryRun('flaky mcp add', 'claude', [
|
||||||
|
'mcp',
|
||||||
|
'add-json',
|
||||||
|
'--scope',
|
||||||
|
'user',
|
||||||
|
'flaky',
|
||||||
|
JSON.stringify(config),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerFlakyMcp();
|
||||||
|
|
||||||
tryRun('skills repo reachable', 'git', ['ls-remote', `https://github.com/${MARKETPLACE}`, 'HEAD']);
|
tryRun('skills repo reachable', 'git', ['ls-remote', `https://github.com/${MARKETPLACE}`, 'HEAD']);
|
||||||
|
|
||||||
const installed = [];
|
const installed = [];
|
||||||
|
|
@ -61,19 +99,33 @@ if (addMarketplace()) {
|
||||||
failed.push(...PLUGINS);
|
failed.push(...PLUGINS);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFileSync(STATUS_FILE, JSON.stringify({ installed, failed }, null, 2));
|
|
||||||
|
|
||||||
// A skipped install is otherwise invisible until someone misses a skill mid-session.
|
// A skipped install is otherwise invisible until someone misses a skill mid-session.
|
||||||
if (failed.length > 0) {
|
if (failed.length > 0) {
|
||||||
console.error(`\n!! SKILLS NOT INSTALLED: ${failed.join(', ')}`);
|
console.error(`\n!! SKILLS NOT INSTALLED: ${failed.join(', ')}`);
|
||||||
console.error('!! Sessions start without them. Retry with:');
|
console.error('!! Sessions start without them. Retry with:');
|
||||||
console.error('!! node /workspaces/n8n/.devcontainer/codespaces/post-start.mjs\n');
|
console.error('!! node /workspaces/n8n/.devcontainer/codespaces/post-start.mjs\n');
|
||||||
}
|
}
|
||||||
|
let harness;
|
||||||
|
try {
|
||||||
|
const result = installAgentHarness();
|
||||||
|
harness = { status: 'active', version: result.version, cacheHit: result.cacheHit };
|
||||||
|
} catch (error) {
|
||||||
|
harness = { status: 'unavailable', error: error.message };
|
||||||
|
console.error(`agent harness: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
tryRun('worker start', 'tmux', [
|
const workerStarted =
|
||||||
'new-session',
|
harness.status === 'active' &&
|
||||||
'-d',
|
tryRun('worker start', 'tmux', [
|
||||||
'-s',
|
'new-session',
|
||||||
'agent-worker',
|
'-d',
|
||||||
'bash -lc ". /usr/local/lib/codespaces-env.sh; export CLAUDE_CODE_PLUGIN_PREFER_HTTPS=1 CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1; node /workspaces/n8n/.devcontainer/codespaces/agent-worker.mjs >> /tmp/agent-worker.log 2>&1"',
|
'-s',
|
||||||
]);
|
'agent-worker',
|
||||||
|
'bash -lc ". /usr/local/lib/codespaces-env.sh; export CLAUDE_CODE_PLUGIN_PREFER_HTTPS=1 CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1; node /workspaces/n8n/.devcontainer/codespaces/agent-worker.mjs >> /tmp/agent-worker.log 2>&1"',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!workerStarted && harness.status !== 'active') {
|
||||||
|
console.error('worker start: skipped because the pinned agent harness is unavailable');
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync(STATUS_FILE, JSON.stringify({ installed, failed, harness, workerStarted }, null, 2));
|
||||||
|
|
|
||||||
32
.devcontainer/codespaces/ssh-config.test.mjs
Normal file
32
.devcontainer/codespaces/ssh-config.test.mjs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { test } from 'node:test';
|
||||||
|
|
||||||
|
import { aliasHostConfig, withInclude } from '../../scripts/cloud-session-ssh-config.mjs';
|
||||||
|
|
||||||
|
const GH_CONFIG = `Host cs.ominous-doodle.master
|
||||||
|
User node
|
||||||
|
ProxyCommand gh cs ssh -c ominous-doodle --stdio
|
||||||
|
UserKnownHostsFile=/dev/null
|
||||||
|
`;
|
||||||
|
|
||||||
|
test('replaces the gh host name with the fixed alias', () => {
|
||||||
|
assert.equal(
|
||||||
|
aliasHostConfig(GH_CONFIG),
|
||||||
|
GH_CONFIG.replace('cs.ominous-doodle.master', 'n8n-codespace'),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rejects gh output without exactly one proxied host', () => {
|
||||||
|
assert.throws(() => aliasHostConfig(''));
|
||||||
|
assert.throws(() => aliasHostConfig(`${GH_CONFIG}Host other\n`));
|
||||||
|
assert.throws(() => aliasHostConfig('Host cs.x\n\tUser node\n'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('adds the Include line at the top once', () => {
|
||||||
|
const include = 'Include ~/.ssh/n8n-codespace.conf';
|
||||||
|
assert.equal(withInclude(''), `${include}\n`);
|
||||||
|
|
||||||
|
const updated = withInclude('Host github.com\n\tUser git\n');
|
||||||
|
assert.equal(updated, `${include}\n\nHost github.com\n\tUser git\n`);
|
||||||
|
assert.equal(withInclude(updated), undefined);
|
||||||
|
});
|
||||||
|
|
@ -33,5 +33,22 @@
|
||||||
// Codespaces regenerates the managed /etc/gitconfig on each start, and the ssh
|
// Codespaces regenerates the managed /etc/gitconfig on each start, and the ssh
|
||||||
// command shells `pnpm preview` uses are neither login nor interactive, so
|
// command shells `pnpm preview` uses are neither login nor interactive, so
|
||||||
// profile.d and bashrc never fire for them. Register the helper here instead.
|
// profile.d and bashrc never fire for them. Register the helper here instead.
|
||||||
"postStartCommand": "git config --global --get-all credential.helper 2>/dev/null | grep -qs gitcredential-refresh || git config --global --add credential.helper /usr/local/bin/gitcredential-refresh.sh"
|
"postStartCommand": "git config --global --get-all credential.helper 2>/dev/null | grep -qs gitcredential-refresh || git config --global --add credential.helper /usr/local/bin/gitcredential-refresh.sh",
|
||||||
|
// Declarations only. All of these are set at the repository level, so Codespaces
|
||||||
|
// injects them into every preview box whether or not they are listed here.
|
||||||
|
// scripts/codespace-preview/preview-serve.mjs reads them with codespaceSecret().
|
||||||
|
"secrets": {
|
||||||
|
"N8N_LICENSE_ACTIVATION_KEY": {
|
||||||
|
"description": "Sandbox licence key. The preview:enterprise label decides whether it reaches n8n."
|
||||||
|
},
|
||||||
|
"CODESPACE_ENV_URL": {
|
||||||
|
"description": "n8n webhook that returns extra environment for a preview, as a flat JSON object"
|
||||||
|
},
|
||||||
|
"CODESPACE_ENV_USER": {
|
||||||
|
"description": "Basic auth user for CODESPACE_ENV_URL. Defaults to `preview`."
|
||||||
|
},
|
||||||
|
"CODESPACE_ENV_PASSWORD": {
|
||||||
|
"description": "Basic auth password for CODESPACE_ENV_URL"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* One-click sign-in for preview instances. Loaded through EXTERNAL_HOOK_FILES by
|
* One-click sign-in for preview instances. Loaded through EXTERNAL_HOOK_FILES by
|
||||||
* scripts/preview-serve.mjs, so it is never part of a packaged n8n.
|
* scripts/codespace-preview/preview-serve.mjs, so it is never part of a packaged n8n.
|
||||||
*
|
*
|
||||||
* The route performs an ordinary login on the visitor's behalf: it calls
|
* The route performs an ordinary login on the visitor's behalf: it calls
|
||||||
* /rest/login with the preview instance's own seeded credentials and forwards the
|
* /rest/login with the preview instance's own seeded credentials and forwards the
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
!docker/images/runners
|
!docker/images/runners
|
||||||
!docker/images/runners/n8n-task-runners.json
|
!docker/images/runners/n8n-task-runners.json
|
||||||
|
|
||||||
# === benchmark image (packages/@n8n/benchmark/Dockerfile) ===
|
# === benchmark image (packages/quality/efficiency/scale/benchmark/Dockerfile) ===
|
||||||
!package.json
|
!package.json
|
||||||
!pnpm-lock.yaml
|
!pnpm-lock.yaml
|
||||||
!pnpm-workspace.yaml
|
!pnpm-workspace.yaml
|
||||||
|
|
@ -34,8 +34,10 @@
|
||||||
!patches/**
|
!patches/**
|
||||||
!scripts
|
!scripts
|
||||||
!scripts/**
|
!scripts/**
|
||||||
!packages/@n8n/benchmark
|
!packages/quality
|
||||||
!packages/@n8n/benchmark/**
|
!packages/quality/efficiency
|
||||||
|
!packages/quality/efficiency/scale
|
||||||
|
!packages/quality/efficiency/scale/benchmark
|
||||||
|
!packages/quality/efficiency/scale/benchmark/**
|
||||||
!packages/@n8n/typescript-config
|
!packages/@n8n/typescript-config
|
||||||
!packages/@n8n/typescript-config/**
|
!packages/@n8n/typescript-config/**
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,6 @@ N8N_LOG_LEVEL=debug
|
||||||
N8N_AI_ENABLED=true
|
N8N_AI_ENABLED=true
|
||||||
N8N_ENABLED_MODULES=instance-ai
|
N8N_ENABLED_MODULES=instance-ai
|
||||||
|
|
||||||
# Uncomment when calibrating MCP grouping cases (--build-via-mcp): canvas-group
|
|
||||||
# support in the MCP tools is PostHog-gated and PostHog is unreachable locally
|
|
||||||
# (fails closed), so the env var is the only lever. Mirrors test-evals-mcp.yml.
|
|
||||||
# N8N_MCP_CANVAS_GROUPS_ENABLED=true
|
|
||||||
|
|
||||||
# Model key for the builder and the eval helper (mock generation, verifier,
|
# Model key for the builder and the eval helper (mock generation, verifier,
|
||||||
# user-proxy, expectation judge). When the instance runs without the proxy, the
|
# user-proxy, expectation judge). When the instance runs without the proxy, the
|
||||||
# model client reads ANTHROPIC_API_KEY directly, so export that too if you go
|
# model client reads ANTHROPIC_API_KEY directly, so export that too if you go
|
||||||
|
|
|
||||||
1
.gitattributes
vendored
1
.gitattributes
vendored
|
|
@ -1,2 +1,3 @@
|
||||||
*.sh text eol=lf
|
*.sh text eol=lf
|
||||||
|
*.patch text eol=lf
|
||||||
docs/generated/**/* linguist-generated
|
docs/generated/**/* linguist-generated
|
||||||
|
|
|
||||||
36
.githooks/check-pnpm.mjs
Normal file
36
.githooks/check-pnpm.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
// Git hook helper (post-merge, post-rewrite, post-checkout): warn when the
|
||||||
|
// installed pnpm major differs from the one pinned in package.json.
|
||||||
|
// Usage: node .githooks/check-pnpm.mjs [checkout-type]
|
||||||
|
// For post-checkout, pass lefthook's {3}: "0" is a file checkout, which we skip.
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { homedir } from 'node:os';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
if (process.argv[2] === '0') process.exit(0);
|
||||||
|
|
||||||
|
const packageJsonPath = fileURLToPath(new URL('../package.json', import.meta.url));
|
||||||
|
const { packageManager = '' } = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
||||||
|
const wanted = /^pnpm@(\d+)/.exec(packageManager)?.[1];
|
||||||
|
|
||||||
|
if (!wanted) process.exit(0);
|
||||||
|
|
||||||
|
// Run from the home dir so pnpm reports the installed version,
|
||||||
|
// not the version pinned by this repo.
|
||||||
|
// `shell` lets Windows resolve pnpm.cmd. The command has no user input.
|
||||||
|
const result = spawnSync('pnpm --version', { cwd: homedir(), shell: true, encoding: 'utf8' });
|
||||||
|
const current = result.status === 0 ? result.stdout.trim().split('.')[0] : '';
|
||||||
|
if (wanted === current) process.exit(0);
|
||||||
|
|
||||||
|
const installCommand =
|
||||||
|
process.platform === 'win32'
|
||||||
|
? 'powershell -c "irm https://get.pnpm.io/install.ps1 | iex"'
|
||||||
|
: 'curl -fsSL https://get.pnpm.io/install.sh | sh -';
|
||||||
|
|
||||||
|
console.log(`
|
||||||
|
⚠ This repo now pins pnpm ${wanted} (you have ${current || 'none'}).
|
||||||
|
pnpm should auto-download it on the next install command.
|
||||||
|
If that fails (some pnpm 10 versions can't install v12), reinstall:
|
||||||
|
${installCommand}
|
||||||
|
`);
|
||||||
40
.github/CI-TELEMETRY.md
vendored
40
.github/CI-TELEMETRY.md
vendored
|
|
@ -19,6 +19,39 @@ All telemetry uses the same format:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Container startup payloads also include:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"attempt_id": "uuid",
|
||||||
|
"correlation": {
|
||||||
|
"profile": "sqlite",
|
||||||
|
"shard": "3",
|
||||||
|
"worker": "2",
|
||||||
|
"retry": 1,
|
||||||
|
"restartReason": null
|
||||||
|
},
|
||||||
|
"stages": [
|
||||||
|
{
|
||||||
|
"name": "n8n-startup",
|
||||||
|
"source": "local",
|
||||||
|
"startedAt": "2026-03-16T12:00:00.000Z",
|
||||||
|
"elapsedMs": 4200,
|
||||||
|
"outcome": "failure",
|
||||||
|
"errorMessage": "readiness failed"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"failure_phase": "n8n-startup"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`attempt_id` identifies one stack startup. Join all stage records and attached
|
||||||
|
Playwright startup evidence with this value. `outcome` is `success`, `failure`,
|
||||||
|
or `cancelled`. Stage durations are also sent as `stack-startup-stage` metrics
|
||||||
|
with `attempt_id`, `stage`, `source`, and `outcome` dimensions. `profile` is
|
||||||
|
resolved from the configured profile or stack shape. Other unavailable
|
||||||
|
correlation values stay `null`.
|
||||||
|
|
||||||
## Standard Context Fields
|
## Standard Context Fields
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
|
@ -48,11 +81,12 @@ return 'blacksmith';
|
||||||
|
|
||||||
| Telemetry | Source | Metrics |
|
| Telemetry | Source | Metrics |
|
||||||
|-----------|--------|---------|
|
|-----------|--------|---------|
|
||||||
| Playwright perf/benchmark | `packages/testing/playwright/reporters/metrics-reporter.ts` | Any metric attached via `attachMetric()` |
|
| Playwright perf/benchmark | `packages/quality/testing/playwright/reporters/metrics-reporter.ts` | Any metric attached via `attachMetric()` |
|
||||||
| Accessibility buckets | `packages/testing/playwright/reporters/a11y-reporter.ts` | Per-bucket axe score, violated rules, violating elements |
|
| Accessibility buckets | `packages/quality/testing/playwright/reporters/a11y-reporter.ts` | Per-bucket axe score, violated rules, violating elements |
|
||||||
| Build stats | `.github/scripts/send-build-stats.mjs` | Per-package build duration, cache hit/miss, run total |
|
| Build stats | `.github/scripts/send-build-stats.mjs` | Per-package build duration, cache hit/miss, run total |
|
||||||
| Docker stats | `.github/scripts/send-docker-stats.mjs` | Image size per platform, docker build duration |
|
| Docker stats | `.github/scripts/send-docker-stats.mjs` | Image size per platform, docker build duration |
|
||||||
| Container stack | `packages/testing/containers/telemetry.ts` | E2E stack startup times per service |
|
| Dive image efficiency | `packages/quality/efficiency/images/image-efficiency.spec.ts` | Layer content size, estimated waste, efficiency score, and layer count through the shared Playwright reporter |
|
||||||
|
| Container stack | `packages/quality/environments/containers/telemetry.ts` | E2E stack startup times per service |
|
||||||
|
|
||||||
## Secrets
|
## Secrets
|
||||||
|
|
||||||
|
|
|
||||||
11
.github/CODEOWNERS
vendored
11
.github/CODEOWNERS
vendored
|
|
@ -1,11 +0,0 @@
|
||||||
# Temporary: kept side by side with the top-level OWNERS file while the
|
|
||||||
# "Required Reviews" enforcement is on trial. Do not add entries here;
|
|
||||||
# add them to OWNERS. See "Transition from CODEOWNERS" in WORKFLOWS.md.
|
|
||||||
packages/@n8n/db/src/migrations/ @n8n-io/migrations-review
|
|
||||||
/OWNERS @n8n-io/qa-dx
|
|
||||||
.github/workflows @n8n-io/qa-dx
|
|
||||||
.github/scripts @n8n-io/qa-dx
|
|
||||||
.github/actions @n8n-io/qa-dx
|
|
||||||
.github/poutine-rules @n8n-io/qa-dx
|
|
||||||
docker/get-n8n.sh @n8n-io/qa-dx
|
|
||||||
.code-health-baseline.json @n8n-io/qa-dx
|
|
||||||
33
.github/DEVELOPING_V3.md
vendored
33
.github/DEVELOPING_V3.md
vendored
|
|
@ -124,6 +124,9 @@ of the breaking removal on `3.x`.
|
||||||
|
|
||||||
## How the daily sync works
|
## How the daily sync works
|
||||||
|
|
||||||
|
The sync runs automation code from the triggering `master` SHA while its working checkout
|
||||||
|
stays on `3.x`.
|
||||||
|
|
||||||
[`util-sync-master-to-3x.yml`](./workflows/util-sync-master-to-3x.yml) runs daily and
|
[`util-sync-master-to-3x.yml`](./workflows/util-sync-master-to-3x.yml) runs daily and
|
||||||
**replays the `3.x`-only commits on top of `master`** (a rebase), then force-pushes `3.x`:
|
**replays the `3.x`-only commits on top of `master`** (a rebase), then force-pushes `3.x`:
|
||||||
|
|
||||||
|
|
@ -133,20 +136,19 @@ of the breaking removal on `3.x`.
|
||||||
original message and author. Nothing is ever squashed. Merge commits in the range (breaking
|
original message and author. Nothing is ever squashed. Merge commits in the range (breaking
|
||||||
PRs merged into `3.x`) are flattened away, and a breaking commit that also landed on
|
PRs merged into `3.x`) are flattened away, and a breaking commit that also landed on
|
||||||
`master` is dropped as empty.
|
`master` is dropped as empty.
|
||||||
3. Conflicts confined to **mechanical files** — tool-generated content with a deterministic
|
3. Conflicts confined to **non-lockfile mechanical files** — bot-maintained content with a
|
||||||
resolution (`pnpm-lock.yaml`, `packages/frontend/editor-ui/data/node-popularity.json`,
|
deterministic resolution (`packages/frontend/editor-ui/data/node-popularity.json`,
|
||||||
`packages/@n8n/instance-ai/src/tools/nodes/credential-setupability.json`, and
|
`packages/@n8n/instance-ai/src/tools/nodes/credential-setupability.json`, and
|
||||||
`.github/test-metrics/e2e-impact-map.json`) — are **auto-resolved during the replay**,
|
`.github/test-metrics/e2e-impact-map.json`) — are **auto-resolved during the replay**,
|
||||||
exactly as a human resolver would: the lockfile is regenerated with
|
by taking `master`'s side. The resolution is folded into the stalled commit, so this still
|
||||||
`pnpm install --lockfile-only` (pnpm merges its own conflict markers), bot-maintained data
|
adds **no commit and no PR**. The list lives in `MECHANICAL_PATHS` in
|
||||||
files take `master`'s side. The resolution is folded into the stalled commit, so this
|
|
||||||
still adds **no commit and no PR**. The list lives in `MECHANICAL_PATHS` in
|
|
||||||
[`sync-master-to-3x.mjs`](./scripts/sync-master-to-3x.mjs).
|
[`sync-master-to-3x.mjs`](./scripts/sync-master-to-3x.mjs).
|
||||||
4. On a **real code conflict**, `3.x` is left **untouched** and a **draft conflict PR**
|
4. On a **real code conflict or any `pnpm-lock.yaml` conflict**, `3.x` is left **untouched**
|
||||||
(labeled `automation:v3-sync`) carrying the conflict markers is opened on
|
and a **draft conflict PR** (labeled `automation:v3-sync`) carrying the conflict markers is
|
||||||
`sync/master-to-3x` — with the mechanical files already pre-resolved — plus a post to the
|
opened on `sync/master-to-3x`. Other mechanical files are already pre-resolved. The
|
||||||
**`#alerts-v3-sync`** Slack channel. **Syncs pause until that PR is merged** — so
|
lockfile stays unresolved because pnpm validation is not reliable while the merge index is
|
||||||
conflicts never pile up silently.
|
unresolved. The workflow also posts to the **`#alerts-v3-sync`** Slack channel. **Syncs
|
||||||
|
pause until that PR is merged**, so conflicts never pile up silently.
|
||||||
|
|
||||||
Whatever route it takes, the sync verifies that the content it is about to push is **exactly
|
Whatever route it takes, the sync verifies that the content it is about to push is **exactly
|
||||||
the tree a merge of `3.x` and `master` produces** (`git merge-tree`), and that no conflict
|
the tree a merge of `3.x` and `master` produces** (`git merge-tree`), and that no conflict
|
||||||
|
|
@ -165,8 +167,8 @@ rewriting `3.x`.
|
||||||
|
|
||||||
The conflict branch is `master` merged into `3.x` with the **conflict markers committed**, so
|
The conflict branch is `master` merged into `3.x` with the **conflict markers committed**, so
|
||||||
you see exactly what clashed — and the required checks stay red until they're gone, so the PR
|
you see exactly what clashed — and the required checks stay red until they're gone, so the PR
|
||||||
can't be merged half-resolved. Mechanical files arrive **pre-resolved** (listed in the PR
|
can't be merged half-resolved. Non-lockfile mechanical files arrive **pre-resolved** (listed
|
||||||
under "Auto-resolved for you"), so only the real code conflicts need you:
|
in the PR under "Auto-resolved for you"), so only the code and lockfile conflicts need you:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git fetch origin sync/master-to-3x && git switch sync/master-to-3x
|
git fetch origin sync/master-to-3x && git switch sync/master-to-3x
|
||||||
|
|
@ -174,9 +176,8 @@ git fetch origin sync/master-to-3x && git switch sync/master-to-3x
|
||||||
git push origin sync/master-to-3x
|
git push origin sync/master-to-3x
|
||||||
```
|
```
|
||||||
|
|
||||||
If the PR says the lockfile was **deferred** (a `package.json` / `pnpm-workspace.yaml` is
|
If the PR says the lockfile was **deferred**, resolve the other conflicts first. Then
|
||||||
conflicted too), resolve the manifests first, then regenerate it with
|
regenerate it with `pnpm install --lockfile-only` and include the result in your fix commit.
|
||||||
`pnpm install --lockfile-only` and include the result in your fix commit.
|
|
||||||
|
|
||||||
Watch for the **"Deleted on one side, changed on the other"** section. Git leaves no markers
|
Watch for the **"Deleted on one side, changed on the other"** section. Git leaves no markers
|
||||||
for a delete/modify, so the branch looks clean where it is not: the merge keeps `3.x`'s side
|
for a delete/modify, so the branch looks clean where it is not: the merge keeps `3.x`'s side
|
||||||
|
|
|
||||||
316
.github/WORKFLOWS.md
vendored
316
.github/WORKFLOWS.md
vendored
|
|
@ -10,7 +10,6 @@ Complete reference for n8n's `.github/` folder.
|
||||||
.github/
|
.github/
|
||||||
├── WORKFLOWS.md # This document
|
├── WORKFLOWS.md # This document
|
||||||
├── CI-TELEMETRY.md # Telemetry & metrics guide
|
├── CI-TELEMETRY.md # Telemetry & metrics guide
|
||||||
├── CODEOWNERS # Temporary, side by side with OWNERS during the trial
|
|
||||||
├── pull_request_template.md # PR description template
|
├── pull_request_template.md # PR description template
|
||||||
├── pull_request_title_conventions.md # Title format rules (Angular)
|
├── pull_request_title_conventions.md # Title format rules (Angular)
|
||||||
├── actionlint.yml # Workflow linter config
|
├── actionlint.yml # Workflow linter config
|
||||||
|
|
@ -178,7 +177,7 @@ These only run if specific files changed:
|
||||||
| `docker/images/n8n-base/Dockerfile` | `build-base-image.yml` | any |
|
| `docker/images/n8n-base/Dockerfile` | `build-base-image.yml` | any |
|
||||||
| `**/package.json`, `**/turbo.json` | `build-windows.yml` | master |
|
| `**/package.json`, `**/turbo.json` | `build-windows.yml` | master |
|
||||||
| `packages/@n8n/ai-workflow-builder.ee/evaluations/programmatic/python/**` | `test-evals-python.yml` | any |
|
| `packages/@n8n/ai-workflow-builder.ee/evaluations/programmatic/python/**` | `test-evals-python.yml` | any |
|
||||||
| `packages/@n8n/benchmark/**` | `build-benchmark-image.yml` | master |
|
| `packages/quality/efficiency/scale/benchmark/**` | `build-benchmark-image.yml` | master |
|
||||||
| `packages/cli/src/public-api/**/*.yml`, `packages/cli/src/public-api/**/*.yaml`, `packages/cli/src/public-api/**/*.css`, `packages/cli/src/public-api/v1/openapi-gen/**/*.ts`, `packages/cli/scripts/build.mjs`, `packages/cli/package.json` | `util-publish-api-schema.yml` | master |
|
| `packages/cli/src/public-api/**/*.yml`, `packages/cli/src/public-api/**/*.yaml`, `packages/cli/src/public-api/**/*.css`, `packages/cli/src/public-api/v1/openapi-gen/**/*.ts`, `packages/cli/scripts/build.mjs`, `packages/cli/package.json` | `util-publish-api-schema.yml` | master |
|
||||||
| `packages/@n8n/instance-ai/src/**`, `packages/@n8n/instance-ai/skills/**`, `packages/@n8n/instance-ai/knowledge-base/**`, `packages/@n8n/instance-ai/evaluations/**`, `packages/cli/src/modules/instance-ai/**`, `packages/core/src/execution-engine/eval-mock-helpers.ts`, `packages/@n8n/agents/src/**` | `ci-instance-ai-evals.yml` | on PR `opened` / `reopened` / `ready_for_review` |
|
| `packages/@n8n/instance-ai/src/**`, `packages/@n8n/instance-ai/skills/**`, `packages/@n8n/instance-ai/knowledge-base/**`, `packages/@n8n/instance-ai/evaluations/**`, `packages/cli/src/modules/instance-ai/**`, `packages/core/src/execution-engine/eval-mock-helpers.ts`, `packages/@n8n/agents/src/**` | `ci-instance-ai-evals.yml` | on PR `opened` / `reopened` / `ready_for_review` |
|
||||||
| `docker/get-n8n.sh`, `docker/get-n8n-compose.yml`, `docker/test-get-n8n.sh` | `test-get-n8n.yml` | any |
|
| `docker/get-n8n.sh`, `docker/get-n8n-compose.yml`, `docker/test-get-n8n.sh` | `test-get-n8n.yml` | any |
|
||||||
|
|
@ -237,14 +236,6 @@ parallelism). See the `--build-via-mcp` section in
|
||||||
| PR merged to `release/*` | `release-publish.yml` |
|
| PR merged to `release/*` | `release-publish.yml` |
|
||||||
| PR closed with `codespace-preview` | `util-codespace-preview.yml` |
|
| PR closed with `codespace-preview` | `util-codespace-preview.yml` |
|
||||||
|
|
||||||
### Manual Triggers (PR Comments)
|
|
||||||
|
|
||||||
| Command | Workflow | Permissions |
|
|
||||||
|--------------------|------------------------------|---------------------|
|
|
||||||
| `/test-workflows` | `test-workflows-callable.yml`| admin/write/maintain|
|
|
||||||
|
|
||||||
**Why:** Re-run tests without pushing commits. Useful for flaky test investigation.
|
|
||||||
|
|
||||||
### Label Triggers
|
### Label Triggers
|
||||||
|
|
||||||
| Label | Workflow | Effect |
|
| Label | Workflow | Effect |
|
||||||
|
|
@ -254,7 +245,7 @@ parallelism). See the `--build-via-mcp` section in
|
||||||
| `preview:debug` | `util-codespace-preview.yml` | Re-serves the instance with `N8N_LOG_LEVEL=debug` |
|
| `preview:debug` | `util-codespace-preview.yml` | Re-serves the instance with `N8N_LOG_LEVEL=debug` |
|
||||||
|
|
||||||
**Why:** A reviewer gets a running instance of the PR without a Docker build or a
|
**Why:** A reviewer gets a running instance of the PR without a Docker build or a
|
||||||
cloud deploy. The workflow calls `scripts/preview.mjs`, which keeps one codespace
|
cloud deploy. The workflow calls `scripts/codespace-preview/preview.mjs`, which keeps one codespace
|
||||||
for each PR (display name `preview/pr-<number>`) and shares port 5678 with the
|
for each PR (display name `preview/pr-<number>`) and shares port 5678 with the
|
||||||
organization. A later push serves the new head in the same box. Removing the
|
organization. A later push serves the new head in the same box. Removing the
|
||||||
label, or closing the PR, deletes the box.
|
label, or closing the PR, deletes the box.
|
||||||
|
|
@ -262,19 +253,63 @@ label, or closing the PR, deletes the box.
|
||||||
Only a PR from a branch in this repository is eligible: a codespace token is
|
Only a PR from a branch in this repository is eligible: a codespace token is
|
||||||
scoped to `n8n-io/n8n` and cannot check out a fork head.
|
scoped to `n8n-io/n8n` and cannot check out a fork head.
|
||||||
|
|
||||||
|
#### Live progress on the PR
|
||||||
|
|
||||||
|
`up` and `refresh` take minutes, and an absent comment looks the same as a broken
|
||||||
|
preview. So the comment goes up before the box work starts, as a checklist of the
|
||||||
|
phases in `scripts/codespace-preview/preview-phases.mjs`, and is edited for each phase and once a
|
||||||
|
minute after that. The final URL replaces it in place.
|
||||||
|
|
||||||
|
A comment **edit sends no notification** — only a create does. That is what makes a
|
||||||
|
heartbeat on a sticky comment acceptable at all.
|
||||||
|
|
||||||
|
A `refresh` keeps the URL of the previous run in the checklist. The URL does not
|
||||||
|
change between runs, and taking a working link off the PR for several minutes is
|
||||||
|
worse than saying it is briefly down.
|
||||||
|
|
||||||
|
A cancelled job — including the 45-minute `timeout-minutes` — kills the script while
|
||||||
|
its checklist is up, so a last `if: cancelled()` step writes the outcome instead. It
|
||||||
|
writes **only over a checklist**: a run cancelled while it was queued never started
|
||||||
|
work, and must leave the previous run's URL alone.
|
||||||
|
|
||||||
|
#### Running it by hand
|
||||||
|
|
||||||
|
A box sleeps after 2 hours of no use, and GitHub makes every forwarded port
|
||||||
|
private again at each start. So a preview that slept reaches nobody until
|
||||||
|
something shares port 5678 again, and its backend is gone with the container.
|
||||||
|
**Actions → Util: Codespace Preview → Run workflow** does both without a commit
|
||||||
|
and without a label toggle:
|
||||||
|
|
||||||
|
| Input | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| `pr_number` | The pull request to act on. |
|
||||||
|
| `operation` | `up` (default) creates the box if it is gone, starts it if it sleeps, serves the head and shares the port again. `refresh` re-serves the head in a box that already exists. `down` deletes the box. |
|
||||||
|
|
||||||
|
Prefer `up` unless you mean to delete: it covers create, wake and re-share.
|
||||||
|
|
||||||
|
The button needs write access, and it appears only once the trigger is on
|
||||||
|
`master` — GitHub lists dispatchable workflows from the default branch. A manual
|
||||||
|
run takes the branch picked in the dropdown, which is the branch GitHub read the
|
||||||
|
workflow from, so a branch can test a change to the preview scripts. A fork head
|
||||||
|
is still refused, by `preview.mjs` rather than by the job's `if`. There is no
|
||||||
|
`ls` operation: it needs no PR and posts no comment — run `pnpm preview ls`
|
||||||
|
locally.
|
||||||
|
|
||||||
#### Preview toggles
|
#### Preview toggles
|
||||||
|
|
||||||
A `preview:*` label configures an instance that already exists, so adding or
|
A `preview:*` label configures an instance that already exists, so adding or
|
||||||
removing one re-serves the box instead of creating or deleting it. It does
|
removing one re-serves the box instead of creating or deleting it. It does
|
||||||
nothing on a PR without `codespace-preview`.
|
nothing on a PR without `codespace-preview`.
|
||||||
|
|
||||||
The vocabulary lives in `scripts/preview-labels.mjs`, which both ends import:
|
The vocabulary lives in `scripts/codespace-preview/preview-labels.mjs`, which both ends import:
|
||||||
`preview.mjs` turns the PR's labels into slugs, and `preview-serve.mjs` turns
|
`preview.mjs` turns the PR's labels into slugs, and `preview-serve.mjs` turns
|
||||||
those slugs into environment inside the box. Add a toggle there, in one place.
|
those slugs into environment inside the box. Add a toggle there, in one place.
|
||||||
|
|
||||||
Only slugs cross the gap. The `gh codespace ssh` command is a shell string that
|
Two things cross the gap, and both are shape-checked rather than trusted: a
|
||||||
appears in the box's process list, so a value is never passed through it —
|
`preview:*` slug, and a phase key from `scripts/codespace-preview/preview-phases.mjs`. The `gh
|
||||||
`preview:enterprise` resolves to a licence key inside the box, not on the runner.
|
codespace ssh` command is a shell string that appears in the box's process list, so
|
||||||
|
a value is never passed through it — `preview:enterprise` resolves to a licence key
|
||||||
|
inside the box, not on the runner.
|
||||||
|
|
||||||
`preview:enterprise` needs a **Codespaces** secret named
|
`preview:enterprise` needs a **Codespaces** secret named
|
||||||
`N8N_LICENSE_ACTIVATION_KEY`, scoped to `n8n-io/n8n`. That is a Codespaces
|
`N8N_LICENSE_ACTIVATION_KEY`, scoped to `n8n-io/n8n`. That is a Codespaces
|
||||||
|
|
@ -289,6 +324,39 @@ whether the key reaches the box. Anyone who can run PR-head code can read
|
||||||
`/workspaces/.codespaces/shared/.env-secrets`. Previews are limited to branches
|
`/workspaces/.codespaces/shared/.env-secrets`. Previews are limited to branches
|
||||||
in this repository, so that is the set of people who already have write access.
|
in this repository, so that is the set of people who already have write access.
|
||||||
|
|
||||||
|
#### Preview environment from a webhook
|
||||||
|
|
||||||
|
A preview can also take environment from an n8n webhook we control, so a value
|
||||||
|
can change without a commit and a merge. `scripts/codespace-preview/preview-remote-env.mjs` fetches
|
||||||
|
it, and `preview-serve.mjs` hands the result to the backend.
|
||||||
|
|
||||||
|
It needs three **Codespaces** secrets on `n8n-io/n8n`, again not Actions secrets:
|
||||||
|
|
||||||
|
| Secret | Purpose |
|
||||||
|
| ------------------------ | ------------------------------------------------- |
|
||||||
|
| `CODESPACE_ENV_URL` | The webhook URL |
|
||||||
|
| `CODESPACE_ENV_USER` | Basic auth user. Optional, defaults to `preview`. |
|
||||||
|
| `CODESPACE_ENV_PASSWORD` | Basic auth password |
|
||||||
|
|
||||||
|
The webhook answers with a flat JSON object. Its keys become environment
|
||||||
|
variables and its values are used as-is, so a number or a boolean is stringified
|
||||||
|
and a nested object is dropped. The request carries the PR number and the head
|
||||||
|
SHA as query parameters, so one endpoint can answer per PR.
|
||||||
|
|
||||||
|
The fetch runs in the box, not on the runner. Codespaces secrets are unreadable
|
||||||
|
from Actions, so neither the password nor a returned value can reach a CI log.
|
||||||
|
The log prints key names only.
|
||||||
|
|
||||||
|
**Every key is passed through.** A response containing `NODE_OPTIONS`,
|
||||||
|
`EXTERNAL_HOOK_FILES` or `PATH` runs code inside the preview box, so whoever can
|
||||||
|
edit that workflow can run code there. The one exception is the preview's own
|
||||||
|
wiring — the sign-in hook and the owner credentials — which is applied last and
|
||||||
|
wins. The `.env-secrets` note above applies to these secrets too.
|
||||||
|
|
||||||
|
Nothing here is required. Without the secrets, an unreachable webhook or a
|
||||||
|
rejected password, the preview serves as usual and says so in the log. A wrong
|
||||||
|
password is not retried: it cannot fix itself.
|
||||||
|
|
||||||
#### The `CODESPACE_PREVIEW_TOKEN` secret
|
#### The `CODESPACE_PREVIEW_TOKEN` secret
|
||||||
|
|
||||||
The job needs `CODESPACE_PREVIEW_TOKEN`, a **fine-grained** personal access token,
|
The job needs `CODESPACE_PREVIEW_TOKEN`, a **fine-grained** personal access token,
|
||||||
|
|
@ -334,14 +402,18 @@ better than a person's account for quota attribution, though the token is scoped
|
||||||
to one repository either way.
|
to one repository either way.
|
||||||
|
|
||||||
The job checks out the base branch, never the PR head, so a PR cannot supply the
|
The job checks out the base branch, never the PR head, so a PR cannot supply the
|
||||||
script that reads that token.
|
script that reads that token. A manual run checks out the branch chosen in the
|
||||||
|
Run-workflow dropdown, which only a user with write access can pick.
|
||||||
|
|
||||||
### Other Manual Workflows
|
### Other Manual Workflows
|
||||||
|
|
||||||
| Workflow | Purpose |
|
| Workflow | Purpose |
|
||||||
|-----------------------------|---------------------------------------------------------|
|
|-----------------------------|---------------------------------------------------------|
|
||||||
|
| `util-codespace-preview.yml`| Wake, re-serve or delete a PR preview instance by hand |
|
||||||
| `util-data-tooling.yml` | SQLite/PostgreSQL export/import validation (manual) |
|
| `util-data-tooling.yml` | SQLite/PostgreSQL export/import validation (manual) |
|
||||||
|
| `test-image-efficiency.yml` | Measure n8n and runners image size and layer waste with Dive |
|
||||||
| `util-probe-registry.yml` | Diagnose slow npm metadata fetches (temporary) |
|
| `util-probe-registry.yml` | Diagnose slow npm metadata fetches (temporary) |
|
||||||
|
| `sec-sync-bundle-branches.yml` | Sync both bundle branches on demand, including before a bundle cut |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -370,11 +442,10 @@ release-publish.yml
|
||||||
│ └──────────▶ security-trivy-scan-callable.yml
|
│ └──────────▶ security-trivy-scan-callable.yml
|
||||||
└──────────────────────────▶ sbom-generation-callable.yml
|
└──────────────────────────▶ sbom-generation-callable.yml
|
||||||
|
|
||||||
test-workflows-nightly.yml (manual dispatch only — nightly schedule disabled, DEVP-544)
|
test-sbom-nightly.yml
|
||||||
└──────────────────────────▶ test-workflows-callable.yml
|
└──────────────────────────▶ sbom-validation-callable.yml
|
||||||
|
|
||||||
PR Comment Dispatchers (triggered by /command in PR comments):
|
test-workflows-nightly.yml (manual dispatch only — nightly schedule disabled, DEVP-544)
|
||||||
test-workflows-pr-comment.yml
|
|
||||||
└──────────────────────────▶ test-workflows-callable.yml
|
└──────────────────────────▶ test-workflows-callable.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -493,14 +564,15 @@ out: `npm deprecate n8n@X.Y.Z "Failed release, use X.Y.(Z+1)"`.
|
||||||
|
|
||||||
## ci-master.yml
|
## ci-master.yml
|
||||||
|
|
||||||
Runs on push to `master` or `1.x`:
|
Runs on push to `master`:
|
||||||
|
|
||||||
```
|
```
|
||||||
Push to master/1.x
|
Push to master
|
||||||
├─ build-github (populate cache)
|
├─ build-and-format (Blacksmith: build, then format check; populate master cache)
|
||||||
├─ unit-test (matrix: Node 22.23.2, 24.18.1)
|
├─ unit-test (matrix: Node 24.18.1, 26.5.1)
|
||||||
│ └─ Coverage only on 24.18.1
|
│ └─ Coverage only on 24.18.1
|
||||||
├─ lint
|
├─ lint
|
||||||
|
├─ (performance: CodSpeed benchmarks, paused until the plugin supports Vitest 5)
|
||||||
├─ verify-single-instance-npm (advisory; packages changed by this push)
|
├─ verify-single-instance-npm (advisory; packages changed by this push)
|
||||||
└─ notify-on-failure (Slack #alerts-build)
|
└─ notify-on-failure (Slack #alerts-build)
|
||||||
```
|
```
|
||||||
|
|
@ -515,18 +587,20 @@ Push to master/1.x
|
||||||
| Daily 03:00 | `sec-sync-bundle-branches.yml` | Merge the base into `bundle/*` |
|
| Daily 03:00 | `sec-sync-bundle-branches.yml` | Merge the base into `bundle/*` |
|
||||||
| Daily 00:00 | `docker-build-push.yml` | Nightly Docker images |
|
| Daily 00:00 | `docker-build-push.yml` | Nightly Docker images |
|
||||||
| Daily 00:00 | `test-db.yml` | Database compatibility |
|
| Daily 00:00 | `test-db.yml` | Database compatibility |
|
||||||
| Daily 00:00 | `test-e2e-performance-reusable.yml`| Performance E2E |
|
| Daily 00:00 | `test-e2e-performance-reusable.yml`| Browser performance and idle memory baselines |
|
||||||
| Daily 00:00 | `release-storybook.yml` | Storybook deploy |
|
| Daily 00:00 | `release-storybook.yml` | Storybook deploy |
|
||||||
| Daily 00:00 | `release-chromatic.yml` | Visual regression |
|
| Daily 00:00 | `release-chromatic.yml` | Visual regression |
|
||||||
| Daily 00:00 | `util-check-docs-urls.yml` | Doc link validation |
|
| Daily 00:00 | `util-check-docs-urls.yml` | Doc link validation |
|
||||||
| Daily 01:30, 02:30, 03:30 | `test-benchmark-nightly.yml` | Performance benchmarks |
|
| Daily 01:30, 02:30, 03:30 | `test-benchmark-nightly.yml` | Performance benchmarks |
|
||||||
| Daily 02:00 | `test-get-n8n.yml` | get.n8n.io installer health |
|
| Daily 02:00 | `test-get-n8n.yml` | get.n8n.io installer health |
|
||||||
| Daily 02:00 | `test-e2e-pc-nightly.yml` | E2E on the `-pc` image |
|
| Daily 02:00 | `test-e2e-pc-nightly.yml` | E2E on the `-pc` image |
|
||||||
|
| Daily 04:00 | `test-sbom-nightly.yml` | Release and image SBOM license validation |
|
||||||
| Daily 05:00 | `test-benchmark-destroy-nightly.yml`| Cleanup benchmark env |
|
| Daily 05:00 | `test-benchmark-destroy-nightly.yml`| Cleanup benchmark env |
|
||||||
| Daily 06:00 | `util-sync-master-to-3x.yml` | Replay 3.x onto master (v3) |
|
| Daily 06:00 | `util-sync-master-to-3x.yml` | Replay 3.x onto master (v3) |
|
||||||
| Daily 08:00 | `build-v3-nightly.yml` | Nightly v3 Docker images |
|
| Daily 08:00 | `build-v3-nightly.yml` | Nightly v3 Docker images |
|
||||||
| Monday 00:00 | `util-update-node-popularity.yml` | Node usage stats |
|
| Monday 00:00 | `util-update-node-popularity.yml` | Node usage stats |
|
||||||
| Monday 02:00 | `test-e2e-coverage-weekly.yml` | Weekly E2E coverage |
|
| Monday 02:00 | `test-e2e-coverage-weekly.yml` | Weekly E2E coverage |
|
||||||
|
| Wednesday 04:00 | `util-update-get-n8n-versions.yml` | get-n8n stable versions |
|
||||||
| Saturday 22:00 | `test-evals-ai.yml` | AI workflow evals |
|
| Saturday 22:00 | `test-evals-ai.yml` | AI workflow evals |
|
||||||
| 1st of month 04:00 | `util-refresh-cubic-schema.yml` | Refresh vendored cubic schema |
|
| 1st of month 04:00 | `util-refresh-cubic-schema.yml` | Refresh vendored cubic schema |
|
||||||
|
|
||||||
|
|
@ -534,18 +608,21 @@ Push to master/1.x
|
||||||
|
|
||||||
## v3 development (master + 3.x)
|
## v3 development (master + 3.x)
|
||||||
|
|
||||||
|
The sync runs automation code from the triggering `master` SHA while its working checkout
|
||||||
|
stays on `3.x`.
|
||||||
|
|
||||||
During the v3 release window, `master` carries normal feature work (behind opt-in
|
During the v3 release window, `master` carries normal feature work (behind opt-in
|
||||||
flags) and the long-lived `3.x` branch carries breaking changes. `util-sync-master-to-3x.yml`
|
flags) and the long-lived `3.x` branch carries breaking changes. `util-sync-master-to-3x.yml`
|
||||||
syncs daily by **replaying the `3.x`-only commits onto `master` and force-pushing `3.x`**, so a
|
syncs daily by **replaying the `3.x`-only commits onto `master` and force-pushing `3.x`**, so a
|
||||||
clean sync adds no commit and nothing is squashed. What it pushes is always verified to be
|
clean sync adds no commit and nothing is squashed. What it pushes is always verified to be
|
||||||
exactly the tree a merge of `3.x` and `master` produces, and marker-free. Conflicts confined
|
exactly the tree a merge of `3.x` and `master` produces, and marker-free. Conflicts confined
|
||||||
to mechanical, tool-generated files (the pnpm lockfile, bot-maintained data files — see
|
to non-lockfile mechanical files (bot-maintained data files — see `MECHANICAL_PATHS` in
|
||||||
`MECHANICAL_PATHS` in `sync-master-to-3x.mjs`) are auto-resolved during the replay; the tree
|
`sync-master-to-3x.mjs`) are auto-resolved during the replay. On a code or `pnpm-lock.yaml`
|
||||||
check then applies to every path except those files. On a real code conflict `3.x` is left
|
conflict, `3.x` is left untouched and a draft PR carrying the conflict markers (labeled
|
||||||
untouched and a draft PR carrying the conflict markers (labeled `automation:v3-sync`, with
|
`automation:v3-sync`, with other mechanical files pre-resolved) is opened on
|
||||||
mechanical files pre-resolved) is opened on `sync/master-to-3x`, naming both ends of the
|
`sync/master-to-3x`. The lockfile is always left for the resolver. The PR names both ends of
|
||||||
conflict — the breaking-commit authors and the `master` commits that touched the same files
|
the conflict — the breaking-commit authors and the `master` commits that touched the same
|
||||||
— via `sync-conflict-owners.mjs`, posting to `#alerts-v3-sync` and pausing further syncs
|
files — via `sync-conflict-owners.mjs`, posts to `#alerts-v3-sync`, and pauses further syncs
|
||||||
until it is resolved and merged normally. Delete/modify conflicts have no markers to carry,
|
until it is resolved and merged normally. Delete/modify conflicts have no markers to carry,
|
||||||
so they are resolved toward `3.x` and listed as an explicit decision in the PR body.
|
so they are resolved toward `3.x` and listed as an explicit decision in the PR body.
|
||||||
`build-v3-nightly.yml` publishes `n8nio/n8n:v3-nightly[-<date>]` images from `3.x`
|
`build-v3-nightly.yml` publishes `n8nio/n8n:v3-nightly[-<date>]` images from `3.x`
|
||||||
|
|
@ -568,6 +645,7 @@ Composite actions in `.github/actions/`:
|
||||||
| Action | Purpose | Used By |
|
| Action | Purpose | Used By |
|
||||||
|--------------------------|----------------------------------------------|--------------------|
|
|--------------------------|----------------------------------------------|--------------------|
|
||||||
| `setup-nodejs` | pnpm + Node.js + Turbo cache + Docker (opt) | Most CI workflows |
|
| `setup-nodejs` | pnpm + Node.js + Turbo cache + Docker (opt) | Most CI workflows |
|
||||||
|
| `run-workflow-script` | Run a `.github/scripts` module with no setup or install | Owners and PR quality checks |
|
||||||
| `docker-registry-login` | GHCR + DockerHub + DHI authentication | Docker workflows |
|
| `docker-registry-login` | GHCR + DockerHub + DHI authentication | Docker workflows |
|
||||||
|
|
||||||
### setup-nodejs
|
### setup-nodejs
|
||||||
|
|
@ -604,6 +682,30 @@ while the build reports a successful commit. Every job therefore shares the
|
||||||
`n8n-io/n8n` key, which is the only disk that actually retains layers. Revisit
|
`n8n-io/n8n` key, which is the only disk that actually retains layers. Revisit
|
||||||
once new-disk retention works.
|
once new-disk retention works.
|
||||||
|
|
||||||
|
### run-workflow-script
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
inputs:
|
||||||
|
script: # path of the module, relative to the repository root
|
||||||
|
github-token: # token for the Octokit client, also exported as GITHUB_TOKEN
|
||||||
|
```
|
||||||
|
|
||||||
|
Runs one `.github/scripts` module through `actions/github-script`. That action
|
||||||
|
brings its own Node.js and an Octokit client, so the job needs no
|
||||||
|
`setup-nodejs` step and no dependency install. The action loads
|
||||||
|
`github-helpers.mjs`, hands the client to `setOctokit`, then imports the module
|
||||||
|
and awaits its exported `main()`.
|
||||||
|
|
||||||
|
Use it for a module that imports only node builtins and other `.github/scripts`
|
||||||
|
modules. `github-helpers.mjs` loads `@actions/github` and `semver` only when
|
||||||
|
they are present, so it works in both modes. A module that needs an npm
|
||||||
|
package (`semver`, `yaml`, `minimatch`, ...) keeps the `setup-nodejs` path with
|
||||||
|
the `.github/scripts` install command.
|
||||||
|
|
||||||
|
Pair it with a sparse checkout of `.github` when the module reads nothing else
|
||||||
|
from the tree. Cone mode always includes the root files, so `OWNERS` and
|
||||||
|
`package.json` stay available.
|
||||||
|
|
||||||
### docker-registry-login
|
### docker-registry-login
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
@ -640,8 +742,10 @@ Workflows with `workflow_call` trigger:
|
||||||
| `docker-build-push.yml` | `n8n_version`, `release_type`, `push_enabled`, `ref`, `date_tag`, `create_attestations` | Docker build |
|
| `docker-build-push.yml` | `n8n_version`, `release_type`, `push_enabled`, `ref`, `date_tag`, `create_attestations` | Docker build |
|
||||||
| `sec-ci-reusable.yml` | `ref` | Security orchestrator |
|
| `sec-ci-reusable.yml` | `ref` | Security orchestrator |
|
||||||
| `sec-poutine-reusable.yml` | `ref` | Poutine scanner |
|
| `sec-poutine-reusable.yml` | `ref` | Poutine scanner |
|
||||||
|
| `sec-sync-retarget-prs.yml` | none | Move bundle PRs back onto `bundle/*` |
|
||||||
| `security-trivy-scan-callable.yml` | `image_ref` | Trivy scan |
|
| `security-trivy-scan-callable.yml` | `image_ref` | Trivy scan |
|
||||||
| `sbom-generation-callable.yml` | `n8n_version`, `release_tag_ref` | SBOM generation |
|
| `sbom-generation-callable.yml` | `n8n_version`, `release_tag_ref` | SBOM generation |
|
||||||
|
| `sbom-validation-callable.yml` | `sha` | Read-only SBOM validation |
|
||||||
| `test-single-instance-npm.yml` | `scope`, `base-ref`, `base-branch`, `blocking`, `timeout-minutes` | Dependency duplication |
|
| `test-single-instance-npm.yml` | `scope`, `base-ref`, `base-branch`, `blocking`, `timeout-minutes` | Dependency duplication |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -669,6 +773,7 @@ Scripts in `.github/scripts/`:
|
||||||
| `docker/kafka-native-smoke-check.mjs`| Verify librdkafka binary loads in built image | `docker-build-smoke.yml`|
|
| `docker/kafka-native-smoke-check.mjs`| Verify librdkafka binary loads in built image | `docker-build-smoke.yml`|
|
||||||
| `docker/assert-manifest-format.mjs`| Assert a merged manifest is an OCI image index with the expected platforms | `docker-build-push.yml`|
|
| `docker/assert-manifest-format.mjs`| Assert a merged manifest is an OCI image index with the expected platforms | `docker-build-push.yml`|
|
||||||
| `docker/should-smoke-build.mjs`| Narrow the `pnpm-workspace.yaml` smoke trigger to native dependency pins | `docker-build-smoke.yml`|
|
| `docker/should-smoke-build.mjs`| Narrow the `pnpm-workspace.yaml` smoke trigger to native dependency pins | `docker-build-smoke.yml`|
|
||||||
|
| `attest-image-sbom.mjs` | Generate, validate, and optionally attest image SBOMs | `docker-build-push.yml`, `test-sbom-nightly.yml` |
|
||||||
|
|
||||||
### Validation Scripts
|
### Validation Scripts
|
||||||
|
|
||||||
|
|
@ -677,20 +782,26 @@ Scripts in `.github/scripts/`:
|
||||||
| `validate-docs-links.js`| Check doc URLs | `util-check-docs-urls.yml`|
|
| `validate-docs-links.js`| Check doc URLs | `util-check-docs-urls.yml`|
|
||||||
| `send-build-stats.mjs` | Build telemetry | `setup-nodejs` action |
|
| `send-build-stats.mjs` | Build telemetry | `setup-nodejs` action |
|
||||||
| `resolve-pnpm-version.mjs` | Publish the pinned pnpm version and its executable cache key | `setup-nodejs` action |
|
| `resolve-pnpm-version.mjs` | Publish the pinned pnpm version and its executable cache key | `setup-nodejs` action |
|
||||||
|
| `nightly-sbom-context.mjs` | Resolve the source SHA and image tag for nightly SBOM validation | `test-sbom-nightly.yml` |
|
||||||
| `db-test-matrix.mjs` | DB test matrix from `postgres-versions.json` | `ci-pull-requests.yml` |
|
| `db-test-matrix.mjs` | DB test matrix from `postgres-versions.json` | `ci-pull-requests.yml` |
|
||||||
| `quality/check-cubic-config.mjs` | Validate `cubic.yaml` against the vendored cubic schema; enforce its silent agent/character limits. `--refresh` re-pulls the schema | `test-workflow-scripts-reusable.yml`, `util-refresh-cubic-schema.yml` |
|
| `quality/check-cubic-config.mjs` | Validate `cubic.yaml` against the vendored cubic schema; enforce its silent agent/character limits. `--refresh` re-pulls the schema | `test-workflow-scripts-reusable.yml`, `util-refresh-cubic-schema.yml` |
|
||||||
|
| `glob.mjs` | Builtin-only glob matcher for changed-file paths (`**`, `*`, dot segments) | `quality/check-pr-size.mjs` |
|
||||||
| `probe-registry.mjs` | Registry path throughput probe (temporary) | `util-probe-registry.yml` |
|
| `probe-registry.mjs` | Registry path throughput probe (temporary) | `util-probe-registry.yml` |
|
||||||
|
|
||||||
### Preview Scripts
|
### Preview Scripts
|
||||||
|
|
||||||
| Script | Purpose | Called By |
|
| Script | Purpose | Called By |
|
||||||
|---------------------------------|-------------------------------------------------------------------------|--------------------------------|
|
|---------------------------------|-------------------------------------------------------------------------|--------------------------------|
|
||||||
| `codespace-preview.mjs` | Map a `pull_request` event onto a preview operation, comment the result | `util-codespace-preview.yml` |
|
| `codespace-preview.mjs` | Map a `pull_request` event or a manual operation onto a preview operation, comment the result | `util-codespace-preview.yml` |
|
||||||
| `../../scripts/preview.mjs` | One codespace for each PR: `up`, `refresh`, `down`, `ls`. `--json` for CI | `codespace-preview.mjs`, developers |
|
| `../../scripts/codespace-preview/preview.mjs` | One codespace for each PR: `up`, `refresh`, `down`, `ls`. `--json` for CI | `codespace-preview.mjs`, developers |
|
||||||
|
| `../../scripts/codespace-preview/preview-remote-env.mjs` | Fetch extra environment for a preview from the webhook, inside the box | `../../scripts/codespace-preview/preview-serve.mjs` |
|
||||||
|
| `../../scripts/codespace-preview/preview-phases.mjs` | The phase vocabulary and its one-line marker, so the runner, the box and the comment cannot drift | `codespace-preview.mjs`, `../../scripts/codespace-preview/preview.mjs`, `../../scripts/codespace-preview/preview-serve.mjs` |
|
||||||
|
|
||||||
`scripts/preview.mjs` is also the developer entry point (`pnpm preview up <pr>`).
|
`scripts/codespace-preview/preview.mjs` is also the developer entry point (`pnpm preview up <pr>`).
|
||||||
In `--json` mode it prints one object on stdout and sends all progress to stderr,
|
In `--json` mode stdout carries one line for each phase and then the report object,
|
||||||
so a workflow can read the URL from a run that also streams an in-box build log.
|
and all human progress goes to stderr. So a workflow can follow a run that also
|
||||||
|
streams an in-box build log. The reader tells the two apart by the `url` field: the
|
||||||
|
report has one, a phase line never does.
|
||||||
|
|
||||||
### Branch Replay Scripts
|
### Branch Replay Scripts
|
||||||
|
|
||||||
|
|
@ -702,7 +813,7 @@ rewrite safe.
|
||||||
|----------------------------|----------------------------------------------------------------------|------------------------------------|
|
|----------------------------|----------------------------------------------------------------------|------------------------------------|
|
||||||
| `branch-replay.mjs` | Shared primitives: merge-tree, tree guard, marker scan | the two scripts below |
|
| `branch-replay.mjs` | Shared primitives: merge-tree, tree guard, marker scan | the two scripts below |
|
||||||
| `sync-master-to-3x.mjs` | master → `3.x`, rebased; auto-resolves mechanical files, opens a conflict PR | `util-sync-master-to-3x.yml` |
|
| `sync-master-to-3x.mjs` | master → `3.x`, rebased; auto-resolves mechanical files, opens a conflict PR | `util-sync-master-to-3x.yml` |
|
||||||
| `sync-bundle-branch.mjs` | base → `bundle/*` in n8n-private, merged; fail-loud, never resolves conflicts | `sec-sync-bundle-branches.yml` |
|
| `sync-bundle-branch.mjs` | base → `bundle/*` in n8n-private, merged; skips while the base is unpublished; fail-loud, never resolves conflicts | `sec-sync-bundle-branches.yml` |
|
||||||
|
|
||||||
### Slack Scripts
|
### Slack Scripts
|
||||||
|
|
||||||
|
|
@ -729,9 +840,8 @@ See **[CI-TELEMETRY.md](CI-TELEMETRY.md)** for:
|
||||||
|
|
||||||
## OWNERS
|
## OWNERS
|
||||||
|
|
||||||
Team ownership lives in the top-level `OWNERS` file (this replaces the
|
Team ownership lives in the top-level `OWNERS` file. The scripts that consume
|
||||||
GitHub-native `CODEOWNERS` file; see the transition note below). The scripts
|
it live in `.github/scripts/owners/`. Line format:
|
||||||
that consume it live in `.github/scripts/owners/`. Line format:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
<pattern> <@org/team> [required]
|
<pattern> <@org/team> [required]
|
||||||
|
|
@ -763,27 +873,57 @@ The file drives four workflows:
|
||||||
### Required reviews
|
### Required reviews
|
||||||
|
|
||||||
An entry with the `required` option makes team approval mandatory: when a PR
|
An entry with the `required` option makes team approval mandatory: when a PR
|
||||||
changes a file whose winning entry carries `required`, a member of each listed
|
changes a non-test file whose winning entry carries `required`, a member of each
|
||||||
team must approve the PR. `ci-owners-required-reviews.yml` evaluates this on
|
listed team must approve the PR. Test files match the shared patterns in
|
||||||
|
`test-files.mjs` and do not trigger required reviews.
|
||||||
|
`ci-owners-required-reviews.yml` evaluates this on
|
||||||
PR changes and review events, and reports a commit status
|
PR changes and review events, and reports a commit status
|
||||||
named **Required Reviews** on the head SHA. The ruleset for `master` must list
|
named **Required Reviews** on the head SHA. A missing approval reports
|
||||||
that status as a required check for the block to take effect. Merge-queue runs
|
`pending` ("Waiting for approval from: …"), not `failure`, so an unreviewed PR
|
||||||
report success on the queue head without re-evaluating: a PR cannot enter the
|
does not show red CI; any non-success state blocks the merge equally. The
|
||||||
queue unless the status is green on its head, and the queue does not change
|
ruleset for a branch must list that status as a required check for the block
|
||||||
approvals.
|
to take effect. Merge-queue runs report success on the queue head without
|
||||||
|
re-evaluating: a PR cannot enter the queue unless the status is green on its
|
||||||
|
head, and the queue does not change approvals.
|
||||||
|
|
||||||
The workflow reads OWNERS and its scripts from the base branch only, so a PR
|
The status is evaluated for a PR into any base branch, from a same-repo head
|
||||||
cannot lift its own review requirement.
|
or a fork. Both matter because the ruleset that gates a PR is not always the
|
||||||
|
one on its base branch: GitHub applies the ruleset of a stack's target branch
|
||||||
|
to every PR in the stack, so a stacked PR into a feature branch is gated by
|
||||||
|
the `master` ruleset. A required status that no run ever writes leaves the PR
|
||||||
|
blocked on "Expected". Routes that skip the evaluation are listed in
|
||||||
|
`REQUIRED_REVIEW_EXEMPTIONS` in
|
||||||
|
`required-reviews.mjs`. An entry is `<head> -> <base>` or just `<base>`
|
||||||
|
(any head); `*` matches any run of characters. An exempt PR reports
|
||||||
|
`success` with the route in the description. Only heads in this repository
|
||||||
|
can match, so a fork branch with a matching name is still evaluated. Add a
|
||||||
|
route only when every commit it carries was already reviewed elsewhere, as
|
||||||
|
with `sync/master-to-3x -> 3.x`: its commits landed on `master` first.
|
||||||
|
|
||||||
### Transition from CODEOWNERS
|
The workflow reads OWNERS, its scripts and the exemption routes from `master`
|
||||||
|
only, never from the base branch or the PR: any writable branch can be a base,
|
||||||
|
so only `master` is trusted input. A PR cannot lift its own review
|
||||||
|
requirement. A retarget re-evaluates the PR, so a verdict computed against the
|
||||||
|
old base does not carry over.
|
||||||
|
|
||||||
During a trial period, `.github/CODEOWNERS` stays in place next to OWNERS:
|
Members of the `large-scale-changes` GitHub team can make the **Required
|
||||||
GitHub's native code-owner enforcement keeps gating merges while the
|
Reviews** status succeed without required OWNERS team approvals. A team member
|
||||||
"Required Reviews" status runs side by side. The two must agree — CODEOWNERS
|
must apply the `large-scale-change` label. The gate checks the actor from the
|
||||||
holds exactly the `required` entries of OWNERS (plus the OWNERS file itself)
|
label event and verifies their current team membership. The label alone is not
|
||||||
and must not gain new entries; new ownership goes into OWNERS. After the
|
sufficient. Label changes re-evaluate the status. Removing the label removes
|
||||||
trial, delete `.github/CODEOWNERS`, remove "Require review from Code Owners"
|
the exemption.
|
||||||
from the master ruleset, and delete this section (tracked in DEVP-887).
|
|
||||||
|
Every path that writes the status runs in the base repository context, because
|
||||||
|
a fork-context run has no secrets and a read-only token. PR changes arrive
|
||||||
|
through `pull_request_target`, which is safe here because no step checks out
|
||||||
|
or runs PR code. Review events on a same-repo PR arrive through
|
||||||
|
`pull_request_review`. Review events on a fork PR arrive through the
|
||||||
|
`workflow_run` of `ci-pull-request-review.yml`, which runs on every submitted
|
||||||
|
or dismissed review; the owners workflow looks the PR up from that run's head
|
||||||
|
and skips same-repo heads, which the direct event already covers. A first
|
||||||
|
contribution whose runs still wait for approval gets no review-event
|
||||||
|
re-evaluation until a maintainer approves the runs; `workflow_dispatch` with
|
||||||
|
the PR number is the manual fallback.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -808,7 +948,7 @@ from the master ruleset, and delete this section (tracked in DEVP-887).
|
||||||
|
|
||||||
**`blacksmith-4vcpu-ubuntu-2204`** - Unit tests (parallelized), linting (parallel file processing), typechecking (CPU-intensive), E2E test shards
|
**`blacksmith-4vcpu-ubuntu-2204`** - Unit tests (parallelized), linting (parallel file processing), typechecking (CPU-intensive), E2E test shards
|
||||||
|
|
||||||
**`blacksmith-8vcpu-ubuntu-2204`** - Heavy parallel workloads
|
**`blacksmith-8vcpu-ubuntu-2204`** - Heavy parallel workloads. The PR `install-and-build` job uses it with the default runner provider. Most PR jobs wait for that job, and a cold build keeps all 4 vCPUs of a smaller runner busy.
|
||||||
|
|
||||||
### Runner Provider Toggle
|
### Runner Provider Toggle
|
||||||
|
|
||||||
|
|
@ -906,6 +1046,13 @@ Packages whose license cannot be resolved from disk go in
|
||||||
`scripts/licenses/license-overrides.json` with a verified `source` citation — the upstream
|
`scripts/licenses/license-overrides.json` with a verified `source` citation — the upstream
|
||||||
LICENSE file, not registry metadata.
|
LICENSE file, not registry metadata.
|
||||||
|
|
||||||
|
`test-sbom-nightly.yml` runs at 04:00 UTC. It waits up to two hours for the current scheduled
|
||||||
|
Docker build to complete. It builds the production deployment closure at that run's SHA and
|
||||||
|
validates the release SBOM. It also resolves the four immutable SHA image tags from that
|
||||||
|
build and validates each image SBOM. The validation uses the same enrichment and SPDX gates
|
||||||
|
as a release. It does not publish, attest, or upload an artifact. A failure reports to the
|
||||||
|
Developer Platform Slack channel.
|
||||||
|
|
||||||
### SLSA L3 Provenance
|
### SLSA L3 Provenance
|
||||||
|
|
||||||
SLSA (Supply-chain Levels for Software Artifacts) Level 3 provides cryptographic proof of build integrity.
|
SLSA (Supply-chain Levels for Software Artifacts) Level 3 provides cryptographic proof of build integrity.
|
||||||
|
|
@ -994,11 +1141,28 @@ open the PR there. That PR **must stay a single-parent squash** — the publish
|
||||||
posts to `#alerts-build` when that gate fails on a PR opened *from* `bundle/2.x` or
|
posts to `#alerts-build` when that gate fails on a PR opened *from* `bundle/2.x` or
|
||||||
`bundle/1.x` (link only, no PR title, since the branch is embargoed).
|
`bundle/1.x` (link only, no PR title, since the branch is embargoed).
|
||||||
|
|
||||||
`sec-sync-bundle-branches.yml` keeps those branches current, daily plus whenever a PR is
|
`sec-sync-bundle-branches.yml` keeps those branches current nightly at 03:00 UTC and on
|
||||||
merged into one (and on `workflow_dispatch`). It **merges the base into** the bundle branch
|
`workflow_dispatch`, including before a bundle cut. It **merges the public base into** the
|
||||||
via [`scripts/sync-bundle-branch.mjs`](scripts/sync-bundle-branch.mjs) and pushes without
|
bundle branch via
|
||||||
forcing. Every push is verified to carry exactly the tree a merge of the two sides would
|
[`scripts/sync-bundle-branch.mjs`](scripts/sync-bundle-branch.mjs) and pushes without forcing.
|
||||||
produce (`git merge-tree`); a mismatch, or a conflict marker, fails the run instead of pushing.
|
Every push is verified to carry exactly the tree a merge of the two sides would produce (`git
|
||||||
|
merge-tree`); a mismatch, or a conflict marker, fails the run instead of pushing.
|
||||||
|
|
||||||
|
**A bundle branch is only ever built on published history.** The sync fetches `master` or `1.x`
|
||||||
|
directly from `https://github.com/n8n-io/n8n.git`. It creates a missing bundle branch at that
|
||||||
|
exact public SHA and merges that public SHA into an existing bundle branch. It never reads the
|
||||||
|
private base branch. This matters because the `chore: Bundle/*` squash on private `master` is
|
||||||
|
private-only until publication. The mirror can replace that commit with the public copy after
|
||||||
|
the bundle branch is deleted. The next bundle branch must not inherit the replaced commit.
|
||||||
|
|
||||||
|
Deleting a bundle branch takes its open PRs with it: GitHub moves each one onto the deleted
|
||||||
|
branch's own base, and re-creating the branch does not move them back. The next nightly or manual
|
||||||
|
sync re-creates the branch and then calls
|
||||||
|
[`sec-sync-retarget-prs.yml`](workflows/sec-sync-retarget-prs.yml), which moves every open PR
|
||||||
|
on `master` onto `bundle/2.x` and every one on `1.x` onto `bundle/1.x`. It skips a bundle
|
||||||
|
branch that does not exist, and skips PRs whose *head* is `bundle/*` — those are the
|
||||||
|
`chore: Bundle/*` cut PRs, which target the base on purpose. It is also dispatchable on its
|
||||||
|
own. The retarget runs inside the bundle sync after a missing branch is recreated.
|
||||||
|
|
||||||
**`bundle/*` is append-only — never rebase it, never force-push it.** These branches receive
|
**`bundle/*` is append-only — never rebase it, never force-push it.** These branches receive
|
||||||
PRs, and rewriting a branch that receives PRs orphans the copies of its commits that the open
|
PRs, and rewriting a branch that receives PRs orphans the copies of its commits that the open
|
||||||
|
|
@ -1011,21 +1175,19 @@ itself. To refresh a fix branch, use GitHub's **Update branch** button or
|
||||||
sibling PR's merge base untouched, which is why only a rewrite breaks this.
|
sibling PR's merge base untouched, which is why only a rewrite breaks this.
|
||||||
|
|
||||||
The costs of merging are deliberate and paid for: a merge commit per run, and fixes that have
|
The costs of merging are deliberate and paid for: a merge commit per run, and fixes that have
|
||||||
already been published staying in the branch's log (the old rebase dropped them as empty
|
already been published staying in the branch's log. Neither reaches anything downstream,
|
||||||
commits). Neither reaches anything downstream, because a bundle publishes as one squashed
|
because a bundle publishes as one squashed commit taken from the tree rather than the history —
|
||||||
commit taken from the tree rather than the history — the `chore: Bundle/*` PR's **diff** stays
|
the `chore: Bundle/*` PR's **diff** stays
|
||||||
exactly the pending fixes even when its commit list does not. For a list of what a bundle
|
exactly the pending fixes even when its commit list does not. For a list of what a bundle
|
||||||
actually carries, read the fix PRs merged into the branch since the last cut, not
|
actually carries, read the fix PRs merged into the branch since the last cut, not `base..bundle`.
|
||||||
`base..bundle`. A lower cadence than the base's is fine too: a base push never re-triggered
|
|
||||||
CI on the fix PRs, so syncing more often bought them nothing.
|
|
||||||
|
|
||||||
There is **one job per bundle branch**. A conflict is detected from the merge tree before the
|
There is **one job per bundle branch**. A conflict is detected from the merge tree before the
|
||||||
working tree is touched, so the branch is left exactly as it was, that job **fails** (no
|
working tree is touched, so the branch is left exactly as it was, that job **fails** (no
|
||||||
green runs hiding a stalled branch) and `#alerts-security` gets a run link — while the other
|
green runs hiding a stalled branch) and `#alerts-security` gets a run link — while the other
|
||||||
branch still syncs. Recovery is deliberate: merge the base into the branch locally, resolve,
|
branch still syncs. Recovery is deliberate: merge the public base into the branch locally,
|
||||||
push, then re-run the workflow — and that resolution then lives in the merge commit instead of
|
resolve, push, then re-run the workflow — and that resolution then lives in the merge commit
|
||||||
being re-litigated on every later run. The sync never resolves a conflict itself, unlike
|
instead of being re-litigated on every later run. The sync never resolves a conflict itself,
|
||||||
`util-sync-master-to-3x.yml`.
|
unlike `util-sync-master-to-3x.yml`.
|
||||||
|
|
||||||
See **[`../AGENTS.md`](../AGENTS.md)** ("Security Fix Hygiene") for the naming rules that
|
See **[`../AGENTS.md`](../AGENTS.md)** ("Security Fix Hygiene") for the naming rules that
|
||||||
keep the vulnerability out of public branch names, commits, and test descriptions.
|
keep the vulnerability out of public branch names, commits, and test descriptions.
|
||||||
|
|
@ -1095,12 +1257,6 @@ Adding a new channel requires inviting the bot first; the first run otherwise fa
|
||||||
|
|
||||||
## Future Vision
|
## Future Vision
|
||||||
|
|
||||||
### Redundancy Review
|
|
||||||
|
|
||||||
Comment trigger (`/test-workflows`) is a workaround.
|
|
||||||
|
|
||||||
Long-term: Main CI should be reliable enough to not need these.
|
|
||||||
|
|
||||||
### Workflow Testability
|
### Workflow Testability
|
||||||
|
|
||||||
- Tools like `act` for local testing
|
- Tools like `act` for local testing
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import {
|
||||||
getChangedFiles,
|
getChangedFiles,
|
||||||
getAddedFiles,
|
getAddedFiles,
|
||||||
getMergeBase,
|
getMergeBase,
|
||||||
|
resolveHeadRef,
|
||||||
} from '../ci-filter.mjs';
|
} from '../ci-filter.mjs';
|
||||||
|
|
||||||
// --- matchGlob ---
|
// --- matchGlob ---
|
||||||
|
|
@ -57,6 +58,15 @@ describe('matchGlob', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('backend module pattern matches packaged module files', () => {
|
||||||
|
assert.ok(
|
||||||
|
matchGlob(
|
||||||
|
'packages/modules/insights/backend/src/insights.service.ts',
|
||||||
|
'packages/modules/*/backend/**',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('* matches single-level only', () => {
|
it('* matches single-level only', () => {
|
||||||
assert.ok(matchGlob('README.md', '*.md'));
|
assert.ok(matchGlob('README.md', '*.md'));
|
||||||
assert.ok(!matchGlob('docs/README.md', '*.md'));
|
assert.ok(!matchGlob('docs/README.md', '*.md'));
|
||||||
|
|
@ -241,7 +251,7 @@ describe('runtime filter', () => {
|
||||||
'!**/CHANGELOG.md',
|
'!**/CHANGELOG.md',
|
||||||
'!**/*.test.ts',
|
'!**/*.test.ts',
|
||||||
'!**/*.spec.ts',
|
'!**/*.spec.ts',
|
||||||
'!packages/testing/playwright/**',
|
'!packages/quality/testing/playwright/**',
|
||||||
'!packages/frontend/@n8n/storybook/**',
|
'!packages/frontend/@n8n/storybook/**',
|
||||||
'!scripts/agent-setup.mjs',
|
'!scripts/agent-setup.mjs',
|
||||||
'!scripts/backend-module/**',
|
'!scripts/backend-module/**',
|
||||||
|
|
@ -264,7 +274,7 @@ describe('runtime filter', () => {
|
||||||
|
|
||||||
it('does not trigger on playwright tests', () => {
|
it('does not trigger on playwright tests', () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
evaluateFilter(['packages/testing/playwright/tests/x.spec.ts'], runtimePatterns),
|
evaluateFilter(['packages/quality/testing/playwright/tests/x.spec.ts'], runtimePatterns),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -395,6 +405,100 @@ describe('getChangedFiles', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// --- resolveHeadRef ---
|
||||||
|
|
||||||
|
describe('resolveHeadRef', () => {
|
||||||
|
it('diffs the PR head (second parent of the test merge) on pull request events', () => {
|
||||||
|
assert.equal(resolveHeadRef('pull_request'), 'HEAD^2');
|
||||||
|
assert.equal(resolveHeadRef('pull_request_review'), 'HEAD^2');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('diffs HEAD on every other event', () => {
|
||||||
|
assert.equal(resolveHeadRef('merge_group'), 'HEAD');
|
||||||
|
assert.equal(resolveHeadRef('workflow_dispatch'), 'HEAD');
|
||||||
|
assert.equal(resolveHeadRef(undefined), 'HEAD');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- getChangedFiles on a stacked PR's test-merge commit (shallow clone) ---
|
||||||
|
|
||||||
|
describe('getChangedFiles (stacked PR test merge)', () => {
|
||||||
|
const builderDir = mkdtempSync(join(tmpdir(), 'ci-filter-build-stack-'));
|
||||||
|
const remoteDir = mkdtempSync(join(tmpdir(), 'ci-filter-remote-stack-'));
|
||||||
|
const repoDir = mkdtempSync(join(tmpdir(), 'ci-filter-stack-'));
|
||||||
|
const originalCwd = process.cwd();
|
||||||
|
const originalStep = process.env.CI_FILTER_DEEPEN_STEP;
|
||||||
|
const git = (args: string[], cwd: string) =>
|
||||||
|
execFileSync('git', args, { cwd, stdio: 'pipe' }).toString().trim();
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
execFileSync('git', ['init', '--bare', '-b', 'main', remoteDir], { stdio: 'pipe' });
|
||||||
|
git(['init', '-b', 'main'], builderDir);
|
||||||
|
git(['config', 'user.email', 'test@test.local'], builderDir);
|
||||||
|
git(['config', 'user.name', 'test'], builderDir);
|
||||||
|
git(['remote', 'add', 'origin', remoteDir], builderDir);
|
||||||
|
|
||||||
|
writeFileSync(join(builderDir, 'shared.ts'), 'shared\n');
|
||||||
|
git(['add', '.'], builderDir);
|
||||||
|
git(['commit', '-m', 'root'], builderDir);
|
||||||
|
git(['push', 'origin', 'main'], builderDir);
|
||||||
|
|
||||||
|
// Bottom of the stack: parent PR branch off root
|
||||||
|
git(['checkout', '-b', 'parent-branch'], builderDir);
|
||||||
|
writeFileSync(join(builderDir, 'parent.ts'), 'parent\n');
|
||||||
|
git(['add', '.'], builderDir);
|
||||||
|
git(['commit', '-m', 'parent PR change'], builderDir);
|
||||||
|
git(['push', 'origin', 'parent-branch'], builderDir);
|
||||||
|
|
||||||
|
// Top of the stack: this PR branches off the parent PR
|
||||||
|
git(['checkout', '-b', 'pr-branch'], builderDir);
|
||||||
|
writeFileSync(join(builderDir, 'pr-only.ts'), 'pr\n');
|
||||||
|
git(['add', '.'], builderDir);
|
||||||
|
git(['commit', '-m', 'PR change'], builderDir);
|
||||||
|
|
||||||
|
// main drifts after the stack was created
|
||||||
|
git(['checkout', 'main'], builderDir);
|
||||||
|
writeFileSync(join(builderDir, 'shared.ts'), 'shared\ndrift\n');
|
||||||
|
git(['commit', '-am', 'main moves'], builderDir);
|
||||||
|
git(['push', 'origin', 'main'], builderDir);
|
||||||
|
|
||||||
|
// GitHub builds the parent PR's test merge against main, then builds
|
||||||
|
// this PR's test merge on top of it instead of on parent-branch.
|
||||||
|
git(['checkout', '--detach', 'main'], builderDir);
|
||||||
|
git(['merge', '--no-ff', '-m', 'Merge parent-branch into main', 'parent-branch'], builderDir);
|
||||||
|
git(['merge', '--no-ff', '-m', 'Merge pr-branch into parent merge', 'pr-branch'], builderDir);
|
||||||
|
git(['push', 'origin', 'HEAD:refs/pull/1/merge'], builderDir);
|
||||||
|
|
||||||
|
// Mirror actions/checkout: depth-1 fetch of the test-merge ref
|
||||||
|
git(['init'], repoDir);
|
||||||
|
git(['remote', 'add', 'origin', `file://${remoteDir}`], repoDir);
|
||||||
|
git(['fetch', '--depth=1', 'origin', '+refs/pull/1/merge:refs/remotes/pull/1/merge'], repoDir);
|
||||||
|
git(['checkout', '--force', 'refs/remotes/pull/1/merge'], repoDir);
|
||||||
|
process.env.CI_FILTER_DEEPEN_STEP = '1';
|
||||||
|
process.chdir(repoDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
process.chdir(originalCwd);
|
||||||
|
if (originalStep === undefined) delete process.env.CI_FILTER_DEEPEN_STEP;
|
||||||
|
else process.env.CI_FILTER_DEEPEN_STEP = originalStep;
|
||||||
|
rmSync(builderDir, { recursive: true, force: true });
|
||||||
|
rmSync(remoteDir, { recursive: true, force: true });
|
||||||
|
rmSync(repoDir, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('diffing HEAD reports the base-branch drift carried by the parent test merge', () => {
|
||||||
|
assert.equal(git(['rev-parse', '--is-shallow-repository'], repoDir), 'true');
|
||||||
|
assert.deepEqual(getChangedFiles('parent-branch', 'HEAD').sort(), ['pr-only.ts', 'shared.ts']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('diffing HEAD^2 reports only the files this PR changes', () => {
|
||||||
|
assert.deepEqual(getChangedFiles('parent-branch', 'HEAD^2'), ['pr-only.ts']);
|
||||||
|
assert.deepEqual(getAddedFiles('parent-branch', 'HEAD^2'), ['pr-only.ts']);
|
||||||
|
assert.equal(getMergeBase('HEAD^2'), git(['rev-parse', 'origin/parent-branch'], repoDir));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// --- getChangedFiles deep merge-base (shallow clone, stale base) ---
|
// --- getChangedFiles deep merge-base (shallow clone, stale base) ---
|
||||||
|
|
||||||
describe('getChangedFiles (shallow clone, stale base)', () => {
|
describe('getChangedFiles (shallow clone, stale base)', () => {
|
||||||
|
|
|
||||||
2
.github/actions/ci-filter/action.yml
vendored
2
.github/actions/ci-filter/action.yml
vendored
|
|
@ -34,7 +34,7 @@ outputs:
|
||||||
description: 'Resolved base ref used for the diff (filter mode only)'
|
description: 'Resolved base ref used for the diff (filter mode only)'
|
||||||
value: ${{ steps.run.outputs.base-ref }}
|
value: ${{ steps.run.outputs.base-ref }}
|
||||||
merge-base:
|
merge-base:
|
||||||
description: 'Merge-base SHA between FETCH_HEAD and HEAD (filter mode only)'
|
description: 'Merge-base SHA between the base ref and the PR head (filter mode only)'
|
||||||
value: ${{ steps.run.outputs.merge-base }}
|
value: ${{ steps.run.outputs.merge-base }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
|
|
|
||||||
74
.github/actions/ci-filter/ci-filter.mjs
vendored
74
.github/actions/ci-filter/ci-filter.mjs
vendored
|
|
@ -95,7 +95,19 @@ export function parseFilters(input) {
|
||||||
|
|
||||||
const SAFE_REF = /^[a-zA-Z0-9_./-]+$/;
|
const SAFE_REF = /^[a-zA-Z0-9_./-]+$/;
|
||||||
|
|
||||||
export function getChangedFiles(baseRef) {
|
/**
|
||||||
|
* Ref to diff against the base branch.
|
||||||
|
*
|
||||||
|
* On pull_request events checkout lands on GitHub's test-merge commit. For a
|
||||||
|
* stacked PR its first parent is the parent PR's test merge, which already
|
||||||
|
* carries every base-branch commit the stack lacks, so a diff against HEAD
|
||||||
|
* reports that drift as changed. The second parent is the PR head itself.
|
||||||
|
*/
|
||||||
|
export function resolveHeadRef(eventName = process.env.GITHUB_EVENT_NAME) {
|
||||||
|
return eventName === 'pull_request' || eventName === 'pull_request_review' ? 'HEAD^2' : 'HEAD';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getChangedFiles(baseRef, headRef = 'HEAD') {
|
||||||
if (!SAFE_REF.test(baseRef)) {
|
if (!SAFE_REF.test(baseRef)) {
|
||||||
throw new Error(`Unsafe base ref: "${baseRef}"`);
|
throw new Error(`Unsafe base ref: "${baseRef}"`);
|
||||||
}
|
}
|
||||||
|
|
@ -104,8 +116,8 @@ export function getChangedFiles(baseRef) {
|
||||||
// direction, so files added to base-branch after the PR diverged show up as
|
// direction, so files added to base-branch after the PR diverged show up as
|
||||||
// "changed" — spuriously triggering path-filtered jobs. The merge base
|
// "changed" — spuriously triggering path-filtered jobs. The merge base
|
||||||
// scopes the diff to PR-only changes.
|
// scopes the diff to PR-only changes.
|
||||||
fetchUntilMergeBase(baseRef);
|
fetchUntilMergeBase(baseRef, headRef);
|
||||||
const output = execSync('git diff --name-only --no-renames --merge-base FETCH_HEAD HEAD', {
|
const output = execSync(`git diff --name-only --no-renames --merge-base FETCH_HEAD ${headRef}`, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
return output
|
return output
|
||||||
|
|
@ -116,12 +128,12 @@ export function getChangedFiles(baseRef) {
|
||||||
|
|
||||||
// Files added (not merely modified) in this PR. Same merge-base scoping as
|
// Files added (not merely modified) in this PR. Same merge-base scoping as
|
||||||
// getChangedFiles; assumes the fetch it performs has already run.
|
// getChangedFiles; assumes the fetch it performs has already run.
|
||||||
export function getAddedFiles(baseRef) {
|
export function getAddedFiles(baseRef, headRef = 'HEAD') {
|
||||||
if (!SAFE_REF.test(baseRef)) {
|
if (!SAFE_REF.test(baseRef)) {
|
||||||
throw new Error(`Unsafe base ref: "${baseRef}"`);
|
throw new Error(`Unsafe base ref: "${baseRef}"`);
|
||||||
}
|
}
|
||||||
const output = execSync(
|
const output = execSync(
|
||||||
'git diff --name-only --no-renames --diff-filter=A --merge-base FETCH_HEAD HEAD',
|
`git diff --name-only --no-renames --diff-filter=A --merge-base FETCH_HEAD ${headRef}`,
|
||||||
{ encoding: 'utf-8' },
|
{ encoding: 'utf-8' },
|
||||||
);
|
);
|
||||||
return output
|
return output
|
||||||
|
|
@ -131,8 +143,8 @@ export function getAddedFiles(baseRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deepen the shallow clone until the merge base between the fetched base ref
|
* Fetch the base ref, then deepen only if its merge base with headRef is not
|
||||||
* (FETCH_HEAD) and HEAD is reliably reachable.
|
* reliably reachable from the checkout.
|
||||||
*
|
*
|
||||||
* A single fixed deepen is not enough for stale PRs whose divergence point is
|
* A single fixed deepen is not enough for stale PRs whose divergence point is
|
||||||
* older than the shallow boundary. We fetch with an exponentially growing
|
* older than the shallow boundary. We fetch with an exponentially growing
|
||||||
|
|
@ -144,19 +156,33 @@ export function getAddedFiles(baseRef) {
|
||||||
* git's signed int32 `--deepen` limit), switch to `--unshallow` instead of
|
* git's signed int32 `--deepen` limit), switch to `--unshallow` instead of
|
||||||
* passing an ever-larger integer that git would reject.
|
* passing an ever-larger integer that git would reject.
|
||||||
*/
|
*/
|
||||||
function fetchUntilMergeBase(baseRef) {
|
function fetchUntilMergeBase(baseRef, headRef) {
|
||||||
let step = Number(process.env.CI_FILTER_DEEPEN_STEP) || 200;
|
let step = Number(process.env.CI_FILTER_DEEPEN_STEP) || 200;
|
||||||
const maxDeepen = Number(process.env.CI_FILTER_MAX_DEEPEN) || 20_000;
|
const maxDeepen = Number(process.env.CI_FILTER_MAX_DEEPEN) || 20_000;
|
||||||
deepenFetch(baseRef, step, maxDeepen);
|
// A PR merge checkout already has the base commit as its first parent.
|
||||||
|
const hasBaseCommit = headRef === 'HEAD^2' && hasCommit('HEAD^1');
|
||||||
|
const depth = isShallow() && !hasBaseCommit ? `--depth=${step} ` : '';
|
||||||
|
execSync(`git fetch --no-tags --prune --filter=blob:none ${depth}origin ${baseRef}`, {
|
||||||
|
stdio: 'pipe',
|
||||||
|
});
|
||||||
|
|
||||||
while (!hasReliableMergeBase()) {
|
while (!hasReliableMergeBase(headRef)) {
|
||||||
if (!isShallow()) {
|
if (!isShallow()) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No merge base between FETCH_HEAD and HEAD after fetching the full history of "${baseRef}" (unrelated histories).`,
|
`No merge base between FETCH_HEAD and ${headRef} after fetching the full history of "${baseRef}" (unrelated histories).`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
step *= 2;
|
|
||||||
deepenFetch(baseRef, step, maxDeepen);
|
deepenFetch(baseRef, step, maxDeepen);
|
||||||
|
step *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasCommit(ref) {
|
||||||
|
try {
|
||||||
|
execSync(`git cat-file -e ${ref}^{commit}`, { stdio: 'pipe' });
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,9 +194,7 @@ function deepenFetch(baseRef, step, maxDeepen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isShallow() {
|
function isShallow() {
|
||||||
return (
|
return execSync('git rev-parse --is-shallow-repository', { encoding: 'utf-8' }).trim() === 'true';
|
||||||
execSync('git rev-parse --is-shallow-repository', { encoding: 'utf-8' }).trim() === 'true'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -179,12 +203,12 @@ function isShallow() {
|
||||||
* sub-history is truncated; that result is unreliable, so we must deepen further
|
* sub-history is truncated; that result is unreliable, so we must deepen further
|
||||||
* before trusting it.
|
* before trusting it.
|
||||||
*/
|
*/
|
||||||
function hasReliableMergeBase() {
|
function hasReliableMergeBase(headRef) {
|
||||||
let base;
|
let base;
|
||||||
try {
|
try {
|
||||||
base = execSync('git merge-base FETCH_HEAD HEAD', { encoding: 'utf-8' }).trim();
|
base = execSync(`git merge-base FETCH_HEAD ${headRef}`, { encoding: 'utf-8' }).trim();
|
||||||
} catch {
|
} catch {
|
||||||
return false; // no common ancestor reachable yet
|
return false; // no common ancestor reachable yet, or headRef still hidden by the shallow graft
|
||||||
}
|
}
|
||||||
if (!base) return false;
|
if (!base) return false;
|
||||||
return !readShallowBoundaries().has(base);
|
return !readShallowBoundaries().has(base);
|
||||||
|
|
@ -208,12 +232,12 @@ function readShallowBoundaries() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the merge-base SHA between FETCH_HEAD and HEAD.
|
* Resolve the merge-base SHA between FETCH_HEAD and headRef.
|
||||||
* Used to give downstream tools (e.g. janitor's AST diff) a stable, PR-only
|
* Used to give downstream tools (e.g. janitor's AST diff) a stable, PR-only
|
||||||
* comparison point that doesn't drift when the base branch moves forward.
|
* comparison point that doesn't drift when the base branch moves forward.
|
||||||
*/
|
*/
|
||||||
export function getMergeBase() {
|
export function getMergeBase(headRef = 'HEAD') {
|
||||||
return execSync('git merge-base FETCH_HEAD HEAD', { encoding: 'utf-8' }).trim();
|
return execSync(`git merge-base FETCH_HEAD ${headRef}`, { encoding: 'utf-8' }).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Filter evaluation ---
|
// --- Filter evaluation ---
|
||||||
|
|
@ -290,10 +314,12 @@ export function runFilter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const filters = parseFilters(filtersInput);
|
const filters = parseFilters(filtersInput);
|
||||||
const changedFiles = getChangedFiles(baseRef);
|
const headRef = resolveHeadRef();
|
||||||
const addedFiles = getAddedFiles(baseRef);
|
const changedFiles = getChangedFiles(baseRef, headRef);
|
||||||
const mergeBase = getMergeBase();
|
const addedFiles = getAddedFiles(baseRef, headRef);
|
||||||
|
const mergeBase = getMergeBase(headRef);
|
||||||
|
|
||||||
|
console.log(`Diffing ${headRef} against ${baseRef}`);
|
||||||
console.log(`Merge base: ${mergeBase}`);
|
console.log(`Merge base: ${mergeBase}`);
|
||||||
console.log(`Changed files (${changedFiles.length}):`);
|
console.log(`Changed files (${changedFiles.length}):`);
|
||||||
for (const f of changedFiles) {
|
for (const f of changedFiles) {
|
||||||
|
|
|
||||||
42
.github/actions/run-workflow-script/action.yml
vendored
Normal file
42
.github/actions/run-workflow-script/action.yml
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# Runs one `.github/scripts` module without a Node.js setup or a dependency
|
||||||
|
# install. actions/github-script brings its own Node.js and Octokit client;
|
||||||
|
# the module receives that client through `setOctokit` in github-helpers.mjs.
|
||||||
|
#
|
||||||
|
# The module must export an async `main()` function and must import only
|
||||||
|
# node builtins and other `.github/scripts` modules. A module that needs an
|
||||||
|
# npm package (semver, yaml, ...) keeps using `setup-nodejs` with an
|
||||||
|
# install command instead.
|
||||||
|
name: 'Run workflow script'
|
||||||
|
description: 'Runs a .github/scripts module through actions/github-script, without a Node.js setup or dependency install.'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
script:
|
||||||
|
description: 'Path of the module, relative to the repository root. It must export an async main() function.'
|
||||||
|
required: true
|
||||||
|
github-token:
|
||||||
|
description: 'Token for the Octokit client. Also exported as GITHUB_TOKEN for the module.'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Run workflow script
|
||||||
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||||
|
env:
|
||||||
|
SCRIPT: ${{ inputs.script }}
|
||||||
|
GITHUB_TOKEN: ${{ inputs.github-token }}
|
||||||
|
with:
|
||||||
|
github-token: ${{ inputs.github-token }}
|
||||||
|
script: |
|
||||||
|
const path = require('node:path');
|
||||||
|
const { pathToFileURL } = require('node:url');
|
||||||
|
const load = (file) => import(pathToFileURL(path.join(process.env.GITHUB_WORKSPACE, file)).href);
|
||||||
|
|
||||||
|
const { setOctokit } = await load('.github/scripts/github-helpers.mjs');
|
||||||
|
setOctokit(github);
|
||||||
|
|
||||||
|
const { main } = await load(process.env.SCRIPT);
|
||||||
|
if (typeof main !== 'function') {
|
||||||
|
throw new Error(`${process.env.SCRIPT} does not export main()`);
|
||||||
|
}
|
||||||
|
await main();
|
||||||
8
.github/actions/setup-nodejs/action.yml
vendored
8
.github/actions/setup-nodejs/action.yml
vendored
|
|
@ -171,7 +171,7 @@ runs:
|
||||||
|
|
||||||
- name: Restore pnpm metadata cache
|
- name: Restore pnpm metadata cache
|
||||||
if: ${{ inputs.install-command != '' }}
|
if: ${{ inputs.install-command != '' }}
|
||||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.pnpm-metadata-cache.outputs.path }}
|
path: ${{ steps.pnpm-metadata-cache.outputs.path }}
|
||||||
key: pnpm-metadata-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.pnpm-metadata-cache.outputs.version }}-${{ hashFiles(inputs.cache-dependency-path) }}
|
key: pnpm-metadata-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.pnpm-metadata-cache.outputs.version }}-${{ hashFiles(inputs.cache-dependency-path) }}
|
||||||
|
|
@ -194,7 +194,7 @@ runs:
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||||
with:
|
with:
|
||||||
path: ~/.safe-chain/bin
|
path: ~/.safe-chain/bin
|
||||||
key: safe-chain-1.5.7-${{ runner.os }}-${{ runner.arch }}
|
key: safe-chain-1.5.20-${{ runner.os }}-${{ runner.arch }}
|
||||||
|
|
||||||
# Download + install the SafeChain binary. This is the expensive,
|
# Download + install the SafeChain binary. This is the expensive,
|
||||||
# CDN-backed part and the only part worth gating on the cache. The install
|
# CDN-backed part and the only part worth gating on the cache. The install
|
||||||
|
|
@ -203,8 +203,8 @@ runs:
|
||||||
- name: Download Aikido SafeChain
|
- name: Download Aikido SafeChain
|
||||||
if: steps.cache-safe-chain.outputs.cache-hit != 'true'
|
if: steps.cache-safe-chain.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
VERSION="1.5.7"
|
VERSION="1.5.20"
|
||||||
EXPECTED_SHA256="07ab512fd8795ce41b2275be369aced4c9a93cc7bca9b397951507891a955239"
|
EXPECTED_SHA256="0ad25efe15d1fa56105157a454d647223e78eb0c53d1f85e3d10afcd722e7bfd"
|
||||||
node .github/scripts/retry.mjs --attempts 3 --delay 10 -- \
|
node .github/scripts/retry.mjs --attempts 3 --delay 10 -- \
|
||||||
curl -fsSL -o install-safe-chain.sh "https://github.com/AikidoSec/safe-chain/releases/download/${VERSION}/install-safe-chain.sh"
|
curl -fsSL -o install-safe-chain.sh "https://github.com/AikidoSec/safe-chain/releases/download/${VERSION}/install-safe-chain.sh"
|
||||||
echo "${EXPECTED_SHA256} install-safe-chain.sh" | sha256sum -c -
|
echo "${EXPECTED_SHA256} install-safe-chain.sh" | sha256sum -c -
|
||||||
|
|
|
||||||
2
.github/docker-compose.yml
vendored
2
.github/docker-compose.yml
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: ${TEST_IMAGE_POSTGRES:?set it from packages/testing/containers/postgres-versions.json}
|
image: ${TEST_IMAGE_POSTGRES:?set it from packages/quality/environments/containers/postgres-versions.json}
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_DB=n8n
|
- POSTGRES_DB=n8n
|
||||||
|
|
|
||||||
11
.github/pull_request_template.md
vendored
11
.github/pull_request_template.md
vendored
|
|
@ -1,8 +1,15 @@
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Describe what the PR does.
|
Start with 1 to 3 sentences of background for a new reader. Then describe what the PR does, in prose, not as a list of edits.
|
||||||
Photos and videos are recommended.
|
Add photos or videos for UI changes.
|
||||||
|
-->
|
||||||
|
|
||||||
|
## Why
|
||||||
|
|
||||||
|
<!--
|
||||||
|
State the problem or the constraint that makes the current code unfit. Do not repeat the Summary.
|
||||||
|
Add a rejected alternative only when a reviewer would ask about it, in one or two sentences.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## How to test
|
## How to test
|
||||||
|
|
|
||||||
73
.github/scripts/attest-image-sbom.mjs
vendored
73
.github/scripts/attest-image-sbom.mjs
vendored
|
|
@ -8,7 +8,8 @@
|
||||||
* Image refs + digests come from the environment (set by docker-build-push.yml).
|
* Image refs + digests come from the environment (set by docker-build-push.yml).
|
||||||
* An image with no digest (not built for this release type) is skipped.
|
* An image with no digest (not built for this release type) is skipped.
|
||||||
*
|
*
|
||||||
* Usage: node .github/scripts/attest-image-sbom.mjs (run from the repo root)
|
* Usage: node .github/scripts/attest-image-sbom.mjs [--validate-only]
|
||||||
|
* (run from the repo root)
|
||||||
*/
|
*/
|
||||||
import { execFileSync } from 'node:child_process';
|
import { execFileSync } from 'node:child_process';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
|
|
@ -62,7 +63,10 @@ export function assertSbomIsUsable(sbomPath, label) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function attest({ label, image, digest }) {
|
export function processTarget(
|
||||||
|
{ label, image, digest },
|
||||||
|
{ shouldAttest = true, runCommand = run, assertUsable = assertSbomIsUsable } = {},
|
||||||
|
) {
|
||||||
const ref = `${image}@${digest}`;
|
const ref = `${image}@${digest}`;
|
||||||
const out = path.join(REPO_ROOT, `sbom-${label}.cdx.json`);
|
const out = path.join(REPO_ROOT, `sbom-${label}.cdx.json`);
|
||||||
console.log(`::group::SBOM for ${label} (${ref})`);
|
console.log(`::group::SBOM for ${label} (${ref})`);
|
||||||
|
|
@ -71,14 +75,14 @@ function attest({ label, image, digest }) {
|
||||||
// names the failing image renders inside a collapsed section.
|
// names the failing image renders inside a collapsed section.
|
||||||
try {
|
try {
|
||||||
// Pull the (host-arch) image and scan its filesystem: OS packages + npm.
|
// Pull the (host-arch) image and scan its filesystem: OS packages + npm.
|
||||||
run('docker', ['pull', ref]);
|
runCommand('docker', ['pull', ref]);
|
||||||
// `docker:` pins the scan to the image just pulled. A bare ref lets syft's
|
// `docker:` pins the scan to the image just pulled. A bare ref lets syft's
|
||||||
// own provider order decide, and it may resolve the multi-arch index from
|
// own provider order decide, and it may resolve the multi-arch index from
|
||||||
// the registry instead — describing a different manifest than the one
|
// the registry instead — describing a different manifest than the one
|
||||||
// cosign then attests to.
|
// cosign then attests to.
|
||||||
// syft reads licenses from the LICENSE files on disk, so this scan makes no
|
// syft reads licenses from the LICENSE files on disk, so this scan makes no
|
||||||
// registry requests. `-file` excludes its per-file catalogue, ~4000 entries.
|
// registry requests. `-file` excludes its per-file catalogue, ~4000 entries.
|
||||||
run('syft', [
|
runCommand('syft', [
|
||||||
`docker:${ref}`,
|
`docker:${ref}`,
|
||||||
'-o',
|
'-o',
|
||||||
`cyclonedx-json@1.6=${out}`,
|
`cyclonedx-json@1.6=${out}`,
|
||||||
|
|
@ -90,52 +94,67 @@ function attest({ label, image, digest }) {
|
||||||
// Resolve first-party + override licenses (lenient: this image holds only a
|
// Resolve first-party + override licenses (lenient: this image holds only a
|
||||||
// subset of the npm closure, so absent overrides are not stale pins) and drop
|
// subset of the npm closure, so absent overrides are not stale pins) and drop
|
||||||
// scanner filesystem phantoms.
|
// scanner filesystem phantoms.
|
||||||
run(process.execPath, [ENRICH, out, '--lenient-config', '--drop-phantom-npm']);
|
runCommand(process.execPath, [ENRICH, out, '--lenient-config', '--drop-phantom-npm']);
|
||||||
|
|
||||||
// Release-blocking gate, scoped to npm — OS packages carry upstream-distro
|
// Release-blocking gate, scoped to npm — OS packages carry upstream-distro
|
||||||
// license strings we don't control, so they're inventoried but not gated.
|
// license strings we don't control, so they're inventoried but not gated.
|
||||||
run(process.execPath, [CHECK, out, ...ALLOW_REFS, '--enforce-prefix=pkg:npm/']);
|
runCommand(process.execPath, [CHECK, out, ...ALLOW_REFS, '--enforce-prefix=pkg:npm/']);
|
||||||
assertSbomIsUsable(out, label);
|
assertUsable(out, label);
|
||||||
|
|
||||||
// --replace, so re-running after a mid-loop failure does not leave the
|
// --replace, so re-running after a mid-loop failure does not leave the
|
||||||
// digest carrying two CycloneDX attestations.
|
// digest carrying two CycloneDX attestations.
|
||||||
run('cosign', [
|
if (shouldAttest) {
|
||||||
'attest',
|
runCommand('cosign', [
|
||||||
'--yes',
|
'attest',
|
||||||
'--replace',
|
'--yes',
|
||||||
'--type',
|
'--replace',
|
||||||
'cyclonedx',
|
'--type',
|
||||||
'--predicate',
|
'cyclonedx',
|
||||||
out,
|
'--predicate',
|
||||||
ref,
|
out,
|
||||||
]);
|
ref,
|
||||||
|
]);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
console.log('::endgroup::');
|
console.log('::endgroup::');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
export function processTargets(targets, options = {}) {
|
||||||
const targets = parseTargets(process.env);
|
const action = options.shouldAttest === false ? 'validation' : 'attestation';
|
||||||
if (targets.length === 0) {
|
const process = options.processTarget ?? processTarget;
|
||||||
console.log('No images with digests to attest — skipping.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Attempt every image, then report. Aborting on the first failure leaves the
|
// Attempt every image, then report. Aborting on the first failure leaves the
|
||||||
// later images silently unattested and hides whether they would have passed.
|
// later images silently unvalidated and hides whether they would have passed.
|
||||||
const failed = [];
|
const failed = [];
|
||||||
for (const target of targets) {
|
for (const target of targets) {
|
||||||
try {
|
try {
|
||||||
attest(target);
|
process(target, options);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failed.push(`${target.label}: ${err.message}`);
|
failed.push(`${target.label}: ${err.message}`);
|
||||||
console.log(`::error title=SBOM attestation::${target.label}: ${err.message}`);
|
console.log(`::error title=SBOM ${action}::${target.label}: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failed.length > 0) {
|
if (failed.length > 0) {
|
||||||
throw new Error(`${failed.length} of ${targets.length} image(s) failed:\n ${failed.join('\n ')}`);
|
throw new Error(
|
||||||
|
`${failed.length} of ${targets.length} image(s) failed:\n ${failed.join('\n ')}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function main({
|
||||||
|
env = process.env,
|
||||||
|
args = process.argv.slice(2),
|
||||||
|
processAll = processTargets,
|
||||||
|
} = {}) {
|
||||||
|
const shouldAttest = !args.includes('--validate-only');
|
||||||
|
const targets = parseTargets(env);
|
||||||
|
if (targets.length === 0) {
|
||||||
|
console.log(`No images with digests to ${shouldAttest ? 'attest' : 'validate'} - skipping.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
processAll(targets, { shouldAttest });
|
||||||
|
}
|
||||||
|
|
||||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||||
try {
|
try {
|
||||||
main();
|
main();
|
||||||
|
|
|
||||||
94
.github/scripts/attest-image-sbom.test.mjs
vendored
94
.github/scripts/attest-image-sbom.test.mjs
vendored
|
|
@ -3,7 +3,13 @@ import assert from 'node:assert/strict';
|
||||||
import { mkdtempSync, writeFileSync } from 'node:fs';
|
import { mkdtempSync, writeFileSync } from 'node:fs';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { assertSbomIsUsable, parseTargets } from './attest-image-sbom.mjs';
|
import {
|
||||||
|
assertSbomIsUsable,
|
||||||
|
main,
|
||||||
|
parseTargets,
|
||||||
|
processTarget,
|
||||||
|
processTargets,
|
||||||
|
} from './attest-image-sbom.mjs';
|
||||||
|
|
||||||
describe('parseTargets', () => {
|
describe('parseTargets', () => {
|
||||||
it('builds a target per image when both ref and digest are present', () => {
|
it('builds a target per image when both ref and digest are present', () => {
|
||||||
|
|
@ -82,3 +88,89 @@ describe('assertSbomIsUsable', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('processTarget', () => {
|
||||||
|
const target = {
|
||||||
|
label: 'n8n-pc',
|
||||||
|
image: 'ghcr.io/n8n-io/n8n',
|
||||||
|
digest: 'sha256:aaa',
|
||||||
|
};
|
||||||
|
|
||||||
|
it('runs the complete validation chain without attesting in validation-only mode', () => {
|
||||||
|
const calls = [];
|
||||||
|
let asserted = false;
|
||||||
|
processTarget(target, {
|
||||||
|
shouldAttest: false,
|
||||||
|
runCommand: (command, args) => calls.push([command, args]),
|
||||||
|
assertUsable: (_sbomPath, label) => {
|
||||||
|
assert.equal(label, 'n8n-pc');
|
||||||
|
asserted = true;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
calls.map(([command]) => path.basename(command)),
|
||||||
|
['docker', 'syft', 'node', 'node'],
|
||||||
|
);
|
||||||
|
assert.equal(calls[0][1][0], 'pull');
|
||||||
|
assert.equal(calls[1][1][0], 'docker:ghcr.io/n8n-io/n8n@sha256:aaa');
|
||||||
|
assert.ok(calls[2][1].includes('--drop-phantom-npm'));
|
||||||
|
assert.ok(calls[3][1].includes('--enforce-prefix=pkg:npm/'));
|
||||||
|
assert.equal(asserted, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('attests after validation by default', () => {
|
||||||
|
const calls = [];
|
||||||
|
processTarget(target, {
|
||||||
|
runCommand: (command, args) => calls.push([command, args]),
|
||||||
|
assertUsable: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(calls.at(-1)[0], 'cosign');
|
||||||
|
assert.deepEqual(calls.at(-1)[1].slice(0, 6), [
|
||||||
|
'attest',
|
||||||
|
'--yes',
|
||||||
|
'--replace',
|
||||||
|
'--type',
|
||||||
|
'cyclonedx',
|
||||||
|
'--predicate',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('processTargets', () => {
|
||||||
|
it('validates every image before reporting aggregated failures', () => {
|
||||||
|
const attempted = [];
|
||||||
|
assert.throws(
|
||||||
|
() =>
|
||||||
|
processTargets([{ label: 'n8n' }, { label: 'n8n-pc' }, { label: 'runners' }], {
|
||||||
|
shouldAttest: false,
|
||||||
|
processTarget: (target) => {
|
||||||
|
attempted.push(target.label);
|
||||||
|
if (target.label !== 'n8n-pc') throw new Error('missing license');
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
/2 of 3 image\(s\) failed/,
|
||||||
|
);
|
||||||
|
assert.deepEqual(attempted, ['n8n', 'n8n-pc', 'runners']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('main', () => {
|
||||||
|
it('passes validation-only mode to image processing', () => {
|
||||||
|
let received;
|
||||||
|
main({
|
||||||
|
env: {
|
||||||
|
N8N_IMAGE: 'ghcr.io/n8n-io/n8n',
|
||||||
|
N8N_DIGEST: 'sha256:aaa',
|
||||||
|
},
|
||||||
|
args: ['--validate-only'],
|
||||||
|
processAll: (targets, options) => {
|
||||||
|
received = { targets, options };
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(received.targets[0].label, 'n8n');
|
||||||
|
assert.equal(received.options.shouldAttest, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
372
.github/scripts/codespace-preview.mjs
vendored
372
.github/scripts/codespace-preview.mjs
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
// Drives a PR preview instance from CI. `scripts/preview.mjs` does the work; this
|
// Drives a PR preview instance from CI. `scripts/codespace-preview/preview.mjs` does the work; this
|
||||||
// script maps the pull_request event onto one of its operations and reports the
|
// script maps the pull_request event onto one of its operations and reports the
|
||||||
// result back to the PR as a single, edited-in-place comment.
|
// result back to the PR as a single, edited-in-place comment.
|
||||||
//
|
//
|
||||||
|
|
@ -8,23 +8,51 @@
|
||||||
// unlabeled -> down delete the box
|
// unlabeled -> down delete the box
|
||||||
// closed -> down
|
// closed -> down
|
||||||
//
|
//
|
||||||
|
// A manual run sets PREVIEW_OPERATION instead, which wins over the event mapping.
|
||||||
|
//
|
||||||
// `refresh` never creates a box. A box that GitHub already deleted (24 h
|
// `refresh` never creates a box. A box that GitHub already deleted (24 h
|
||||||
// retention) is reported as expired, not as a failure.
|
// retention) is reported as expired, not as a failure.
|
||||||
import { spawnSync } from 'node:child_process';
|
//
|
||||||
|
// `up` and `refresh` take minutes, so the comment goes up before the work starts
|
||||||
|
// and is edited for each phase and once a minute after that. `preview.mjs --json`
|
||||||
|
// prints one JSON line per phase on the channel this already parses; the report is
|
||||||
|
// the line that carries a `url`.
|
||||||
|
//
|
||||||
|
// With `--report-cancelled` it posts one body and nothing else. The workflow runs
|
||||||
|
// that on a cancelled or timed-out job, which kills this process mid-checklist.
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
import { PREVIEW_LABEL_PREFIX } from '../../scripts/preview-labels.mjs';
|
import { PREVIEW_LABEL_PREFIX } from '../../scripts/codespace-preview/preview-labels.mjs';
|
||||||
import { ensureEnvVar, postOrUpdateComment } from './github-helpers.mjs';
|
import { PREVIEW_PHASES, createLineSplitter, phaseIndex } from '../../scripts/codespace-preview/preview-phases.mjs';
|
||||||
|
import {
|
||||||
|
ensureEnvVar,
|
||||||
|
findCommentByMarker,
|
||||||
|
postOrUpdateComment,
|
||||||
|
updateCommentById,
|
||||||
|
} from './github-helpers.mjs';
|
||||||
|
|
||||||
export const BOT_MARKER = '<!-- codespace-preview -->';
|
export const BOT_MARKER = '<!-- codespace-preview -->';
|
||||||
|
// Only a progress body carries this. The cancelled-run step checks for it before it
|
||||||
|
// writes, so a run cancelled while it was still queued cannot replace a good ready
|
||||||
|
// comment left by the run before it.
|
||||||
|
export const PROGRESS_MARKER = '<!-- codespace-preview:progress -->';
|
||||||
export const PREVIEW_LABEL = 'codespace-preview';
|
export const PREVIEW_LABEL = 'codespace-preview';
|
||||||
// Copied from `preview.mjs`, which owns them. They cannot be imported: that module
|
// Copied from `preview.mjs`, which owns them, so they move together. They cannot be
|
||||||
// runs its command switch on import. They appear in the comment so a reviewer knows
|
// imported: that module runs its command switch on import. They appear in the comment
|
||||||
// how long the instance lasts without reading the script.
|
// so a reviewer knows how long the instance lasts without reading the script.
|
||||||
const IDLE_TIMEOUT = '30 minutes';
|
const IDLE_TIMEOUT = '2 hours';
|
||||||
const RETENTION_PERIOD = '24 hours';
|
const RETENTION_PERIOD = '24 hours';
|
||||||
|
const CODESPACE_ENV_VARIABLE_URL = "https://internal.users.n8n.cloud/form/codespace-environments";
|
||||||
|
// A slept box comes back with a private port, so every recovery hint points here.
|
||||||
|
export const WORKFLOW_URL =
|
||||||
|
'https://github.com/n8n-io/n8n/actions/workflows/util-codespace-preview.yml';
|
||||||
|
// What a manual run may ask for. `ls` is absent: it needs no PR and posts no comment.
|
||||||
|
export const DISPATCH_OPERATIONS = ['up', 'refresh', 'down'];
|
||||||
// Resolved against this file, so the script runs the same from any directory.
|
// Resolved against this file, so the script runs the same from any directory.
|
||||||
const PREVIEW_SCRIPT = fileURLToPath(new URL('../../scripts/preview.mjs', import.meta.url));
|
const PREVIEW_SCRIPT = fileURLToPath(new URL('../../scripts/codespace-preview/preview.mjs', import.meta.url));
|
||||||
|
// Often enough to look alive, rarely enough that the edit history stays readable.
|
||||||
|
const HEARTBEAT_MS = 60_000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A `preview:*` label configures an instance that already exists, so toggling one
|
* A `preview:*` label configures an instance that already exists, so toggling one
|
||||||
|
|
@ -50,6 +78,19 @@ export function operationFor(action, label) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A manual run says what to do, so its operation wins over the event mapping. An
|
||||||
|
* operation that is not one of ours stops here: `preview.mjs` would only print
|
||||||
|
* usage and exit 1, which reads as a broken preview rather than a bad input.
|
||||||
|
*
|
||||||
|
* @param {{action?: string, label?: string, operation?: string}} context
|
||||||
|
* @returns {'up' | 'refresh' | 'down' | undefined}
|
||||||
|
*/
|
||||||
|
export function resolveOperation({ action, label, operation }) {
|
||||||
|
if (operation) return DISPATCH_OPERATIONS.includes(operation) ? operation : undefined;
|
||||||
|
return operationFor(action ?? '', label);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `preview.mjs --json` keeps stdout clean, but a truncated or empty run still has
|
* `preview.mjs --json` keeps stdout clean, but a truncated or empty run still has
|
||||||
* to be told apart from a good one. Read the last JSON object that carries a url.
|
* to be told apart from a good one. Read the last JSON object that carries a url.
|
||||||
|
|
@ -113,6 +154,9 @@ export function readyComment({ url, codespace, sha, orgVisible, pr }) {
|
||||||
'',
|
'',
|
||||||
`**[Open the preview](${url}/preview-signin)** — one click signs you in.`,
|
`**[Open the preview](${url}/preview-signin)** — one click signs you in.`,
|
||||||
'',
|
'',
|
||||||
|
`If you need to modify the environment variables of this instance, navigate to ${CODESPACE_ENV_VARIABLE_URL}?pr=${pr} and submit them.`,
|
||||||
|
'The instance will refresh and apply your variables.',
|
||||||
|
'',
|
||||||
'| | |',
|
'| | |',
|
||||||
'| --- | --- |',
|
'| --- | --- |',
|
||||||
`| URL | ${url} |`,
|
`| URL | ${url} |`,
|
||||||
|
|
@ -122,7 +166,9 @@ export function readyComment({ url, codespace, sha, orgVisible, pr }) {
|
||||||
access,
|
access,
|
||||||
'',
|
'',
|
||||||
`The instance sleeps after ${IDLE_TIMEOUT} of no use and is deleted after ${RETENTION_PERIOD}.`,
|
`The instance sleeps after ${IDLE_TIMEOUT} of no use and is deleted after ${RETENTION_PERIOD}.`,
|
||||||
`Push a commit to serve it again. Remove the \`${PREVIEW_LABEL}\` label to delete it now.`,
|
`A box that slept comes back private, so wake it with [the preview workflow](${WORKFLOW_URL})`,
|
||||||
|
'(`Run workflow` → this PR number → `up`), or by pushing a commit.',
|
||||||
|
`Remove the \`${PREVIEW_LABEL}\` label to delete it now.`,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +189,132 @@ export function expiredComment({ pr }) {
|
||||||
`### Preview instance expired`,
|
`### Preview instance expired`,
|
||||||
'',
|
'',
|
||||||
`The preview box for PR #${pr} no longer exists — GitHub deletes one after ${RETENTION_PERIOD}.`,
|
`The preview box for PR #${pr} no longer exists — GitHub deletes one after ${RETENTION_PERIOD}.`,
|
||||||
`Remove and add the \`${PREVIEW_LABEL}\` label to get a new one.`,
|
`Run [the preview workflow](${WORKFLOW_URL}) with \`up\` to get a new one.`,
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `4m 12s`, for a comment that is read while it counts. Anything unusable reads as
|
||||||
|
* `0s`: a wrong duration in a status line is worse than a boring one.
|
||||||
|
*
|
||||||
|
* @param {number} ms
|
||||||
|
*/
|
||||||
|
export function formatElapsed(ms) {
|
||||||
|
const total = Number.isFinite(ms) && ms > 0 ? Math.floor(ms / 1000) : 0;
|
||||||
|
const seconds = total % 60;
|
||||||
|
const minutes = Math.floor(total / 60) % 60;
|
||||||
|
const hours = Math.floor(total / 3600);
|
||||||
|
|
||||||
|
if (hours) return `${hours}h ${minutes}m`;
|
||||||
|
if (minutes) return `${minutes}m ${String(seconds).padStart(2, '0')}s`;
|
||||||
|
return `${seconds}s`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The instance URL out of a body a previous run left. A refresh replaces the ready
|
||||||
|
* comment with a checklist, so without this the PR loses the URL for several
|
||||||
|
* minutes. Reads the URL row `readyComment` writes.
|
||||||
|
*
|
||||||
|
* @param {string} body
|
||||||
|
*/
|
||||||
|
export function previewUrlFromBody(body) {
|
||||||
|
return body.match(/^\| URL \| (\S+) \|$/m)?.[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One line of a `preview.mjs --json` run that reports a phase rather than the final
|
||||||
|
* result. A report carries a `url`; a progress line never does.
|
||||||
|
*
|
||||||
|
* @param {string} line
|
||||||
|
* @returns {{phase: string, detail?: string, sha?: string, codespace?: string} | undefined}
|
||||||
|
*/
|
||||||
|
export function parseProgressLine(line) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (!trimmed.startsWith('{')) return undefined;
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(trimmed);
|
||||||
|
if (parsed && typeof parsed.phase === 'string' && parsed.url === undefined) return parsed;
|
||||||
|
} catch {}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The checklist, while the box is being set up. Pure: the caller passes the clock,
|
||||||
|
* so this renders the same body twice.
|
||||||
|
*
|
||||||
|
* @param {{
|
||||||
|
* pr: string | number,
|
||||||
|
* operation: 'up' | 'refresh',
|
||||||
|
* runUrl: string,
|
||||||
|
* sha?: string,
|
||||||
|
* phase?: string,
|
||||||
|
* detail?: string,
|
||||||
|
* previousUrl?: string,
|
||||||
|
* startedAt: number,
|
||||||
|
* phaseStartedAt: number,
|
||||||
|
* now: number,
|
||||||
|
* }} state
|
||||||
|
*/
|
||||||
|
export function progressComment({
|
||||||
|
pr,
|
||||||
|
operation,
|
||||||
|
runUrl,
|
||||||
|
sha,
|
||||||
|
phase,
|
||||||
|
detail,
|
||||||
|
previousUrl,
|
||||||
|
startedAt,
|
||||||
|
phaseStartedAt,
|
||||||
|
now,
|
||||||
|
}) {
|
||||||
|
// Everything before the current phase is done. Going by position rather than by
|
||||||
|
// the phases actually seen keeps the list right when one never reports — an old
|
||||||
|
// PR head has no in-box emitter.
|
||||||
|
const current = phaseIndex(phase);
|
||||||
|
const inPhaseMs = now - phaseStartedAt;
|
||||||
|
|
||||||
|
const steps = PREVIEW_PHASES.map((step, index) => {
|
||||||
|
if (index < current) return `- [x] ${step.label}`;
|
||||||
|
if (index !== current) return `- [ ] ${step.label}`;
|
||||||
|
return `- [ ] **${step.label}**${detail ? ` — ${detail}` : ''} · ${formatElapsed(inPhaseMs)}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const slow = PREVIEW_PHASES[current]?.slowAfterMs;
|
||||||
|
const target = sha ? `\`${sha.slice(0, 7)}\`` : `PR #${pr}`;
|
||||||
|
|
||||||
|
return [
|
||||||
|
BOT_MARKER,
|
||||||
|
PROGRESS_MARKER,
|
||||||
|
`### Preview instance ${operation === 'refresh' ? 'updating to' : 'starting for'} ${target}`,
|
||||||
|
'',
|
||||||
|
'Setting up the box. This usually takes a few minutes.',
|
||||||
|
'',
|
||||||
|
...steps,
|
||||||
|
...(slow && inPhaseMs > slow
|
||||||
|
? ['', `> ${PREVIEW_PHASES[current].label} is taking longer than usual.`]
|
||||||
|
: []),
|
||||||
|
// A refresh stops the old backend before it rebuilds, so the URL is down for
|
||||||
|
// the rest of this run. Keep it on the PR anyway: it is the same URL when the
|
||||||
|
// run finishes, and losing it for several minutes is worse than saying so.
|
||||||
|
...(previousUrl
|
||||||
|
? ['', `The URL does not change: ${previousUrl}. It stops answering until this finishes.`]
|
||||||
|
: []),
|
||||||
|
'',
|
||||||
|
`Elapsed ${formatElapsed(now - startedAt)} · updated ${new Date(now).toISOString().slice(11, 19)} UTC · [live log](${runUrl})`,
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param {{pr: string | number, operation: string, runUrl: string}} context */
|
||||||
|
export function cancelledComment({ pr, operation, runUrl }) {
|
||||||
|
return [
|
||||||
|
BOT_MARKER,
|
||||||
|
`### Preview instance run stopped`,
|
||||||
|
'',
|
||||||
|
`The \`preview ${operation}\` run for PR #${pr} was cancelled or timed out, so the`,
|
||||||
|
'instance is in an unknown state. The box can still exist.',
|
||||||
|
'',
|
||||||
|
`Run [the preview workflow](${WORKFLOW_URL}) with \`up\` to finish the job, or \`down\` to delete the box.`,
|
||||||
|
`See [the workflow run](${runUrl}) for how far it got.`,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,47 +326,161 @@ export function failureComment({ operation, runUrl, message }) {
|
||||||
'',
|
'',
|
||||||
`\`preview ${operation}\` did not finish: ${message}`,
|
`\`preview ${operation}\` did not finish: ${message}`,
|
||||||
'',
|
'',
|
||||||
`See [the workflow run](${runUrl}) for the full log. Remove and add the \`${PREVIEW_LABEL}\` label to try again.`,
|
`See [the workflow run](${runUrl}) for the full log.`,
|
||||||
|
`Run [the preview workflow](${WORKFLOW_URL}) with \`${operation}\` to try again.`,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Progress and the in-box build log go to stderr, so they stream into the job log
|
* Human progress and the in-box build log go to stderr, so they stream into the job
|
||||||
* live. Only the JSON line is captured.
|
* log live. Only stdout is captured, and its phase lines are handed over as they
|
||||||
|
* arrive — a run this long has to report itself while it runs, not at the end.
|
||||||
*
|
*
|
||||||
* @param {readonly string[]} args
|
* @param {readonly string[]} args
|
||||||
|
* @param {{onProgress?: (progress: {phase: string, detail?: string, sha?: string}) => void}} [hooks]
|
||||||
|
* @returns {Promise<{status: number | null, stdout: string}>}
|
||||||
*/
|
*/
|
||||||
function runPreview(args) {
|
function runPreview(args, { onProgress } = {}) {
|
||||||
const result = spawnSync('node', [PREVIEW_SCRIPT, ...args], {
|
return new Promise((resolve, reject) => {
|
||||||
encoding: 'utf8',
|
const child = spawn('node', [PREVIEW_SCRIPT, ...args], {
|
||||||
stdio: ['ignore', 'pipe', 'inherit'],
|
stdio: ['ignore', 'pipe', 'inherit'],
|
||||||
|
});
|
||||||
|
const splitLines = createLineSplitter();
|
||||||
|
let stdout = '';
|
||||||
|
|
||||||
|
child.stdout.setEncoding('utf8');
|
||||||
|
child.stdout.on('data', (chunk) => {
|
||||||
|
// Kept whole for `parsePreviewJson`, which reads the report off the end.
|
||||||
|
stdout += chunk;
|
||||||
|
if (!onProgress) return;
|
||||||
|
for (const line of splitLines(chunk)) {
|
||||||
|
const progress = parseProgressLine(line);
|
||||||
|
if (progress) onProgress(progress);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('error', reject);
|
||||||
|
child.on('close', (status) => resolve({ status, stdout }));
|
||||||
});
|
});
|
||||||
if (result.error) throw result.error;
|
}
|
||||||
return { status: result.status, stdout: result.stdout ?? '' };
|
|
||||||
|
/**
|
||||||
|
* Keeps the checklist on the PR current while `preview.mjs` runs: one edit for each
|
||||||
|
* phase, plus a heartbeat so a long phase still looks alive.
|
||||||
|
*
|
||||||
|
* @param {{pr: string, operation: 'up' | 'refresh', runUrl: string, previousUrl?: string, commentId?: number}} context
|
||||||
|
*/
|
||||||
|
function createProgressReporter({ pr, operation, runUrl, previousUrl, commentId }) {
|
||||||
|
const startedAt = Date.now();
|
||||||
|
let phaseStartedAt = startedAt;
|
||||||
|
let id = commentId;
|
||||||
|
let phase;
|
||||||
|
let detail;
|
||||||
|
let sha;
|
||||||
|
let writes = Promise.resolve();
|
||||||
|
|
||||||
|
// One chain, so two edits never overlap, and every failure is swallowed: this
|
||||||
|
// Octokit carries no retry plugin, and a status edit must not fail a preview that
|
||||||
|
// is otherwise fine. Resetting the chain keeps one failure from poisoning the next.
|
||||||
|
function push() {
|
||||||
|
writes = writes
|
||||||
|
.then(async () => {
|
||||||
|
const body = progressComment({
|
||||||
|
pr,
|
||||||
|
operation,
|
||||||
|
runUrl,
|
||||||
|
sha,
|
||||||
|
phase,
|
||||||
|
detail,
|
||||||
|
previousUrl,
|
||||||
|
startedAt,
|
||||||
|
phaseStartedAt,
|
||||||
|
now: Date.now(),
|
||||||
|
});
|
||||||
|
// Hold the id from the first write: paginating every comment on the PR
|
||||||
|
// once a minute would be the expensive part of a heartbeat.
|
||||||
|
if (id === undefined) id = await postOrUpdateComment(Number(pr), body, BOT_MARKER);
|
||||||
|
else await updateCommentById(id, body);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(`::warning::Could not update the preview comment: ${error.message}`);
|
||||||
|
});
|
||||||
|
return writes;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timer = setInterval(push, HEARTBEAT_MS);
|
||||||
|
timer.unref();
|
||||||
|
|
||||||
|
return {
|
||||||
|
start: push,
|
||||||
|
/** @param {{phase: string, detail?: string, sha?: string}} progress */
|
||||||
|
onProgress(progress) {
|
||||||
|
if (progress.sha) sha = progress.sha;
|
||||||
|
if (progress.phase === phase && progress.detail === detail) return;
|
||||||
|
phase = progress.phase;
|
||||||
|
detail = progress.detail;
|
||||||
|
phaseStartedAt = Date.now();
|
||||||
|
push();
|
||||||
|
},
|
||||||
|
/** Drains the queue, so the final body of the run is always the last write. */
|
||||||
|
async stop() {
|
||||||
|
clearInterval(timer);
|
||||||
|
await writes;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A cancelled or timed-out job kills this process mid-checklist, so the workflow
|
||||||
|
* runs it again just to say so. Only over a progress body: a run cancelled while it
|
||||||
|
* was queued never started work, and must leave a ready comment alone.
|
||||||
|
*
|
||||||
|
* @param {string} pr
|
||||||
|
* @param {string} operation
|
||||||
|
* @param {string} runUrl
|
||||||
|
*/
|
||||||
|
async function reportCancelled(pr, operation, runUrl) {
|
||||||
|
const existing = await findCommentByMarker(Number(pr), BOT_MARKER);
|
||||||
|
if (!existing?.body.includes(PROGRESS_MARKER)) {
|
||||||
|
console.log('The preview comment is not a checklist — leaving it as it is.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await updateCommentById(existing.id, cancelledComment({ pr, operation, runUrl }));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const pr = ensureEnvVar('PULL_REQUEST_NUMBER');
|
const pr = ensureEnvVar('PULL_REQUEST_NUMBER');
|
||||||
const action = ensureEnvVar('EVENT_ACTION');
|
|
||||||
const runUrl = ensureEnvVar('RUN_URL');
|
const runUrl = ensureEnvVar('RUN_URL');
|
||||||
|
const requested = process.env.PREVIEW_OPERATION;
|
||||||
|
// A manual run carries no event action, so it cannot be required there.
|
||||||
|
const action = requested ? '' : ensureEnvVar('EVENT_ACTION');
|
||||||
const label = process.env.LABEL_NAME;
|
const label = process.env.LABEL_NAME;
|
||||||
|
|
||||||
const operation = operationFor(action, label);
|
// The dispatch input is free text. Refuse a non-number before anything tries to
|
||||||
console.log("Operations: ", {
|
// comment on it: postOrUpdateComment(NaN) 404s inside the catch below and
|
||||||
action,
|
// reports that instead of the real cause.
|
||||||
label,
|
if (!/^\d+$/.test(pr)) {
|
||||||
operation
|
console.error(`::error::PULL_REQUEST_NUMBER must be a number, got "${pr}".`);
|
||||||
})
|
process.exitCode = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const operation = resolveOperation({ action, label, operation: requested });
|
||||||
if (!operation) {
|
if (!operation) {
|
||||||
console.log(
|
console.log(
|
||||||
`No preview operation for a "${action}" event on "${label ?? ''}" — nothing to do.`,
|
`No preview operation for action="${action}" label="${label ?? ''}" operation="${requested ?? ''}" — nothing to do.`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.argv.includes('--report-cancelled')) {
|
||||||
|
await reportCancelled(pr, operation, runUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (operation === 'refresh') {
|
if (operation === 'refresh') {
|
||||||
const list = runPreview(['ls']);
|
const list = await runPreview(['ls']);
|
||||||
if (list.status !== 0) throw new Error(`\`preview ls\` exited ${list.status}`);
|
if (list.status !== 0) throw new Error(`\`preview ls\` exited ${list.status}`);
|
||||||
if (!hasPreviewBox(list.stdout, pr)) {
|
if (!hasPreviewBox(list.stdout, pr)) {
|
||||||
console.log(`No preview box for PR #${pr} — reporting it as expired.`);
|
console.log(`No preview box for PR #${pr} — reporting it as expired.`);
|
||||||
|
|
@ -204,14 +489,37 @@ async function main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { status, stdout } = runPreview([operation, pr, '--json']);
|
|
||||||
if (status !== 0) throw new Error(`\`preview ${operation}\` exited ${status}`);
|
|
||||||
|
|
||||||
if (operation === 'down') {
|
if (operation === 'down') {
|
||||||
|
const { status } = await runPreview([operation, pr, '--json']);
|
||||||
|
if (status !== 0) throw new Error(`\`preview ${operation}\` exited ${status}`);
|
||||||
await postOrUpdateComment(Number(pr), downComment({ pr }), BOT_MARKER);
|
await postOrUpdateComment(Number(pr), downComment({ pr }), BOT_MARKER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A checklist only earns its place in front of work that takes minutes. It also
|
||||||
|
// goes up after the `refresh` check above, so a box that is already gone never
|
||||||
|
// flashes a checklist before the expired body replaces it.
|
||||||
|
const existing = await findCommentByMarker(Number(pr), BOT_MARKER);
|
||||||
|
const reporter = createProgressReporter({
|
||||||
|
pr,
|
||||||
|
operation,
|
||||||
|
runUrl,
|
||||||
|
previousUrl: previewUrlFromBody(existing?.body ?? ''),
|
||||||
|
commentId: existing?.id,
|
||||||
|
});
|
||||||
|
await reporter.start();
|
||||||
|
|
||||||
|
let status;
|
||||||
|
let stdout;
|
||||||
|
try {
|
||||||
|
({ status, stdout } = await runPreview([operation, pr, '--json'], {
|
||||||
|
onProgress: reporter.onProgress,
|
||||||
|
}));
|
||||||
|
} finally {
|
||||||
|
await reporter.stop();
|
||||||
|
}
|
||||||
|
if (status !== 0) throw new Error(`\`preview ${operation}\` exited ${status}`);
|
||||||
|
|
||||||
const preview = parsePreviewJson(stdout);
|
const preview = parsePreviewJson(stdout);
|
||||||
if (!preview) throw new Error(`\`preview ${operation}\` printed no preview details`);
|
if (!preview) throw new Error(`\`preview ${operation}\` printed no preview details`);
|
||||||
|
|
||||||
|
|
|
||||||
196
.github/scripts/codespace-preview.test.mjs
vendored
196
.github/scripts/codespace-preview.test.mjs
vendored
|
|
@ -3,14 +3,23 @@ import { describe, it } from 'node:test';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BOT_MARKER,
|
BOT_MARKER,
|
||||||
|
DISPATCH_OPERATIONS,
|
||||||
|
PROGRESS_MARKER,
|
||||||
|
WORKFLOW_URL,
|
||||||
|
cancelledComment,
|
||||||
downComment,
|
downComment,
|
||||||
expiredComment,
|
expiredComment,
|
||||||
failureComment,
|
failureComment,
|
||||||
|
formatElapsed,
|
||||||
hasPreviewBox,
|
hasPreviewBox,
|
||||||
operationFor,
|
operationFor,
|
||||||
parsePreviewJson,
|
parsePreviewJson,
|
||||||
|
parseProgressLine,
|
||||||
portFromUrl,
|
portFromUrl,
|
||||||
|
previewUrlFromBody,
|
||||||
|
progressComment,
|
||||||
readyComment,
|
readyComment,
|
||||||
|
resolveOperation,
|
||||||
} from './codespace-preview.mjs';
|
} from './codespace-preview.mjs';
|
||||||
|
|
||||||
const PREVIEW = {
|
const PREVIEW = {
|
||||||
|
|
@ -21,6 +30,18 @@ const PREVIEW = {
|
||||||
orgVisible: true,
|
orgVisible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const START = Date.parse('2026-09-17T09:35:00Z');
|
||||||
|
const PROGRESS = {
|
||||||
|
pr: 1234,
|
||||||
|
operation: 'up',
|
||||||
|
runUrl: 'https://github.com/n8n-io/n8n/actions/runs/1',
|
||||||
|
sha: PREVIEW.sha,
|
||||||
|
phase: 'build',
|
||||||
|
startedAt: START,
|
||||||
|
phaseStartedAt: START + 111_000,
|
||||||
|
now: START + 363_000,
|
||||||
|
};
|
||||||
|
|
||||||
describe('operationFor', () => {
|
describe('operationFor', () => {
|
||||||
const LABEL = 'codespace-preview';
|
const LABEL = 'codespace-preview';
|
||||||
|
|
||||||
|
|
@ -56,6 +77,30 @@ describe('operationFor', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('resolveOperation', () => {
|
||||||
|
it('falls back to the event mapping when no operation is requested', () => {
|
||||||
|
assert.equal(resolveOperation({ action: 'labeled', label: 'codespace-preview' }), 'up');
|
||||||
|
assert.equal(resolveOperation({ action: 'synchronize' }), 'refresh');
|
||||||
|
assert.equal(resolveOperation({ action: 'labeled', label: 'bug' }), undefined);
|
||||||
|
// The workflow sets the variable to '' on a pull_request run, not undefined.
|
||||||
|
assert.equal(resolveOperation({ action: 'closed', operation: '' }), 'down');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets a manual run choose, over the event', () => {
|
||||||
|
for (const operation of DISPATCH_OPERATIONS) {
|
||||||
|
assert.equal(resolveOperation({ action: '', operation }), operation);
|
||||||
|
}
|
||||||
|
assert.equal(resolveOperation({ action: 'synchronize', operation: 'down' }), 'down');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects an operation that is not one of ours', () => {
|
||||||
|
// `ls` posts no comment and needs no PR, so the workflow does not offer it.
|
||||||
|
assert.equal(resolveOperation({ action: '', operation: 'ls' }), undefined);
|
||||||
|
assert.equal(resolveOperation({ action: '', operation: 'UP' }), undefined);
|
||||||
|
assert.equal(resolveOperation({ action: '', operation: 'up; rm -rf /' }), undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('parsePreviewJson', () => {
|
describe('parsePreviewJson', () => {
|
||||||
it('finds the JSON line among progress and in-box build output', () => {
|
it('finds the JSON line among progress and in-box build output', () => {
|
||||||
const stdout = [
|
const stdout = [
|
||||||
|
|
@ -77,6 +122,19 @@ describe('parsePreviewJson', () => {
|
||||||
assert.equal(parsePreviewJson(stdout).sha, PREVIEW.sha);
|
assert.equal(parsePreviewJson(stdout).sha, PREVIEW.sha);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The phase lines share the channel with the report. This is the contract that
|
||||||
|
// makes that safe.
|
||||||
|
it('ignores the phase lines that precede the report', () => {
|
||||||
|
const stdout = [
|
||||||
|
'{"phase":"resolve"}',
|
||||||
|
'{"sha":"abcdef1","phase":"build"}',
|
||||||
|
JSON.stringify(PREVIEW),
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
assert.deepEqual(parsePreviewJson(stdout), PREVIEW);
|
||||||
|
assert.equal(parsePreviewJson('{"phase":"build"}'), undefined);
|
||||||
|
});
|
||||||
|
|
||||||
it('ignores JSON that is not a preview report', () => {
|
it('ignores JSON that is not a preview report', () => {
|
||||||
// A build tool can print its own JSON on the same stream.
|
// A build tool can print its own JSON on the same stream.
|
||||||
assert.equal(parsePreviewJson('{"level":"info","msg":"built"}'), undefined);
|
assert.equal(parsePreviewJson('{"level":"info","msg":"built"}'), undefined);
|
||||||
|
|
@ -132,6 +190,12 @@ describe('comment bodies', () => {
|
||||||
runUrl: 'https://github.com/n8n-io/n8n/actions/runs/1',
|
runUrl: 'https://github.com/n8n-io/n8n/actions/runs/1',
|
||||||
message: '`preview up` exited 1',
|
message: '`preview up` exited 1',
|
||||||
}),
|
}),
|
||||||
|
progress: progressComment(PROGRESS),
|
||||||
|
cancelled: cancelledComment({
|
||||||
|
pr: PREVIEW.pr,
|
||||||
|
operation: 'up',
|
||||||
|
runUrl: 'https://github.com/n8n-io/n8n/actions/runs/1',
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
it('every body starts with the marker, so postOrUpdateComment edits in place', () => {
|
it('every body starts with the marker, so postOrUpdateComment edits in place', () => {
|
||||||
|
|
@ -159,4 +223,136 @@ describe('comment bodies', () => {
|
||||||
assert.match(bodies.failure, /exited 1/);
|
assert.match(bodies.failure, /exited 1/);
|
||||||
assert.match(bodies.failure, /actions\/runs\/1/);
|
assert.match(bodies.failure, /actions\/runs\/1/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('quotes the idle timeout preview.mjs actually sets', () => {
|
||||||
|
// preview.mjs creates a box with --idle-timeout 2h.
|
||||||
|
assert.match(bodies.ready, /sleeps after 2 hours/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('points a slept, expired or failed box at the manual run', () => {
|
||||||
|
for (const name of ['ready', 'expired', 'failure']) {
|
||||||
|
assert.ok(bodies[name].includes(WORKFLOW_URL), `${name} must link the workflow`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// The cancelled-run step writes only over a checklist, so no settled body may
|
||||||
|
// carry the progress marker.
|
||||||
|
it('carries the progress marker on the checklist and nowhere else', () => {
|
||||||
|
assert.ok(bodies.progress.includes(PROGRESS_MARKER));
|
||||||
|
for (const name of ['ready', 'down', 'expired', 'failure', 'cancelled']) {
|
||||||
|
assert.ok(!bodies[name].includes(PROGRESS_MARKER), `${name} must not look in progress`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('the cancelled body says the box can still exist, and links both runs', () => {
|
||||||
|
assert.match(bodies.cancelled, /can still exist/);
|
||||||
|
assert.ok(bodies.cancelled.includes(WORKFLOW_URL));
|
||||||
|
assert.ok(bodies.cancelled.includes('actions/runs/1'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('formatElapsed', () => {
|
||||||
|
it('reads as a duration a reviewer can scan', () => {
|
||||||
|
assert.equal(formatElapsed(0), '0s');
|
||||||
|
assert.equal(formatElapsed(59_000), '59s');
|
||||||
|
assert.equal(formatElapsed(60_000), '1m 00s');
|
||||||
|
assert.equal(formatElapsed(252_000), '4m 12s');
|
||||||
|
assert.equal(formatElapsed(3_780_000), '1h 3m');
|
||||||
|
});
|
||||||
|
|
||||||
|
// A wrong duration in a status line is worse than a boring one.
|
||||||
|
it('falls back to 0s for a value it cannot use', () => {
|
||||||
|
assert.equal(formatElapsed(-1), '0s');
|
||||||
|
assert.equal(formatElapsed(NaN), '0s');
|
||||||
|
assert.equal(formatElapsed(undefined), '0s');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('progressComment', () => {
|
||||||
|
it('ticks off the phases before the current one and leaves the rest open', () => {
|
||||||
|
const body = progressComment(PROGRESS);
|
||||||
|
|
||||||
|
assert.match(body, /- \[x\] Resolve the PR head/);
|
||||||
|
assert.match(body, /- \[x\] Install dependencies/);
|
||||||
|
assert.match(body, /- \[ \] \*\*Build the monorepo\*\* · 4m 12s/);
|
||||||
|
assert.match(body, /- \[ \] Share the port with the org/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('names the commit and the elapsed time, and links the run', () => {
|
||||||
|
const body = progressComment(PROGRESS);
|
||||||
|
|
||||||
|
assert.match(body, /starting for `abcdef1`/);
|
||||||
|
assert.match(body, /Elapsed 6m 03s/);
|
||||||
|
assert.ok(body.includes(PROGRESS.runUrl));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('says what the phase is doing when the phase says so', () => {
|
||||||
|
const body = progressComment({ ...PROGRESS, phase: 'box', detail: 'reusing psychic-umbrella' });
|
||||||
|
|
||||||
|
assert.match(body, /\*\*Prepare the box\*\* — reusing psychic-umbrella/);
|
||||||
|
});
|
||||||
|
|
||||||
|
// A workflow_dispatch run reports the sha only once preview.mjs resolves it.
|
||||||
|
it('falls back to the PR number before the sha is known', () => {
|
||||||
|
const body = progressComment({ ...PROGRESS, sha: undefined });
|
||||||
|
|
||||||
|
assert.match(body, /starting for PR #1234/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('leaves every phase open before the first one reports', () => {
|
||||||
|
const body = progressComment({ ...PROGRESS, phase: undefined });
|
||||||
|
|
||||||
|
assert.ok(!body.includes('- [x]'));
|
||||||
|
assert.match(body, /- \[ \] Resolve the PR head/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('says a refresh is updating, not starting', () => {
|
||||||
|
assert.match(progressComment({ ...PROGRESS, operation: 'refresh' }), /updating to `abcdef1`/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('warns only once a phase passes the time it usually takes', () => {
|
||||||
|
const slow = { ...PROGRESS, phaseStartedAt: START - 600_001 };
|
||||||
|
|
||||||
|
assert.match(progressComment(slow), /Build the monorepo is taking longer than usual/);
|
||||||
|
assert.ok(!progressComment(PROGRESS).includes('longer than usual'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replacing a ready comment with a checklist would otherwise take a working URL
|
||||||
|
// off the PR for several minutes.
|
||||||
|
it('keeps a URL a previous run reported', () => {
|
||||||
|
const body = progressComment({ ...PROGRESS, previousUrl: PREVIEW.url });
|
||||||
|
|
||||||
|
assert.ok(body.includes(PREVIEW.url));
|
||||||
|
assert.match(body, /stops answering/);
|
||||||
|
assert.ok(!progressComment(PROGRESS).includes('stops answering'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('previewUrlFromBody', () => {
|
||||||
|
it('reads the URL back out of a ready body', () => {
|
||||||
|
assert.equal(previewUrlFromBody(readyComment(PREVIEW)), PREVIEW.url);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds nothing in a body that reports no instance', () => {
|
||||||
|
assert.equal(previewUrlFromBody(downComment({ pr: 1234 })), undefined);
|
||||||
|
assert.equal(previewUrlFromBody(expiredComment({ pr: 1234 })), undefined);
|
||||||
|
assert.equal(previewUrlFromBody(progressComment(PROGRESS)), undefined);
|
||||||
|
assert.equal(previewUrlFromBody(''), undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('parseProgressLine', () => {
|
||||||
|
it('reads a phase line', () => {
|
||||||
|
assert.deepEqual(parseProgressLine('{"phase":"build","sha":"abc"}'), {
|
||||||
|
phase: 'build',
|
||||||
|
sha: 'abc',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores the report and anything that is not a phase line', () => {
|
||||||
|
assert.equal(parseProgressLine(JSON.stringify(PREVIEW)), undefined);
|
||||||
|
assert.equal(parseProgressLine('Serving abcdef1 on psychic-umbrella-q7w6gwx…'), undefined);
|
||||||
|
assert.equal(parseProgressLine('{"level":"info","msg":"built"}'), undefined);
|
||||||
|
assert.equal(parseProgressLine('{not json'), undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
42
.github/scripts/db-test-matrix.mjs
vendored
42
.github/scripts/db-test-matrix.mjs
vendored
|
|
@ -7,11 +7,16 @@ import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
||||||
|
|
||||||
export const POSTGRES_VERSIONS_PATH = 'packages/testing/containers/postgres-versions.json';
|
export const POSTGRES_VERSIONS_PATH = 'packages/quality/environments/containers/postgres-versions.json';
|
||||||
|
|
||||||
/** The matrix wall is bounded by its slowest leg, so a larger runner buys nothing. */
|
/** The matrix wall is bounded by its slowest leg, so a larger runner buys nothing. */
|
||||||
const RUNNER = 'blacksmith-4vcpu-ubuntu-2204';
|
const RUNNER = 'blacksmith-4vcpu-ubuntu-2204';
|
||||||
|
|
||||||
|
// Each leg runs one suite on its own runner, so use every CPU. The CI default
|
||||||
|
// (half the CPUs) is for jobs that run many suites at once. Every test file
|
||||||
|
// gets its own database, so more workers do not share state.
|
||||||
|
const MAX_WORKERS = '--maxWorkers=100%';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PostgresVersions
|
* @typedef {Object} PostgresVersions
|
||||||
* @property {string} primary
|
* @property {string} primary
|
||||||
|
|
@ -24,13 +29,25 @@ export function readPostgresVersions(repoRoot = REPO_ROOT) {
|
||||||
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SCOPES = new Set(['pr', 'full']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Coverage and the schema-docs check run on the primary Postgres leg only, since
|
* The schema-docs check runs on the primary Postgres leg only, since the
|
||||||
* the committed docs come from that one version.
|
* committed docs come from that one version. PRs collect coverage on that leg.
|
||||||
|
* Merge groups use the full scope and skip duplicate coverage collection.
|
||||||
|
*
|
||||||
|
* Scope 'pr' keeps SQLite plus the primary Postgres leg. Scope 'full' keeps
|
||||||
|
* every Postgres major. The merge queue generates with 'full', so every merge
|
||||||
|
* still gates on the older majors.
|
||||||
*
|
*
|
||||||
* @param {PostgresVersions} versions
|
* @param {PostgresVersions} versions
|
||||||
|
* @param {'pr' | 'full'} scope
|
||||||
*/
|
*/
|
||||||
export function buildMatrix(versions) {
|
export function buildMatrix(versions, scope = 'full') {
|
||||||
|
if (!SCOPES.has(scope)) {
|
||||||
|
throw new Error(`Unknown scope "${scope}", expected "pr" or "full"`);
|
||||||
|
}
|
||||||
|
|
||||||
const { primary, matrix } = versions;
|
const { primary, matrix } = versions;
|
||||||
|
|
||||||
if (!Array.isArray(matrix) || matrix.length === 0) {
|
if (!Array.isArray(matrix) || matrix.length === 0) {
|
||||||
|
|
@ -67,29 +84,34 @@ export function buildMatrix(versions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validation always runs on the full list; scope only trims the output.
|
||||||
|
const postgresLegs = scope === 'pr' ? matrix.filter(({ image }) => image === primary) : matrix;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'SQLite Pooled',
|
name: 'SQLite Pooled',
|
||||||
runner: RUNNER,
|
runner: RUNNER,
|
||||||
'test-cmd': 'pnpm test:sqlite',
|
'test-cmd': `pnpm test:sqlite ${MAX_WORKERS}`,
|
||||||
'migration-cmd': 'pnpm test:sqlite:migrations',
|
'migration-cmd': 'pnpm test:sqlite:migrations',
|
||||||
'schema-check-cmd': 'pnpm --filter=@n8n/db schema:check:sqlite',
|
'schema-check-cmd': 'pnpm --filter=@n8n/db schema:check:sqlite',
|
||||||
TEST_IMAGE_POSTGRES: undefined,
|
TEST_IMAGE_POSTGRES: undefined,
|
||||||
collectCoverage: 'false',
|
collectCoverage: 'false',
|
||||||
},
|
},
|
||||||
...matrix.map(({ major, image }) => ({
|
...postgresLegs.map(({ major, image }) => ({
|
||||||
name: `Postgres ${major}`,
|
name: `Postgres ${major}`,
|
||||||
runner: RUNNER,
|
runner: RUNNER,
|
||||||
'test-cmd': 'pnpm test:postgres:integration:tc',
|
'test-cmd': `pnpm test:postgres:integration:tc ${MAX_WORKERS}`,
|
||||||
'migration-cmd': 'pnpm test:postgres:migrations:tc',
|
'migration-cmd': `pnpm test:postgres:migrations:tc ${MAX_WORKERS}`,
|
||||||
'schema-check-cmd': image === primary ? 'pnpm --filter=@n8n/db schema:check:postgres' : '',
|
'schema-check-cmd': image === primary ? 'pnpm --filter=@n8n/db schema:check:postgres' : '',
|
||||||
TEST_IMAGE_POSTGRES: image,
|
TEST_IMAGE_POSTGRES: image,
|
||||||
collectCoverage: image === primary ? 'true' : 'false',
|
collectCoverage: scope === 'pr' && image === primary ? 'true' : 'false',
|
||||||
})),
|
})),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skipped when imported by the tests.
|
// Skipped when imported by the tests.
|
||||||
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
console.log(JSON.stringify(buildMatrix(readPostgresVersions())));
|
const scopeArg = process.argv.find((arg) => arg.startsWith('--scope='));
|
||||||
|
const scope = scopeArg ? scopeArg.slice('--scope='.length) : 'full';
|
||||||
|
console.log(JSON.stringify(buildMatrix(readPostgresVersions(), scope)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
45
.github/scripts/db-test-matrix.test.mjs
vendored
45
.github/scripts/db-test-matrix.test.mjs
vendored
|
|
@ -62,14 +62,27 @@ describe('buildMatrix', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('collects coverage and checks schema docs on the primary Postgres leg only', () => {
|
it('collects coverage on the primary Postgres leg in pr scope only', () => {
|
||||||
const legs = buildMatrix(versions());
|
const legs = buildMatrix(versions(), 'pr');
|
||||||
|
|
||||||
const collecting = legs.filter((leg) => leg.collectCoverage === 'true');
|
const collecting = legs.filter((leg) => leg.collectCoverage === 'true');
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
collecting.map((leg) => leg.name),
|
collecting.map((leg) => leg.name),
|
||||||
['Postgres 18'],
|
['Postgres 18'],
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not collect coverage in full scope', () => {
|
||||||
|
const legs = buildMatrix(versions(), 'full');
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
legs.some((leg) => leg.collectCoverage === 'true'),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checks schema docs on the primary Postgres leg only', () => {
|
||||||
|
const legs = buildMatrix(versions());
|
||||||
|
|
||||||
const checkingPostgresSchema = legs.filter(
|
const checkingPostgresSchema = legs.filter(
|
||||||
(leg) => leg['schema-check-cmd'] === 'pnpm --filter=@n8n/db schema:check:postgres',
|
(leg) => leg['schema-check-cmd'] === 'pnpm --filter=@n8n/db schema:check:postgres',
|
||||||
|
|
@ -125,4 +138,32 @@ describe('buildMatrix', () => {
|
||||||
it('rejects an empty matrix', () => {
|
it('rejects an empty matrix', () => {
|
||||||
assert.throws(() => buildMatrix({ primary: 'postgres:18.4-alpine', matrix: [] }), /non-empty/);
|
assert.throws(() => buildMatrix({ primary: 'postgres:18.4-alpine', matrix: [] }), /non-empty/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('keeps only SQLite and the primary Postgres leg in pr scope', () => {
|
||||||
|
const legs = buildMatrix(versions(), 'pr');
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
legs.map((leg) => leg.name),
|
||||||
|
['SQLite Pooled', 'Postgres 18'],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps every Postgres leg in full scope', () => {
|
||||||
|
const legs = buildMatrix(versions(), 'full');
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
legs.map((leg) => leg.name),
|
||||||
|
['SQLite Pooled', 'Postgres 16', 'Postgres 17', 'Postgres 18'],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('validates the full version list even in pr scope', () => {
|
||||||
|
const stale = { ...versions(), primary: 'postgres:17.10-alpine' };
|
||||||
|
|
||||||
|
assert.throws(() => buildMatrix(stale, 'pr'), /"primary".*must be the newest/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects an unknown scope', () => {
|
||||||
|
assert.throws(() => buildMatrix(versions(), 'nightly'), /Unknown scope/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
32
.github/scripts/docker/should-smoke-build.mjs
vendored
32
.github/scripts/docker/should-smoke-build.mjs
vendored
|
|
@ -14,6 +14,7 @@ import { appendFileSync, readFileSync } from 'node:fs';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
|
|
||||||
const WORKSPACE_FILE = 'pnpm-workspace.yaml';
|
const WORKSPACE_FILE = 'pnpm-workspace.yaml';
|
||||||
|
const ROOT_MANIFEST = 'package.json';
|
||||||
|
|
||||||
const BUMP_ONLY = [/^pnpm-workspace\.yaml$/, /^pnpm-lock\.yaml$/, /(^|\/)package\.json$/];
|
const BUMP_ONLY = [/^pnpm-workspace\.yaml$/, /^pnpm-lock\.yaml$/, /(^|\/)package\.json$/];
|
||||||
|
|
||||||
|
|
@ -69,6 +70,14 @@ export function nativePinsChanged(baseText, headText) {
|
||||||
return { changed: false, reason: 'no buildable dependency pin changed' };
|
return { changed: false, reason: 'no buildable dependency pin changed' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function packageManagerChanged(baseText, headText) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(baseText).packageManager !== JSON.parse(headText).packageManager;
|
||||||
|
} catch {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fileAt(ref, path) {
|
function fileAt(ref, path) {
|
||||||
try {
|
try {
|
||||||
return execFileSync('git', ['show', `${ref}:${path}`], { encoding: 'utf8' });
|
return execFileSync('git', ['show', `${ref}:${path}`], { encoding: 'utf8' });
|
||||||
|
|
@ -88,12 +97,25 @@ function main(argv) {
|
||||||
let reason = 'a Docker-chain file changed';
|
let reason = 'a Docker-chain file changed';
|
||||||
|
|
||||||
if (isBumpOnly(files)) {
|
if (isBumpOnly(files)) {
|
||||||
const baseText = fileAt(base, WORKSPACE_FILE);
|
const baseManifest = fileAt(base, ROOT_MANIFEST);
|
||||||
const headText = fileAt('HEAD', WORKSPACE_FILE);
|
const headManifest = fileAt('HEAD', ROOT_MANIFEST);
|
||||||
if (baseText === null || headText === null) {
|
if (files.includes(ROOT_MANIFEST) && (baseManifest === null || headManifest === null)) {
|
||||||
reason = `could not read ${WORKSPACE_FILE} on both sides of the diff`;
|
reason = `could not read ${ROOT_MANIFEST} on both sides of the diff`;
|
||||||
|
} else if (
|
||||||
|
files.includes(ROOT_MANIFEST) &&
|
||||||
|
baseManifest !== null &&
|
||||||
|
headManifest !== null &&
|
||||||
|
packageManagerChanged(baseManifest, headManifest)
|
||||||
|
) {
|
||||||
|
reason = 'the package manager pin changed';
|
||||||
} else {
|
} else {
|
||||||
({ changed: build, reason } = nativePinsChanged(baseText, headText));
|
const baseWorkspace = fileAt(base, WORKSPACE_FILE);
|
||||||
|
const headWorkspace = fileAt('HEAD', WORKSPACE_FILE);
|
||||||
|
if (baseWorkspace === null || headWorkspace === null) {
|
||||||
|
reason = `could not read ${WORKSPACE_FILE} on both sides of the diff`;
|
||||||
|
} else {
|
||||||
|
({ changed: build, reason } = nativePinsChanged(baseWorkspace, headWorkspace));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
import { describe, it } from 'node:test';
|
import { describe, it } from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { buildableDeps, isBumpOnly, nativePinsChanged } from './should-smoke-build.mjs';
|
import {
|
||||||
|
buildableDeps,
|
||||||
|
isBumpOnly,
|
||||||
|
nativePinsChanged,
|
||||||
|
packageManagerChanged,
|
||||||
|
} from './should-smoke-build.mjs';
|
||||||
|
|
||||||
const workspace = ({ kafka = '1.9.1', vm = '^7.0.0', sentry = '10.70.0', allowVm = true } = {}) => `
|
const workspace = ({ kafka = '1.9.1', vm = '^7.0.0', sentry = '10.70.0', allowVm = true } = {}) => `
|
||||||
catalog:
|
catalog:
|
||||||
|
|
@ -86,3 +91,25 @@ describe('nativePinsChanged', () => {
|
||||||
assert.equal(nativePinsChanged(workspace(), workspace()).changed, false);
|
assert.equal(nativePinsChanged(workspace(), workspace()).changed, false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('packageManagerChanged', () => {
|
||||||
|
it('detects a pnpm version change', () => {
|
||||||
|
assert.equal(
|
||||||
|
packageManagerChanged(
|
||||||
|
JSON.stringify({ packageManager: 'pnpm@11.25.0' }),
|
||||||
|
JSON.stringify({ packageManager: 'pnpm@12.3.4' }),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores unrelated manifest changes', () => {
|
||||||
|
assert.equal(
|
||||||
|
packageManagerChanged(
|
||||||
|
JSON.stringify({ packageManager: 'pnpm@12.3.4', version: '1.0.0' }),
|
||||||
|
JSON.stringify({ packageManager: 'pnpm@12.3.4', version: '1.0.1' }),
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
150
.github/scripts/github-helpers.mjs
vendored
150
.github/scripts/github-helpers.mjs
vendored
|
|
@ -1,8 +1,17 @@
|
||||||
import { getOctokit } from '@actions/github';
|
|
||||||
import { execFileSync } from 'node:child_process';
|
import { execFileSync } from 'node:child_process';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import semver from 'semver';
|
|
||||||
|
// Scripts that run through `run-workflow-script` have no node_modules: they
|
||||||
|
// get their client through `setOctokit` and never call the release helpers.
|
||||||
|
const actionsGithub = await import('@actions/github').catch((error) => {
|
||||||
|
if (error.code !== 'ERR_MODULE_NOT_FOUND') throw error;
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
/** @returns { typeof import('semver') } */
|
||||||
|
const loadSemver = () => require('semver');
|
||||||
|
|
||||||
export const CURRENT_MAJOR_VERSION = 2;
|
export const CURRENT_MAJOR_VERSION = 2;
|
||||||
export const RELEASE_CANDIDATE_BRANCH_PREFIX = 'release-candidate/';
|
export const RELEASE_CANDIDATE_BRANCH_PREFIX = 'release-candidate/';
|
||||||
|
|
@ -48,8 +57,8 @@ export function pickHighestReleaseTag(tags) {
|
||||||
const versions = tags
|
const versions = tags
|
||||||
.filter((t) => t.startsWith(RELEASE_PREFIX))
|
.filter((t) => t.startsWith(RELEASE_PREFIX))
|
||||||
.map((t) => ({ tag: t, v: stripReleasePrefixes(t) }))
|
.map((t) => ({ tag: t, v: stripReleasePrefixes(t) }))
|
||||||
.filter(({ v }) => semver.valid(v))
|
.filter(({ v }) => loadSemver().valid(v))
|
||||||
.sort((a, b) => semver.rcompare(a.v, b.v));
|
.sort((a, b) => loadSemver().rcompare(a.v, b.v));
|
||||||
|
|
||||||
return /** @type { ReleaseVersion } */ (versions[0]?.tag) ?? null;
|
return /** @type { ReleaseVersion } */ (versions[0]?.tag) ?? null;
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +137,7 @@ export function resolveRcBranchForTrack(track) {
|
||||||
const releaseTag = pickHighestReleaseTag(tagsAtCommit);
|
const releaseTag = pickHighestReleaseTag(tagsAtCommit);
|
||||||
if (!releaseTag) return null;
|
if (!releaseTag) return null;
|
||||||
|
|
||||||
const parsed = semver.parse(stripReleasePrefixes(releaseTag));
|
const parsed = loadSemver().parse(stripReleasePrefixes(releaseTag));
|
||||||
if (!parsed) return null;
|
if (!parsed) return null;
|
||||||
|
|
||||||
return `release-candidate/${parsed.major}.${parsed.minor}.x`;
|
return `release-candidate/${parsed.major}.${parsed.minor}.x`;
|
||||||
|
|
@ -145,12 +154,12 @@ export function resolveRcBranchForTrack(track) {
|
||||||
* */
|
* */
|
||||||
export function tagVersionInfoToReleaseCandidateBranchName(tagVersionInfo) {
|
export function tagVersionInfoToReleaseCandidateBranchName(tagVersionInfo) {
|
||||||
const version = tagVersionInfo.version;
|
const version = tagVersionInfo.version;
|
||||||
const majorVersion = semver.major(version);
|
const majorVersion = loadSemver().major(version);
|
||||||
if (majorVersion < CURRENT_MAJOR_VERSION) {
|
if (majorVersion < CURRENT_MAJOR_VERSION) {
|
||||||
return `${majorVersion}.x`;
|
return `${majorVersion}.x`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${RELEASE_CANDIDATE_BRANCH_PREFIX}${majorVersion}.${semver.minor(version)}.x`;
|
return `${RELEASE_CANDIDATE_BRANCH_PREFIX}${majorVersion}.${loadSemver().minor(version)}.x`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -351,18 +360,37 @@ export function localRefExists(ref) {
|
||||||
return res.ok;
|
return res.ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type { GitHubInstance | null } */
|
||||||
|
let injectedOctokit = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes octokit with GITHUB_TOKEN from env vars.
|
* Use a ready client instead of building one from GITHUB_TOKEN.
|
||||||
|
* `run-workflow-script` passes the client that actions/github-script provides.
|
||||||
*
|
*
|
||||||
* Also ensures the existence of useful environment variables.
|
* @param { GitHubInstance | null } octokit
|
||||||
|
*/
|
||||||
|
export function setOctokit(octokit) {
|
||||||
|
injectedOctokit = octokit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the octokit client and the current repository.
|
||||||
|
*
|
||||||
|
* Uses the injected client when set, otherwise builds one from GITHUB_TOKEN.
|
||||||
* */
|
* */
|
||||||
export function initGithub() {
|
export function initGithub() {
|
||||||
const token = ensureEnvVar('GITHUB_TOKEN');
|
|
||||||
const repoFullName = ensureEnvVar('GITHUB_REPOSITORY');
|
const repoFullName = ensureEnvVar('GITHUB_REPOSITORY');
|
||||||
|
|
||||||
const [owner, repo] = repoFullName.split('/');
|
const [owner, repo] = repoFullName.split('/');
|
||||||
|
|
||||||
const octokit = getOctokit(token);
|
if (injectedOctokit) {
|
||||||
|
return { octokit: injectedOctokit, owner, repo };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!actionsGithub) {
|
||||||
|
throw new Error('No Octokit client: call setOctokit() or install the .github/scripts dependencies');
|
||||||
|
}
|
||||||
|
const token = ensureEnvVar('GITHUB_TOKEN');
|
||||||
|
const octokit = actionsGithub.getOctokit(token);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
octokit,
|
octokit,
|
||||||
|
|
@ -386,6 +414,26 @@ export async function getPullRequestById(pullRequestId) {
|
||||||
return pullRequest.data;
|
return pullRequest.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open PRs whose head is `headOwner:headBranch`, newest first.
|
||||||
|
*
|
||||||
|
* @param { string } headOwner Owner of the head repository (a fork owner or this org).
|
||||||
|
* @param { string } headBranch
|
||||||
|
* @returns { Promise<any[]> }
|
||||||
|
*/
|
||||||
|
export async function listOpenPullRequestsByHead(headOwner, headBranch) {
|
||||||
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
||||||
|
const pullRequests = await octokit.rest.pulls.list({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
state: 'open',
|
||||||
|
head: `${headOwner}:${headBranch}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
return pullRequests.data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the set of files changed in a PR, including previous filenames for renames.
|
* Returns the set of files changed in a PR, including previous filenames for renames.
|
||||||
*
|
*
|
||||||
|
|
@ -442,6 +490,23 @@ export async function getPrReviews(pullRequestNumber) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all events for a PR, including label changes and their actors.
|
||||||
|
*
|
||||||
|
* @param { number } pullRequestNumber
|
||||||
|
* @returns { Promise<Array<{ event: string, actor: { login: string } | null, label?: { name?: string } | null, created_at?: string }>> }
|
||||||
|
* */
|
||||||
|
export async function getPrEvents(pullRequestNumber) {
|
||||||
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
||||||
|
return await octokit.paginate(octokit.rest.issues.listEvents, {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: pullRequestNumber,
|
||||||
|
per_page: 100,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether a user is an active member of an org team.
|
* Test whether a user is an active member of an org team.
|
||||||
*
|
*
|
||||||
|
|
@ -493,14 +558,13 @@ export async function setCommitStatus(sha, { state, context, description, target
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post a PR comment, or update the existing one if a previous run already
|
* The comment a previous run left, found by its bot marker.
|
||||||
* left one identified by the provided bot marker.
|
|
||||||
*
|
*
|
||||||
* @param { number } pullRequestNumber
|
* @param { number } pullRequestNumber
|
||||||
* @param { string } body
|
|
||||||
* @param { string } botMarker
|
* @param { string } botMarker
|
||||||
|
* @returns { Promise<{ id: number, body: string } | undefined> }
|
||||||
*/
|
*/
|
||||||
export async function postOrUpdateComment(pullRequestNumber, body, botMarker) {
|
export async function findCommentByMarker(pullRequestNumber, botMarker) {
|
||||||
const { octokit, owner, repo } = initGithub();
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
||||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||||
|
|
@ -512,21 +576,49 @@ export async function postOrUpdateComment(pullRequestNumber, body, botMarker) {
|
||||||
|
|
||||||
const existing = comments.find((c) => c.body?.includes(botMarker));
|
const existing = comments.find((c) => c.body?.includes(botMarker));
|
||||||
|
|
||||||
|
return existing ? { id: existing.id, body: existing.body ?? '' } : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrite a comment whose id is already known. A caller that edits the same
|
||||||
|
* comment repeatedly uses this instead of paginating every comment each time.
|
||||||
|
*
|
||||||
|
* @param { number } commentId
|
||||||
|
* @param { string } body
|
||||||
|
*/
|
||||||
|
export async function updateCommentById(commentId, body) {
|
||||||
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
||||||
|
await octokit.rest.issues.updateComment({ owner, repo, comment_id: commentId, body });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post a PR comment, or update the existing one if a previous run already
|
||||||
|
* left one identified by the provided bot marker.
|
||||||
|
*
|
||||||
|
* @param { number } pullRequestNumber
|
||||||
|
* @param { string } body
|
||||||
|
* @param { string } botMarker
|
||||||
|
* @returns { Promise<number> } the id of the comment it wrote
|
||||||
|
*/
|
||||||
|
export async function postOrUpdateComment(pullRequestNumber, body, botMarker) {
|
||||||
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
||||||
|
const existing = await findCommentByMarker(pullRequestNumber, botMarker);
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
await octokit.rest.issues.updateComment({
|
await updateCommentById(existing.id, body);
|
||||||
owner,
|
return existing.id;
|
||||||
repo,
|
|
||||||
comment_id: existing.id,
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await octokit.rest.issues.createComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: pullRequestNumber,
|
|
||||||
body,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const created = await octokit.rest.issues.createComment({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: pullRequestNumber,
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
|
||||||
|
return created.data.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
150
.github/scripts/github-helpers.test.mjs
vendored
150
.github/scripts/github-helpers.test.mjs
vendored
|
|
@ -18,10 +18,113 @@ mock.module('@actions/github', {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { postOrUpdateComment, writeGithubOutput } = await import('./github-helpers.mjs');
|
const {
|
||||||
|
findCommentByMarker,
|
||||||
|
getPrEvents,
|
||||||
|
initGithub,
|
||||||
|
postOrUpdateComment,
|
||||||
|
setOctokit,
|
||||||
|
updateCommentById,
|
||||||
|
writeGithubOutput,
|
||||||
|
} = await import('./github-helpers.mjs');
|
||||||
|
|
||||||
const ORIGINAL_ENV = { ...process.env };
|
const ORIGINAL_ENV = { ...process.env };
|
||||||
|
|
||||||
|
describe('getPrEvents', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.env.GITHUB_REPOSITORY = 'n8n-io/n8n';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
setOctokit(null);
|
||||||
|
process.env = { ...ORIGINAL_ENV };
|
||||||
|
});
|
||||||
|
|
||||||
|
it('paginates issue events for the pull request', async () => {
|
||||||
|
const events = [{ event: 'labeled', actor: { login: 'ana' } }];
|
||||||
|
const listEvents = {};
|
||||||
|
const paginate = mock.fn(async () => events);
|
||||||
|
setOctokit({ paginate, rest: { issues: { listEvents } } });
|
||||||
|
|
||||||
|
assert.equal(await getPrEvents(42), events);
|
||||||
|
assert.equal(paginate.mock.calls[0].arguments[0], listEvents);
|
||||||
|
assert.deepEqual(paginate.mock.calls[0].arguments[1], {
|
||||||
|
owner: 'n8n-io',
|
||||||
|
repo: 'n8n',
|
||||||
|
issue_number: 42,
|
||||||
|
per_page: 100,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findCommentByMarker', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.env.GITHUB_TOKEN = 'token';
|
||||||
|
process.env.GITHUB_REPOSITORY = 'n8n-io/n8n';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.env = { ...ORIGINAL_ENV };
|
||||||
|
});
|
||||||
|
|
||||||
|
const withComments = (comments) => {
|
||||||
|
octokitImpl = () => ({
|
||||||
|
paginate: mock.fn(async () => comments),
|
||||||
|
rest: { issues: { listComments: {}, createComment: mock.fn(), updateComment: mock.fn() } },
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
it('returns the id and the body of the marked comment', async () => {
|
||||||
|
withComments([
|
||||||
|
{ id: 1, body: 'unrelated' },
|
||||||
|
{ id: 42, body: '<!-- marker -->\nold body' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.deepEqual(await findCommentByMarker(123, '<!-- marker -->'), {
|
||||||
|
id: 42,
|
||||||
|
body: '<!-- marker -->\nold body',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns undefined when nothing carries the marker', async () => {
|
||||||
|
withComments([{ id: 1, body: 'unrelated' }]);
|
||||||
|
|
||||||
|
assert.equal(await findCommentByMarker(123, '<!-- marker -->'), undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('updateCommentById', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.env.GITHUB_TOKEN = 'token';
|
||||||
|
process.env.GITHUB_REPOSITORY = 'n8n-io/n8n';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.env = { ...ORIGINAL_ENV };
|
||||||
|
});
|
||||||
|
|
||||||
|
// This is the whole point of the helper: a heartbeat must not paginate every
|
||||||
|
// comment on the PR once a minute.
|
||||||
|
it('edits the comment without listing any', async () => {
|
||||||
|
const updateComment = mock.fn(async () => {});
|
||||||
|
const paginate = mock.fn(async () => []);
|
||||||
|
octokitImpl = () => ({
|
||||||
|
paginate,
|
||||||
|
rest: { issues: { listComments: {}, createComment: mock.fn(), updateComment } },
|
||||||
|
});
|
||||||
|
|
||||||
|
await updateCommentById(42, 'next body');
|
||||||
|
|
||||||
|
assert.equal(paginate.mock.calls.length, 0);
|
||||||
|
assert.deepEqual(updateComment.mock.calls[0].arguments[0], {
|
||||||
|
owner: 'n8n-io',
|
||||||
|
repo: 'n8n',
|
||||||
|
comment_id: 42,
|
||||||
|
body: 'next body',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('postOrUpdateComment', () => {
|
describe('postOrUpdateComment', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env.GITHUB_TOKEN = 'token';
|
process.env.GITHUB_TOKEN = 'token';
|
||||||
|
|
@ -33,7 +136,7 @@ describe('postOrUpdateComment', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates a new comment when no existing bot-marker comment is found', async () => {
|
it('creates a new comment when no existing bot-marker comment is found', async () => {
|
||||||
const createComment = mock.fn(async () => {});
|
const createComment = mock.fn(async () => ({ data: { id: 7 } }));
|
||||||
const updateComment = mock.fn(async () => {});
|
const updateComment = mock.fn(async () => {});
|
||||||
const paginate = mock.fn(async () => [{ id: 1, body: 'unrelated comment' }]);
|
const paginate = mock.fn(async () => [{ id: 1, body: 'unrelated comment' }]);
|
||||||
octokitImpl = () => ({
|
octokitImpl = () => ({
|
||||||
|
|
@ -47,8 +150,9 @@ describe('postOrUpdateComment', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await postOrUpdateComment(123, 'new body', '<!-- marker -->');
|
const id = await postOrUpdateComment(123, 'new body', '<!-- marker -->');
|
||||||
|
|
||||||
|
assert.equal(id, 7);
|
||||||
assert.equal(updateComment.mock.calls.length, 0);
|
assert.equal(updateComment.mock.calls.length, 0);
|
||||||
assert.equal(createComment.mock.calls.length, 1);
|
assert.equal(createComment.mock.calls.length, 1);
|
||||||
assert.deepEqual(createComment.mock.calls[0].arguments[0], {
|
assert.deepEqual(createComment.mock.calls[0].arguments[0], {
|
||||||
|
|
@ -66,7 +170,7 @@ describe('postOrUpdateComment', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates the existing comment when a bot-marker comment is found', async () => {
|
it('updates the existing comment when a bot-marker comment is found', async () => {
|
||||||
const createComment = mock.fn(async () => {});
|
const createComment = mock.fn(async () => ({ data: { id: 7 } }));
|
||||||
const updateComment = mock.fn(async () => {});
|
const updateComment = mock.fn(async () => {});
|
||||||
octokitImpl = () => ({
|
octokitImpl = () => ({
|
||||||
paginate: mock.fn(async () => [{ id: 42, body: '<!-- marker -->\nold body' }]),
|
paginate: mock.fn(async () => [{ id: 42, body: '<!-- marker -->\nold body' }]),
|
||||||
|
|
@ -79,8 +183,9 @@ describe('postOrUpdateComment', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await postOrUpdateComment(123, 'updated body', '<!-- marker -->');
|
const id = await postOrUpdateComment(123, 'updated body', '<!-- marker -->');
|
||||||
|
|
||||||
|
assert.equal(id, 42);
|
||||||
assert.equal(createComment.mock.calls.length, 0);
|
assert.equal(createComment.mock.calls.length, 0);
|
||||||
assert.equal(updateComment.mock.calls.length, 1);
|
assert.equal(updateComment.mock.calls.length, 1);
|
||||||
assert.deepEqual(updateComment.mock.calls[0].arguments[0], {
|
assert.deepEqual(updateComment.mock.calls[0].arguments[0], {
|
||||||
|
|
@ -129,3 +234,38 @@ describe('writeGithubOutput', () => {
|
||||||
assert.equal(existsSync(outputPath), false);
|
assert.equal(existsSync(outputPath), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('initGithub', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.env.GITHUB_REPOSITORY = 'n8n-io/n8n';
|
||||||
|
delete process.env.GITHUB_TOKEN;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
setOctokit(null);
|
||||||
|
process.env = { ...ORIGINAL_ENV };
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses the injected client and needs no token', () => {
|
||||||
|
const injected = { rest: {} };
|
||||||
|
setOctokit(injected);
|
||||||
|
|
||||||
|
const result = initGithub();
|
||||||
|
|
||||||
|
assert.equal(result.octokit, injected);
|
||||||
|
assert.equal(result.owner, 'n8n-io');
|
||||||
|
assert.equal(result.repo, 'n8n');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('builds a client from GITHUB_TOKEN when nothing is injected', () => {
|
||||||
|
const built = { rest: {} };
|
||||||
|
octokitImpl = () => built;
|
||||||
|
process.env.GITHUB_TOKEN = 'token';
|
||||||
|
|
||||||
|
assert.equal(initGithub().octokit, built);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('requires GITHUB_TOKEN when nothing is injected', () => {
|
||||||
|
assert.throws(() => initGithub(), /GITHUB_TOKEN/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
49
.github/scripts/glob.mjs
vendored
Normal file
49
.github/scripts/glob.mjs
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
/**
|
||||||
|
* Minimal glob matcher for changed-file paths.
|
||||||
|
*
|
||||||
|
* Supports `**` (any number of path segments), `*` (any run of characters
|
||||||
|
* inside one segment) and literal text. Dot segments match like any other,
|
||||||
|
* so patterns reach files under `.github/`. Only node builtins, so scripts
|
||||||
|
* that run through `run-workflow-script` can use it without an install.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type { Map<string, RegExp> } */
|
||||||
|
const cache = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string } pattern
|
||||||
|
* @returns { RegExp }
|
||||||
|
*/
|
||||||
|
export function globToRegExp(pattern) {
|
||||||
|
const cached = cache.get(pattern);
|
||||||
|
if (cached) return cached;
|
||||||
|
|
||||||
|
let source = '';
|
||||||
|
const segments = pattern.split('/');
|
||||||
|
for (const [index, segment] of segments.entries()) {
|
||||||
|
const last = index === segments.length - 1;
|
||||||
|
if (segment === '**') {
|
||||||
|
// `**/` matches zero or more segments; a trailing `**` matches the rest.
|
||||||
|
source += last ? '.*' : '(?:[^/]+/)*';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
source += segment
|
||||||
|
.split('*')
|
||||||
|
.map((literal) => literal.replace(/[.+?^${}()|[\]\\]/g, '\\$&'))
|
||||||
|
.join('[^/]*');
|
||||||
|
if (!last) source += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
const regExp = new RegExp(`^${source}$`);
|
||||||
|
cache.set(pattern, regExp);
|
||||||
|
return regExp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string } file Repository-relative path with `/` separators.
|
||||||
|
* @param { string } pattern
|
||||||
|
* @returns { boolean }
|
||||||
|
*/
|
||||||
|
export function matchesGlob(file, pattern) {
|
||||||
|
return globToRegExp(pattern).test(file);
|
||||||
|
}
|
||||||
81
.github/scripts/glob.test.mjs
vendored
Normal file
81
.github/scripts/glob.test.mjs
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
import { describe, it } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { minimatch } from 'minimatch';
|
||||||
|
|
||||||
|
import { matchesGlob } from './glob.mjs';
|
||||||
|
import { EXCLUDE_PATTERNS } from './quality/check-pr-size.mjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run with:
|
||||||
|
* node --test --experimental-test-module-mocks ./.github/scripts/glob.test.mjs
|
||||||
|
* */
|
||||||
|
|
||||||
|
describe('matchesGlob', () => {
|
||||||
|
it('matches a file extension anywhere in the tree', () => {
|
||||||
|
assert.equal(matchesGlob('a.test.ts', '**/*.test.ts'), true);
|
||||||
|
assert.equal(matchesGlob('packages/cli/src/a.test.ts', '**/*.test.ts'), true);
|
||||||
|
assert.equal(matchesGlob('packages/cli/src/a.ts', '**/*.test.ts'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('matches dot segments', () => {
|
||||||
|
assert.equal(matchesGlob('.github/scripts/a.test.mjs', '**/*.test.mjs'), true);
|
||||||
|
assert.equal(matchesGlob('.github/scripts/glob.mjs', '**/*.test.mjs'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('matches a directory at any depth', () => {
|
||||||
|
assert.equal(matchesGlob('test/a.ts', '**/test/**'), true);
|
||||||
|
assert.equal(matchesGlob('packages/x/test/deep/a.ts', '**/test/**'), true);
|
||||||
|
assert.equal(matchesGlob('packages/x/tests/a.ts', '**/test/**'), false);
|
||||||
|
assert.equal(matchesGlob('packages/x/testing/a.ts', '**/test/**'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('matches a prefix pattern', () => {
|
||||||
|
assert.equal(matchesGlob('packages/quality/testing/playwright/a.ts', 'packages/quality/**'), true);
|
||||||
|
assert.equal(matchesGlob('packages/quality', 'packages/quality/**'), false);
|
||||||
|
assert.equal(matchesGlob('packages/cli/a.ts', 'packages/quality/**'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('matches a literal path only exactly', () => {
|
||||||
|
assert.equal(matchesGlob('pnpm-lock.yaml', 'pnpm-lock.yaml'), true);
|
||||||
|
assert.equal(matchesGlob('packages/cli/pnpm-lock.yaml', 'pnpm-lock.yaml'), false);
|
||||||
|
assert.equal(matchesGlob('pnpm-lockXyaml', 'pnpm-lock.yaml'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps `*` inside one segment', () => {
|
||||||
|
assert.equal(matchesGlob('a/b.snap', '**/*.snap'), true);
|
||||||
|
assert.equal(matchesGlob('a/b/c.md', 'a/*.md'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('agrees with minimatch on the PR size patterns', () => {
|
||||||
|
const files = [
|
||||||
|
'packages/cli/src/a.ts',
|
||||||
|
'packages/cli/src/a.test.ts',
|
||||||
|
'packages/cli/test/a.ts',
|
||||||
|
'packages/cli/__tests__/a.ts',
|
||||||
|
'packages/cli/__snapshots__/a.ts.snap',
|
||||||
|
'packages/nodes-base/nodes/Foo/test/fixtures/a.json',
|
||||||
|
'packages/frontend/editor-ui/src/__mocks__/a.ts',
|
||||||
|
'packages/quality/testing/playwright/a.ts',
|
||||||
|
'packages/quality',
|
||||||
|
'.github/scripts/glob.test.mjs',
|
||||||
|
'.github/workflows/ci.yml',
|
||||||
|
'a/.hidden/b.spec.js',
|
||||||
|
'pnpm-lock.yaml',
|
||||||
|
'packages/cli/pnpm-lock.yaml',
|
||||||
|
'README.md',
|
||||||
|
'docs/a.mdx',
|
||||||
|
'src/tests.ts',
|
||||||
|
'src/test.ts',
|
||||||
|
'src/testing/a.ts',
|
||||||
|
];
|
||||||
|
for (const pattern of EXCLUDE_PATTERNS) {
|
||||||
|
for (const file of files) {
|
||||||
|
assert.equal(
|
||||||
|
matchesGlob(file, pattern),
|
||||||
|
minimatch(file, pattern, { dot: true }),
|
||||||
|
`${file} against ${pattern}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
105
.github/scripts/nightly-sbom-context.mjs
vendored
Normal file
105
.github/scripts/nightly-sbom-context.mjs
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { execFileSync } from 'node:child_process';
|
||||||
|
import { appendFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
const MAX_AGE_MS = 6 * 60 * 60 * 1000;
|
||||||
|
const POLL_INTERVAL_MS = 5 * 60 * 1000;
|
||||||
|
const POLL_ATTEMPTS = 25;
|
||||||
|
|
||||||
|
function writeOutput(name, value) {
|
||||||
|
if (!process.env.GITHUB_OUTPUT) throw new Error('GITHUB_OUTPUT is not set.');
|
||||||
|
appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLatestScheduledRun() {
|
||||||
|
const output = execFileSync(
|
||||||
|
'gh',
|
||||||
|
[
|
||||||
|
'run',
|
||||||
|
'list',
|
||||||
|
'--repo',
|
||||||
|
process.env.GITHUB_REPOSITORY,
|
||||||
|
'--workflow',
|
||||||
|
'docker-build-push.yml',
|
||||||
|
'--event',
|
||||||
|
'schedule',
|
||||||
|
'--limit',
|
||||||
|
'1',
|
||||||
|
'--json',
|
||||||
|
'conclusion,createdAt,headSha,status',
|
||||||
|
],
|
||||||
|
{ encoding: 'utf8' },
|
||||||
|
);
|
||||||
|
return JSON.parse(output)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function isFullSha(value) {
|
||||||
|
return /^[0-9a-f]{40}$/.test(value ?? '');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveSource() {
|
||||||
|
if (process.env.GITHUB_EVENT_NAME === 'workflow_dispatch') {
|
||||||
|
if (!isFullSha(process.env.GITHUB_SHA)) throw new Error('GITHUB_SHA is not a full commit SHA.');
|
||||||
|
writeOutput('source_sha', process.env.GITHUB_SHA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let attempt = 1; attempt <= POLL_ATTEMPTS; attempt++) {
|
||||||
|
const run = getLatestScheduledRun();
|
||||||
|
const age = run?.createdAt ? Date.now() - Date.parse(run.createdAt) : MAX_AGE_MS + 1;
|
||||||
|
const isCurrent = age >= 0 && age <= MAX_AGE_MS;
|
||||||
|
|
||||||
|
if (
|
||||||
|
run?.status === 'completed' &&
|
||||||
|
run.conclusion === 'success' &&
|
||||||
|
isFullSha(run.headSha) &&
|
||||||
|
isCurrent
|
||||||
|
) {
|
||||||
|
writeOutput('source_sha', run.headSha);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (run?.status === 'completed' && run.createdAt && isCurrent) {
|
||||||
|
throw new Error(
|
||||||
|
`The current scheduled Docker build completed with conclusion '${run.conclusion}'.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attempt < POLL_ATTEMPTS) {
|
||||||
|
console.log(
|
||||||
|
`Waiting for the current scheduled Docker build (attempt ${attempt} of ${POLL_ATTEMPTS}).`,
|
||||||
|
);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('No successful scheduled Docker build appeared within two hours.');
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveImageTag() {
|
||||||
|
if (process.env.GITHUB_EVENT_NAME === 'workflow_dispatch') {
|
||||||
|
writeOutput('image_tag', 'nightly');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const shortSha = execFileSync('git', ['rev-parse', '--short=7', 'HEAD'], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
}).trim();
|
||||||
|
writeOutput('image_tag', `nightly-${shortSha}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const command = process.argv[2];
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (command === 'resolve-source') {
|
||||||
|
await resolveSource();
|
||||||
|
} else if (command === 'resolve-image-tag') {
|
||||||
|
resolveImageTag();
|
||||||
|
} else {
|
||||||
|
throw new Error('Expected resolve-source or resolve-image-tag.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`::error::${error.message}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
6
.github/scripts/owners/assign-reviewers.mjs
vendored
6
.github/scripts/owners/assign-reviewers.mjs
vendored
|
|
@ -94,7 +94,11 @@ export async function run(pullRequestNumber) {
|
||||||
await removeLabel(pullRequestNumber, AUTO_ASSIGN_LABEL);
|
await removeLabel(pullRequestNumber, AUTO_ASSIGN_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
export async function main() {
|
||||||
const pullRequestNumber = parseInt(ensureEnvVar('PULL_REQUEST_NUMBER'));
|
const pullRequestNumber = parseInt(ensureEnvVar('PULL_REQUEST_NUMBER'));
|
||||||
await run(pullRequestNumber);
|
await run(pullRequestNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
|
await main();
|
||||||
|
}
|
||||||
|
|
|
||||||
6
.github/scripts/owners/owners.mjs
vendored
6
.github/scripts/owners/owners.mjs
vendored
|
|
@ -1,6 +1,8 @@
|
||||||
import { readFileSync, statSync } from "node:fs";
|
import { readFileSync, statSync } from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
|
import { isTestFile } from "../test-files.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef OwnersEntry
|
* @typedef OwnersEntry
|
||||||
* @property { string } pattern
|
* @property { string } pattern
|
||||||
|
|
@ -236,7 +238,7 @@ export function assignOwnership(files, entries) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine which teams must approve the changeset: a team is required when
|
* Determine which teams must approve the changeset: a team is required when
|
||||||
* its `required` entry wins (last-match) for a changed file.
|
* its `required` entry wins (last-match) for a changed non-test file.
|
||||||
*
|
*
|
||||||
* @param { Set<string> } files
|
* @param { Set<string> } files
|
||||||
* @param { OwnersEntry[] } entries
|
* @param { OwnersEntry[] } entries
|
||||||
|
|
@ -247,6 +249,8 @@ export function resolveRequiredTeams(files, entries) {
|
||||||
const teamToFiles = new Map();
|
const teamToFiles = new Map();
|
||||||
|
|
||||||
for (const file of [...files].sort()) {
|
for (const file of [...files].sort()) {
|
||||||
|
if (isTestFile(file)) continue;
|
||||||
|
|
||||||
const entry = findOwningEntry(file, entries);
|
const entry = findOwningEntry(file, entries);
|
||||||
if (!entry?.required) continue;
|
if (!entry?.required) continue;
|
||||||
|
|
||||||
|
|
|
||||||
16
.github/scripts/owners/owners.test.mjs
vendored
16
.github/scripts/owners/owners.test.mjs
vendored
|
|
@ -293,6 +293,22 @@ describe('resolveRequiredTeams', () => {
|
||||||
assert.equal(result.size, 0);
|
assert.equal(result.size, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignores test files whose winning entry is required', () => {
|
||||||
|
const result = resolveRequiredTeams(
|
||||||
|
new Set([
|
||||||
|
'.github/scripts/check.test.mjs',
|
||||||
|
'.github/workflows/__tests__/check.ts',
|
||||||
|
'.github/workflows/ci.yml',
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
entry({ pattern: '.github/scripts/', team: '@n8n-io/qa-dx', required: true }),
|
||||||
|
entry({ pattern: '.github/workflows/', team: '@n8n-io/qa-dx', required: true }),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(result.get('@n8n-io/qa-dx'), ['.github/workflows/ci.yml']);
|
||||||
|
});
|
||||||
|
|
||||||
it('a later non-required entry overrides an earlier required one', () => {
|
it('a later non-required entry overrides an earlier required one', () => {
|
||||||
const result = resolveRequiredTeams(new Set(['db/migrations/1-init.ts']), [
|
const result = resolveRequiredTeams(new Set(['db/migrations/1-init.ts']), [
|
||||||
entry({ pattern: 'db/', team: '@n8n-io/migrations-review', required: true }),
|
entry({ pattern: 'db/', team: '@n8n-io/migrations-review', required: true }),
|
||||||
|
|
|
||||||
156
.github/scripts/owners/required-reviews.mjs
vendored
156
.github/scripts/owners/required-reviews.mjs
vendored
|
|
@ -1,13 +1,17 @@
|
||||||
/**
|
/**
|
||||||
* Required-review enforcement for OWNERS entries marked `required`.
|
* Required-review enforcement for OWNERS entries marked `required`.
|
||||||
*
|
*
|
||||||
* Computes the teams whose approval the changeset needs (per OWNERS)
|
* Computes the teams whose approval the non-test changes need (per OWNERS)
|
||||||
* and reports the verdict as a "Required Reviews" commit status on the PR
|
* and reports the verdict as a "Required Reviews" commit status on the PR
|
||||||
* head SHA. A ruleset that lists this status as a required check blocks the
|
* head SHA. A ruleset that lists this status as a required check blocks the
|
||||||
* merge until a member of each required team has approved the PR. Merge-queue
|
* merge until a member of each required team has approved the PR. Merge-queue
|
||||||
* runs do not reach this script: the workflow reports success on the queue
|
* runs do not reach this script: the workflow reports success on the queue
|
||||||
* head directly, because entering the queue already required a green status.
|
* head directly, because entering the queue already required a green status.
|
||||||
*
|
*
|
||||||
|
* Every base branch is enforced unless the PR matches a trusted exemption.
|
||||||
|
* Exemptions include configured routes and an authorized large-scale-change
|
||||||
|
* label. An exempt PR reports success without approval evaluation.
|
||||||
|
*
|
||||||
* The job itself always succeeds when the evaluation runs; the commit status
|
* The job itself always succeeds when the evaluation runs; the commit status
|
||||||
* carries the verdict. The status is set to pending before the evaluation
|
* carries the verdict. The status is set to pending before the evaluation
|
||||||
* starts, so a crash (e.g. the team membership API is unavailable) cannot
|
* starts, so a crash (e.g. the team membership API is unavailable) cannot
|
||||||
|
|
@ -17,15 +21,37 @@
|
||||||
import {
|
import {
|
||||||
getChangedFiles,
|
getChangedFiles,
|
||||||
getEventFromGithubEventPath,
|
getEventFromGithubEventPath,
|
||||||
|
getPrEvents,
|
||||||
getPrReviews,
|
getPrReviews,
|
||||||
getPullRequestById,
|
getPullRequestById,
|
||||||
isTeamMember,
|
isTeamMember,
|
||||||
|
listOpenPullRequestsByHead,
|
||||||
|
readPrLabels,
|
||||||
setCommitStatus,
|
setCommitStatus,
|
||||||
} from '../github-helpers.mjs';
|
} from '../github-helpers.mjs';
|
||||||
import { parseOwnersFile, resolveRequiredTeams, teamHandleToSlug } from './owners.mjs';
|
import { parseOwnersFile, resolveRequiredTeams, teamHandleToSlug } from './owners.mjs';
|
||||||
|
|
||||||
export const STATUS_CONTEXT = 'Required Reviews';
|
export const STATUS_CONTEXT = 'Required Reviews';
|
||||||
const TARGET_BRANCH = 'master';
|
export const LARGE_SCALE_CHANGE_LABEL = 'large-scale-change';
|
||||||
|
export const LARGE_SCALE_CHANGES_TEAM = 'large-scale-changes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PR routes that skip the evaluation. Each entry is `<head> -> <base>` or
|
||||||
|
* just `<base>` (any head). `*` matches any run of characters, including
|
||||||
|
* `/`. Only heads in this repository qualify; a fork branch with a
|
||||||
|
* matching name does not.
|
||||||
|
*
|
||||||
|
* Add a route here only when every commit it carries was already reviewed
|
||||||
|
* elsewhere, like the master-to-3.x sync, whose commits landed on master.
|
||||||
|
*/
|
||||||
|
export const REQUIRED_REVIEW_EXEMPTIONS = ['sync/master-to-3x -> 3.x'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef ExemptRoute
|
||||||
|
* @property { string } head Glob for the head branch.
|
||||||
|
* @property { string } base Glob for the base branch.
|
||||||
|
* @property { string } source The entry as written.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A PR review as returned by the reviews API.
|
* A PR review as returned by the reviews API.
|
||||||
|
|
@ -36,17 +62,68 @@ const TARGET_BRANCH = 'master';
|
||||||
* @property { string } [submitted_at]
|
* @property { string } [submitted_at]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string } entry `<head> -> <base>` or `<base>`
|
||||||
|
* @returns { ExemptRoute }
|
||||||
|
*/
|
||||||
|
export function parseExemption(entry) {
|
||||||
|
const parts = entry.split('->').map((part) => part.trim());
|
||||||
|
if (parts.length > 2 || parts.some((part) => part === '')) {
|
||||||
|
throw new Error(`Invalid exemption "${entry}": expected "<head> -> <base>" or "<base>"`);
|
||||||
|
}
|
||||||
|
const [head, base] = parts.length === 2 ? parts : ['*', parts[0]];
|
||||||
|
return { head, base, source: entry };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string } ref Branch name.
|
||||||
|
* @param { string } pattern Glob where `*` matches any run of characters.
|
||||||
|
* @returns { boolean }
|
||||||
|
*/
|
||||||
|
export function matchesBranchPattern(ref, pattern) {
|
||||||
|
const escaped = pattern.split('*').map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
||||||
|
return new RegExp(`^${escaped.join('.*')}$`).test(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { { head: { ref: string, repo: { full_name: string } | null }, base: { ref: string, repo: { full_name: string } } } } pullRequest
|
||||||
|
* @param { string[] } [exemptions]
|
||||||
|
* @returns { ExemptRoute | undefined } The first matching route.
|
||||||
|
*/
|
||||||
|
export function findExemption(pullRequest, exemptions = REQUIRED_REVIEW_EXEMPTIONS) {
|
||||||
|
// A fork can name its branch anything, so the head must live in this repo.
|
||||||
|
if (pullRequest.head.repo?.full_name !== pullRequest.base.repo.full_name) return undefined;
|
||||||
|
|
||||||
|
return exemptions
|
||||||
|
.map(parseExemption)
|
||||||
|
.find(
|
||||||
|
(route) =>
|
||||||
|
matchesBranchPattern(pullRequest.head.ref, route.head) &&
|
||||||
|
matchesBranchPattern(pullRequest.base.ref, route.base),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the PR number from the triggering event.
|
* Resolve the PR number from the triggering event.
|
||||||
*
|
*
|
||||||
|
* A workflow_run event carries no PR: the PR is looked up from the
|
||||||
|
* triggering run's head. Only an open PR whose head SHA is the run's head
|
||||||
|
* SHA counts; several PRs can share a head branch.
|
||||||
|
*
|
||||||
* @param { string } eventName
|
* @param { string } eventName
|
||||||
* @param { any } event Parsed GITHUB_EVENT_PATH payload.
|
* @param { any } event Parsed GITHUB_EVENT_PATH payload.
|
||||||
* @param { string | undefined } pullRequestNumberEnv PULL_REQUEST_NUMBER (workflow_dispatch input).
|
* @param { string | undefined } pullRequestNumberEnv PULL_REQUEST_NUMBER (workflow_dispatch input).
|
||||||
* @returns { number }
|
* @returns { Promise<number | undefined> } undefined when the event has no open PR to evaluate.
|
||||||
*/
|
*/
|
||||||
export function resolvePullRequestNumber(eventName, event, pullRequestNumberEnv) {
|
export async function resolvePullRequestNumber(eventName, event, pullRequestNumberEnv) {
|
||||||
if (event?.pull_request?.number) return event.pull_request.number;
|
if (event?.pull_request?.number) return event.pull_request.number;
|
||||||
|
|
||||||
|
if (eventName === 'workflow_run' && event?.workflow_run) {
|
||||||
|
const { head_sha: sha, head_branch: branch, head_repository: headRepository } = event.workflow_run;
|
||||||
|
const candidates = await listOpenPullRequestsByHead(headRepository.owner.login, branch);
|
||||||
|
return candidates.find((pullRequest) => pullRequest.head.sha === sha)?.number;
|
||||||
|
}
|
||||||
|
|
||||||
const parsed = parseInt(pullRequestNumberEnv ?? '');
|
const parsed = parseInt(pullRequestNumberEnv ?? '');
|
||||||
if (Number.isNaN(parsed)) {
|
if (Number.isNaN(parsed)) {
|
||||||
throw new Error(`Cannot resolve a PR number for event "${eventName}"`);
|
throw new Error(`Cannot resolve a PR number for event "${eventName}"`);
|
||||||
|
|
@ -88,10 +165,36 @@ export function collectApprovers(reviews) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the team member who applied the active large-scale-change label.
|
||||||
|
* The current membership check makes the exemption expire when the actor
|
||||||
|
* leaves the team.
|
||||||
|
*
|
||||||
|
* @param { number } pullRequestNumber
|
||||||
|
* @param {{ labels?: Array<string | { name: string }> }} pullRequest
|
||||||
|
* @returns { Promise<string | undefined> }
|
||||||
|
*/
|
||||||
|
export async function findLargeScaleChangeExemption(pullRequestNumber, pullRequest) {
|
||||||
|
if (!readPrLabels(pullRequest).includes(LARGE_SCALE_CHANGE_LABEL)) return undefined;
|
||||||
|
|
||||||
|
const labelEvents = (await getPrEvents(pullRequestNumber)).filter(
|
||||||
|
(event) =>
|
||||||
|
['labeled', 'unlabeled'].includes(event.event) &&
|
||||||
|
event.label?.name === LARGE_SCALE_CHANGE_LABEL,
|
||||||
|
);
|
||||||
|
const latestEvent = labelEvents.at(-1);
|
||||||
|
if (latestEvent?.event !== 'labeled') return undefined;
|
||||||
|
|
||||||
|
const actor = latestEvent.actor?.login;
|
||||||
|
if (!actor) return undefined;
|
||||||
|
|
||||||
|
return (await isTeamMember(LARGE_SCALE_CHANGES_TEAM, actor)) ? actor : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param { string[] } missingTeams Team handles without an approving member.
|
* @param { string[] } missingTeams Team handles without an approving member.
|
||||||
* @param { number } requiredCount Total number of required teams.
|
* @param { number } requiredCount Total number of required teams.
|
||||||
* @returns {{ state: 'success' | 'failure', description: string }}
|
* @returns {{ state: 'success' | 'pending', description: string }}
|
||||||
*/
|
*/
|
||||||
export function buildStatus(missingTeams, requiredCount) {
|
export function buildStatus(missingTeams, requiredCount) {
|
||||||
if (requiredCount === 0) {
|
if (requiredCount === 0) {
|
||||||
|
|
@ -105,9 +208,11 @@ export function buildStatus(missingTeams, requiredCount) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pending, not failure: an unreviewed PR waits, it is not broken. Anything
|
||||||
|
// other than success still blocks the merge.
|
||||||
return {
|
return {
|
||||||
state: 'failure',
|
state: 'pending',
|
||||||
description: `Missing approval from: ${missingTeams.map(teamHandleToSlug).join(', ')}`,
|
description: `Waiting for approval from: ${missingTeams.map(teamHandleToSlug).join(', ')}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +224,7 @@ function statusTargetUrl() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param { number } pullRequestNumber
|
* @param { number } pullRequestNumber
|
||||||
* @returns { Promise<{ state: 'success' | 'failure', description: string }> }
|
* @returns { Promise<{ state: 'success' | 'pending', description: string }> }
|
||||||
*/
|
*/
|
||||||
async function evaluateRequiredReviews(pullRequestNumber) {
|
async function evaluateRequiredReviews(pullRequestNumber) {
|
||||||
const changedFiles = await getChangedFiles(pullRequestNumber);
|
const changedFiles = await getChangedFiles(pullRequestNumber);
|
||||||
|
|
@ -158,18 +263,16 @@ export async function run() {
|
||||||
const eventName = process.env.GITHUB_EVENT_NAME ?? 'workflow_dispatch';
|
const eventName = process.env.GITHUB_EVENT_NAME ?? 'workflow_dispatch';
|
||||||
const event = getEventFromGithubEventPath();
|
const event = getEventFromGithubEventPath();
|
||||||
|
|
||||||
const pullRequestNumber = resolvePullRequestNumber(
|
const pullRequestNumber = await resolvePullRequestNumber(
|
||||||
eventName,
|
eventName,
|
||||||
event,
|
event,
|
||||||
process.env.PULL_REQUEST_NUMBER,
|
process.env.PULL_REQUEST_NUMBER,
|
||||||
);
|
);
|
||||||
const pullRequest = await getPullRequestById(pullRequestNumber);
|
if (pullRequestNumber === undefined) {
|
||||||
|
console.log(`No open PR for the ${eventName} head; nothing to evaluate.`);
|
||||||
if (pullRequest.base.ref !== TARGET_BRANCH) {
|
|
||||||
console.log(`PR #${pullRequestNumber} targets "${pullRequest.base.ref}", not "${TARGET_BRANCH}"; skipping.`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const pullRequest = await getPullRequestById(pullRequestNumber);
|
||||||
const statusSha = pullRequest.head.sha;
|
const statusSha = pullRequest.head.sha;
|
||||||
const targetUrl = statusTargetUrl();
|
const targetUrl = statusTargetUrl();
|
||||||
|
|
||||||
|
|
@ -182,10 +285,27 @@ export async function run() {
|
||||||
targetUrl,
|
targetUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** @type { { state: 'success' | 'failure', description: string } } */
|
/** @type { { state: 'success' | 'pending', description: string } } */
|
||||||
let status;
|
let status;
|
||||||
try {
|
try {
|
||||||
status = await evaluateRequiredReviews(pullRequestNumber);
|
const exemption = findExemption(pullRequest);
|
||||||
|
const largeScaleChangeActor = exemption
|
||||||
|
? undefined
|
||||||
|
: await findLargeScaleChangeExemption(pullRequestNumber, pullRequest);
|
||||||
|
if (exemption) {
|
||||||
|
console.log(`PR #${pullRequestNumber} matches exempt route "${exemption.source}"; skipping the evaluation.`);
|
||||||
|
status = { state: 'success', description: `Exempt route: ${exemption.source}` };
|
||||||
|
} else if (largeScaleChangeActor) {
|
||||||
|
console.log(
|
||||||
|
`PR #${pullRequestNumber} has an authorized ${LARGE_SCALE_CHANGE_LABEL} label from ${largeScaleChangeActor}; skipping the evaluation.`,
|
||||||
|
);
|
||||||
|
status = {
|
||||||
|
state: 'success',
|
||||||
|
description: `Large-scale change exemption by @${largeScaleChangeActor}`,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
status = await evaluateRequiredReviews(pullRequestNumber);
|
||||||
|
}
|
||||||
} catch (evaluationError) {
|
} catch (evaluationError) {
|
||||||
// Best effort: nicer than a stuck pending status. The pending status
|
// Best effort: nicer than a stuck pending status. The pending status
|
||||||
// already blocks the merge if this write fails too.
|
// already blocks the merge if this write fails too.
|
||||||
|
|
@ -208,6 +328,8 @@ export async function run() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const main = run;
|
||||||
|
|
||||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
await run();
|
await main();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
360
.github/scripts/owners/required-reviews.test.mjs
vendored
360
.github/scripts/owners/required-reviews.test.mjs
vendored
|
|
@ -15,19 +15,28 @@ let getPullRequestByIdImpl = async () => ({});
|
||||||
let getChangedFilesImpl = async () => new Set();
|
let getChangedFilesImpl = async () => new Set();
|
||||||
/** @type {(pullRequestNumber: number) => Promise<any[]>} */
|
/** @type {(pullRequestNumber: number) => Promise<any[]>} */
|
||||||
let getPrReviewsImpl = async () => [];
|
let getPrReviewsImpl = async () => [];
|
||||||
|
/** @type {(pullRequestNumber: number) => Promise<any[]>} */
|
||||||
|
let getPrEventsImpl = async () => [];
|
||||||
/** @type {(teamSlug: string, username: string) => Promise<boolean>} */
|
/** @type {(teamSlug: string, username: string) => Promise<boolean>} */
|
||||||
let isTeamMemberImpl = async () => false;
|
let isTeamMemberImpl = async () => false;
|
||||||
/** @type {(sha: string, status: any) => Promise<void>} */
|
/** @type {(sha: string, status: any) => Promise<void>} */
|
||||||
let setCommitStatusImpl = async () => {};
|
let setCommitStatusImpl = async () => {};
|
||||||
|
/** @type {(headOwner: string, headBranch: string) => Promise<any[]>} */
|
||||||
|
let listOpenPullRequestsByHeadImpl = async () => [];
|
||||||
|
|
||||||
mock.module('../github-helpers.mjs', {
|
mock.module('../github-helpers.mjs', {
|
||||||
namedExports: {
|
namedExports: {
|
||||||
getEventFromGithubEventPath: () => eventImpl(),
|
getEventFromGithubEventPath: () => eventImpl(),
|
||||||
getPullRequestById: (n) => getPullRequestByIdImpl(n),
|
getPullRequestById: (n) => getPullRequestByIdImpl(n),
|
||||||
getChangedFiles: (n) => getChangedFilesImpl(n),
|
getChangedFiles: (n) => getChangedFilesImpl(n),
|
||||||
|
getPrEvents: (n) => getPrEventsImpl(n),
|
||||||
getPrReviews: (n) => getPrReviewsImpl(n),
|
getPrReviews: (n) => getPrReviewsImpl(n),
|
||||||
isTeamMember: (slug, username) => isTeamMemberImpl(slug, username),
|
isTeamMember: (slug, username) => isTeamMemberImpl(slug, username),
|
||||||
setCommitStatus: (sha, status) => setCommitStatusImpl(sha, status),
|
setCommitStatus: (sha, status) => setCommitStatusImpl(sha, status),
|
||||||
|
listOpenPullRequestsByHead: (headOwner, headBranch) =>
|
||||||
|
listOpenPullRequestsByHeadImpl(headOwner, headBranch),
|
||||||
|
readPrLabels: (pullRequest) =>
|
||||||
|
(pullRequest.labels ?? []).map((label) => (typeof label === 'string' ? label : label.name)),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -46,28 +55,153 @@ mock.module('./owners.mjs', {
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
REQUIRED_REVIEW_EXEMPTIONS,
|
||||||
|
LARGE_SCALE_CHANGE_LABEL,
|
||||||
|
LARGE_SCALE_CHANGES_TEAM,
|
||||||
STATUS_CONTEXT,
|
STATUS_CONTEXT,
|
||||||
buildStatus,
|
buildStatus,
|
||||||
collectApprovers,
|
collectApprovers,
|
||||||
|
findLargeScaleChangeExemption,
|
||||||
|
findExemption,
|
||||||
latestReviewStates,
|
latestReviewStates,
|
||||||
|
matchesBranchPattern,
|
||||||
|
parseExemption,
|
||||||
resolvePullRequestNumber,
|
resolvePullRequestNumber,
|
||||||
run,
|
run,
|
||||||
} = await import('./required-reviews.mjs');
|
} = await import('./required-reviews.mjs');
|
||||||
|
|
||||||
|
const REPO = 'n8n-io/n8n';
|
||||||
|
|
||||||
|
/** @param {string} head @param {string} base @param {string} [headRepo] */
|
||||||
|
function pullRequestFor(head, base, headRepo = REPO) {
|
||||||
|
return {
|
||||||
|
head: { ref: head, sha: 'head-sha', repo: { full_name: headRepo } },
|
||||||
|
base: { ref: base, repo: { full_name: REPO } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('parseExemption', () => {
|
||||||
|
it('splits a "<head> -> <base>" route', () => {
|
||||||
|
assert.deepEqual(parseExemption('sync/master-to-3x -> 3.x'), {
|
||||||
|
head: 'sync/master-to-3x',
|
||||||
|
base: '3.x',
|
||||||
|
source: 'sync/master-to-3x -> 3.x',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('treats a bare "<base>" as any head', () => {
|
||||||
|
assert.deepEqual(parseExemption('release/*'), { head: '*', base: 'release/*', source: 'release/*' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects malformed routes', () => {
|
||||||
|
assert.throws(() => parseExemption('a -> b -> c'), /Invalid exemption/);
|
||||||
|
assert.throws(() => parseExemption(' -> 3.x'), /Invalid exemption/);
|
||||||
|
assert.throws(() => parseExemption('3.x -> '), /Invalid exemption/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('accepts every configured exemption', () => {
|
||||||
|
for (const entry of REQUIRED_REVIEW_EXEMPTIONS) parseExemption(entry);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('matchesBranchPattern', () => {
|
||||||
|
it('matches whole branch names', () => {
|
||||||
|
assert.equal(matchesBranchPattern('3.x', '3.x'), true);
|
||||||
|
assert.equal(matchesBranchPattern('3.xy', '3.x'), false);
|
||||||
|
assert.equal(matchesBranchPattern('v3.x', '3.x'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('treats "." as a literal', () => {
|
||||||
|
assert.equal(matchesBranchPattern('3ax', '3.x'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('expands "*" across path separators', () => {
|
||||||
|
assert.equal(matchesBranchPattern('release/2.39.5', 'release/*'), true);
|
||||||
|
assert.equal(matchesBranchPattern('release/2.39.5/hotfix', 'release/*'), true);
|
||||||
|
assert.equal(matchesBranchPattern('anything', '*'), true);
|
||||||
|
assert.equal(matchesBranchPattern('release-candidate/2.40.0', 'release/*'), false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findExemption', () => {
|
||||||
|
const exemptions = ['sync/master-to-3x -> 3.x', 'release/*'];
|
||||||
|
|
||||||
|
it('finds the route for a matching head and base', () => {
|
||||||
|
const route = findExemption(pullRequestFor('sync/master-to-3x', '3.x'), exemptions);
|
||||||
|
assert.equal(route?.source, 'sync/master-to-3x -> 3.x');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns nothing when only the base matches', () => {
|
||||||
|
assert.equal(findExemption(pullRequestFor('feature/x', '3.x'), exemptions), undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns nothing when only the head matches', () => {
|
||||||
|
assert.equal(findExemption(pullRequestFor('sync/master-to-3x', 'master'), exemptions), undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('matches a bare base route for any head', () => {
|
||||||
|
const route = findExemption(pullRequestFor('feature/x', 'release/2.39.5'), exemptions);
|
||||||
|
assert.equal(route?.source, 'release/*');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores heads from another repository', () => {
|
||||||
|
const fromFork = pullRequestFor('sync/master-to-3x', '3.x', 'someone/n8n');
|
||||||
|
assert.equal(findExemption(fromFork, exemptions), undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores heads whose repository is gone', () => {
|
||||||
|
const pullRequest = pullRequestFor('sync/master-to-3x', '3.x');
|
||||||
|
pullRequest.head.repo = null;
|
||||||
|
assert.equal(findExemption(pullRequest, exemptions), undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('resolvePullRequestNumber', () => {
|
describe('resolvePullRequestNumber', () => {
|
||||||
it('reads the PR number from pull_request payloads', () => {
|
/** A workflow_run payload for a run on `owner/branch` at `sha`. */
|
||||||
|
function workflowRunEvent(owner, branch, sha) {
|
||||||
|
return { workflow_run: { head_sha: sha, head_branch: branch, head_repository: { owner: { login: owner } } } };
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
listOpenPullRequestsByHeadImpl = async () => [];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reads the PR number from pull_request payloads', async () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
resolvePullRequestNumber('pull_request', { pull_request: { number: 42 } }, undefined),
|
await resolvePullRequestNumber('pull_request_target', { pull_request: { number: 42 } }, undefined),
|
||||||
42,
|
42,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to the PULL_REQUEST_NUMBER env value for workflow_dispatch', () => {
|
it('falls back to the PULL_REQUEST_NUMBER env value for workflow_dispatch', async () => {
|
||||||
assert.equal(resolvePullRequestNumber('workflow_dispatch', {}, '7'), 7);
|
assert.equal(await resolvePullRequestNumber('workflow_dispatch', {}, '7'), 7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when no source yields a PR number', () => {
|
it('rejects when no source yields a PR number', async () => {
|
||||||
assert.throws(() => resolvePullRequestNumber('workflow_dispatch', {}, undefined), /Cannot resolve/);
|
await assert.rejects(resolvePullRequestNumber('workflow_dispatch', {}, undefined), /Cannot resolve/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('looks up the open PR for a workflow_run head', async () => {
|
||||||
|
const listOpenPullRequestsByHead = mock.fn(async () => [
|
||||||
|
{ number: 11, head: { sha: 'old-sha' } },
|
||||||
|
{ number: 12, head: { sha: 'run-sha' } },
|
||||||
|
]);
|
||||||
|
listOpenPullRequestsByHeadImpl = listOpenPullRequestsByHead;
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await resolvePullRequestNumber('workflow_run', workflowRunEvent('forker', 'fix/x', 'run-sha'), undefined),
|
||||||
|
12,
|
||||||
|
);
|
||||||
|
assert.deepEqual(listOpenPullRequestsByHead.mock.calls[0].arguments, ['forker', 'fix/x']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns undefined when no open PR has the workflow_run head SHA', async () => {
|
||||||
|
listOpenPullRequestsByHeadImpl = async () => [{ number: 11, head: { sha: 'old-sha' } }];
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await resolvePullRequestNumber('workflow_run', workflowRunEvent('forker', 'fix/x', 'run-sha'), undefined),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -120,6 +254,116 @@ describe('collectApprovers', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('findLargeScaleChangeExemption', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
getPrEventsImpl = async () => [];
|
||||||
|
isTeamMemberImpl = async () => false;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the team member who applied the active label', async () => {
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'ana' } },
|
||||||
|
];
|
||||||
|
isTeamMemberImpl = async (slug, username) =>
|
||||||
|
slug === LARGE_SCALE_CHANGES_TEAM && username === 'ana';
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
'ana',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects a label applied by someone outside the team', async () => {
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'outsider' } },
|
||||||
|
];
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects the exemption when the label event is not available', async () => {
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects the exemption when the label event has no actor', async () => {
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: null },
|
||||||
|
];
|
||||||
|
const isTeamMember = mock.fn(async () => true);
|
||||||
|
isTeamMemberImpl = isTeamMember;
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
assert.equal(isTeamMember.mock.calls.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores events for other labels', async () => {
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'ana' } },
|
||||||
|
{ event: 'labeled', label: { name: 'bug' }, actor: { login: 'outsider' } },
|
||||||
|
{ event: 'unlabeled', label: { name: 'bug' }, actor: { login: 'outsider' } },
|
||||||
|
];
|
||||||
|
isTeamMemberImpl = async (slug, username) =>
|
||||||
|
slug === LARGE_SCALE_CHANGES_TEAM && username === 'ana';
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
'ana',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses the actor from the latest label application', async () => {
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'ana' } },
|
||||||
|
{
|
||||||
|
event: 'unlabeled',
|
||||||
|
label: { name: LARGE_SCALE_CHANGE_LABEL },
|
||||||
|
actor: { login: 'outsider' },
|
||||||
|
},
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'outsider' } },
|
||||||
|
];
|
||||||
|
isTeamMemberImpl = async (slug, username) => username === 'ana';
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects the exemption when the latest event removed the label', async () => {
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'ana' } },
|
||||||
|
{
|
||||||
|
event: 'unlabeled',
|
||||||
|
label: { name: LARGE_SCALE_CHANGE_LABEL },
|
||||||
|
actor: { login: 'outsider' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
isTeamMemberImpl = async (slug, username) => username === 'ana';
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
await findLargeScaleChangeExemption(42, { labels: [{ name: LARGE_SCALE_CHANGE_LABEL }] }),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not inspect events when the label is absent', async () => {
|
||||||
|
const getPrEvents = mock.fn(async () => []);
|
||||||
|
getPrEventsImpl = getPrEvents;
|
||||||
|
|
||||||
|
assert.equal(await findLargeScaleChangeExemption(42, { labels: [] }), undefined);
|
||||||
|
assert.equal(getPrEvents.mock.calls.length, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('buildStatus', () => {
|
describe('buildStatus', () => {
|
||||||
it('succeeds when nothing is required', () => {
|
it('succeeds when nothing is required', () => {
|
||||||
const status = buildStatus([], 0);
|
const status = buildStatus([], 0);
|
||||||
|
|
@ -135,11 +379,11 @@ describe('buildStatus', () => {
|
||||||
assert.match(status.description, /2 teams/);
|
assert.match(status.description, /2 teams/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails with the missing team slugs', () => {
|
it('stays pending with the missing team slugs', () => {
|
||||||
const status = buildStatus(['@n8n-io/qa-dx', '@n8n-io/migrations-review'], 2);
|
const status = buildStatus(['@n8n-io/qa-dx', '@n8n-io/migrations-review'], 2);
|
||||||
|
|
||||||
assert.equal(status.state, 'failure');
|
assert.equal(status.state, 'pending');
|
||||||
assert.equal(status.description, 'Missing approval from: qa-dx, migrations-review');
|
assert.equal(status.description, 'Waiting for approval from: qa-dx, migrations-review');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -152,12 +396,12 @@ describe('run', () => {
|
||||||
|
|
||||||
eventImpl = () => ({ pull_request: { number: 42 } });
|
eventImpl = () => ({ pull_request: { number: 42 } });
|
||||||
getPullRequestByIdImpl = async () => ({
|
getPullRequestByIdImpl = async () => ({
|
||||||
base: { ref: 'master' },
|
...pullRequestFor('feature/x', 'master'),
|
||||||
head: { sha: 'head-sha' },
|
|
||||||
user: { login: 'author' },
|
user: { login: 'author' },
|
||||||
});
|
});
|
||||||
getChangedFilesImpl = async () => new Set(['a.ts']);
|
getChangedFilesImpl = async () => new Set(['a.ts']);
|
||||||
getPrReviewsImpl = async () => [];
|
getPrReviewsImpl = async () => [];
|
||||||
|
getPrEventsImpl = async () => [];
|
||||||
isTeamMemberImpl = async () => false;
|
isTeamMemberImpl = async () => false;
|
||||||
parseOwnersFileImpl = () => [];
|
parseOwnersFileImpl = () => [];
|
||||||
resolveRequiredTeamsImpl = () => new Map();
|
resolveRequiredTeamsImpl = () => new Map();
|
||||||
|
|
@ -181,7 +425,7 @@ describe('run', () => {
|
||||||
assert.equal(status.state, 'success');
|
assert.equal(status.state, 'success');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets a failure status when a required team has not approved', async () => {
|
it('sets a pending status when a required team has not approved', async () => {
|
||||||
resolveRequiredTeamsImpl = () => new Map([['@n8n-io/qa-dx', ['a.ts']]]);
|
resolveRequiredTeamsImpl = () => new Map([['@n8n-io/qa-dx', ['a.ts']]]);
|
||||||
getPrReviewsImpl = async () => [
|
getPrReviewsImpl = async () => [
|
||||||
{ user: { login: 'outsider' }, state: 'APPROVED', submitted_at: '2026-01-01T00:00:00Z' },
|
{ user: { login: 'outsider' }, state: 'APPROVED', submitted_at: '2026-01-01T00:00:00Z' },
|
||||||
|
|
@ -191,8 +435,8 @@ describe('run', () => {
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
assert.equal(status.state, 'failure');
|
assert.equal(status.state, 'pending');
|
||||||
assert.match(status.description, /Missing approval from: qa-dx/);
|
assert.match(status.description, /Waiting for approval from: qa-dx/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets an error status and rethrows when the evaluation fails', async () => {
|
it('sets an error status and rethrows when the evaluation fails', async () => {
|
||||||
|
|
@ -250,7 +494,7 @@ describe('run', () => {
|
||||||
|
|
||||||
assert.equal(isTeamMember.mock.calls.length, 0);
|
assert.equal(isTeamMember.mock.calls.length, 0);
|
||||||
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
assert.equal(status.state, 'failure');
|
assert.equal(status.state, 'pending');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not count an approval that was later dismissed', async () => {
|
it('does not count an approval that was later dismissed', async () => {
|
||||||
|
|
@ -264,18 +508,94 @@ describe('run', () => {
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
assert.equal(status.state, 'failure');
|
assert.equal(status.state, 'pending');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('skips PRs that do not target master without setting a status', async () => {
|
it('writes no status for a workflow_run head without an open PR', async () => {
|
||||||
getPullRequestByIdImpl = async () => ({
|
process.env.GITHUB_EVENT_NAME = 'workflow_run';
|
||||||
base: { ref: 'release-candidate/2.9.x' },
|
eventImpl = () => ({
|
||||||
head: { sha: 'head-sha' },
|
workflow_run: { head_sha: 'gone-sha', head_branch: 'fix/x', head_repository: { owner: { login: 'forker' } } },
|
||||||
});
|
});
|
||||||
|
listOpenPullRequestsByHeadImpl = async () => [];
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
assert.equal(setCommitStatus.mock.calls.length, 0);
|
assert.equal(setCommitStatus.mock.calls.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('evaluates PRs into branches other than master', async () => {
|
||||||
|
getPullRequestByIdImpl = async () => pullRequestFor('feature/x', 'release-candidate/2.9.x');
|
||||||
|
resolveRequiredTeamsImpl = () => new Map([['@n8n-io/qa-dx', ['a.ts']]]);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
|
assert.equal(status.state, 'pending');
|
||||||
|
assert.match(status.description, /Waiting for approval from: qa-dx/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports success without evaluating a PR on an exempt route', async () => {
|
||||||
|
getPullRequestByIdImpl = async () => pullRequestFor('sync/master-to-3x', '3.x');
|
||||||
|
const getChangedFiles = mock.fn(async () => new Set(['a.ts']));
|
||||||
|
getChangedFilesImpl = getChangedFiles;
|
||||||
|
resolveRequiredTeamsImpl = () => new Map([['@n8n-io/qa-dx', ['a.ts']]]);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
assert.equal(getChangedFiles.mock.calls.length, 0);
|
||||||
|
assert.equal(setCommitStatus.mock.calls.length, 2);
|
||||||
|
assert.equal(setCommitStatus.mock.calls[0].arguments[1].state, 'pending');
|
||||||
|
const [, status] = setCommitStatus.mock.calls[1].arguments;
|
||||||
|
assert.equal(status.state, 'success');
|
||||||
|
assert.equal(status.description, 'Exempt route: sync/master-to-3x -> 3.x');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports success without evaluating an authorized large-scale change', async () => {
|
||||||
|
getPullRequestByIdImpl = async () => ({
|
||||||
|
...pullRequestFor('feature/x', 'master'),
|
||||||
|
labels: [{ name: LARGE_SCALE_CHANGE_LABEL }],
|
||||||
|
});
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'ana' } },
|
||||||
|
];
|
||||||
|
isTeamMemberImpl = async (slug, username) =>
|
||||||
|
slug === LARGE_SCALE_CHANGES_TEAM && username === 'ana';
|
||||||
|
const getChangedFiles = mock.fn(async () => new Set(['a.ts']));
|
||||||
|
getChangedFilesImpl = getChangedFiles;
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
assert.equal(getChangedFiles.mock.calls.length, 0);
|
||||||
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
|
assert.equal(status.state, 'success');
|
||||||
|
assert.equal(status.description, 'Large-scale change exemption by @ana');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('evaluates a large-scale label applied outside the team', async () => {
|
||||||
|
getPullRequestByIdImpl = async () => ({
|
||||||
|
...pullRequestFor('feature/x', 'master'),
|
||||||
|
labels: [{ name: LARGE_SCALE_CHANGE_LABEL }],
|
||||||
|
});
|
||||||
|
getPrEventsImpl = async () => [
|
||||||
|
{ event: 'labeled', label: { name: LARGE_SCALE_CHANGE_LABEL }, actor: { login: 'outsider' } },
|
||||||
|
];
|
||||||
|
resolveRequiredTeamsImpl = () => new Map([['@n8n-io/qa-dx', ['a.ts']]]);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
|
assert.equal(status.state, 'pending');
|
||||||
|
assert.match(status.description, /Waiting for approval from: qa-dx/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not exempt a fork branch that is named like an exempt route', async () => {
|
||||||
|
getPullRequestByIdImpl = async () => pullRequestFor('sync/master-to-3x', '3.x', 'someone/n8n');
|
||||||
|
resolveRequiredTeamsImpl = () => new Map([['@n8n-io/qa-dx', ['a.ts']]]);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
const [, status] = setCommitStatus.mock.calls.at(-1).arguments;
|
||||||
|
assert.equal(status.state, 'pending');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,38 @@ import {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const BOT_MARKER = '<!-- pr-recommendations -->';
|
const BOT_MARKER = '<!-- pr-recommendations -->';
|
||||||
|
const REQUIRED_FILES_DISPLAY_LIMIT = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string } value
|
||||||
|
* @returns { string }
|
||||||
|
*/
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return value
|
||||||
|
.replaceAll('&', '&')
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
|
.replaceAll('|', '|');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string[] } files
|
||||||
|
* @returns { string }
|
||||||
|
*/
|
||||||
|
function formatRequiredFiles(files) {
|
||||||
|
const displayedFiles = files
|
||||||
|
.slice(0, REQUIRED_FILES_DISPLAY_LIMIT)
|
||||||
|
.map((file) => `<code>${escapeHtml(file)}</code>`);
|
||||||
|
const omittedFileCount = files.length - displayedFiles.length;
|
||||||
|
|
||||||
|
if (omittedFileCount > 0) {
|
||||||
|
displayedFiles.push(
|
||||||
|
`<em>${omittedFileCount} more file${omittedFileCount === 1 ? '' : 's'}</em>`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return displayedFiles.join('<br>');
|
||||||
|
}
|
||||||
|
|
||||||
function createEmptyLineStats() {
|
function createEmptyLineStats() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -210,9 +242,11 @@ export function buildRequiredReviewsSection(requiredTeamFiles) {
|
||||||
'',
|
'',
|
||||||
'Some changed files have a `required` owner in `OWNERS`. A member of each of these teams must approve this PR before it can merge:',
|
'Some changed files have a `required` owner in `OWNERS`. A member of each of these teams must approve this PR before it can merge:',
|
||||||
'',
|
'',
|
||||||
'| Team | Files |',
|
'| Team | Files owned | Owned files |',
|
||||||
'| --- | ---: |',
|
'| --- | ---: | --- |',
|
||||||
...[...requiredTeamFiles].map(([team, files]) => `| ${team} | ${files.length} |`),
|
...[...requiredTeamFiles].map(
|
||||||
|
([team, files]) => `| ${team} | ${files.length} | ${formatRequiredFiles(files)} |`,
|
||||||
|
),
|
||||||
'',
|
'',
|
||||||
`Request a review from the team${plural ? 's' : ''} — GitHub assigns reviewers according to the team's review settings. The \`Auto-assign reviewers\` label does this for all owning teams.`,
|
`Request a review from the team${plural ? 's' : ''} — GitHub assigns reviewers according to the team's review settings. The \`Auto-assign reviewers\` label does this for all owning teams.`,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
@ -282,7 +316,11 @@ export async function run(pullRequestNumber) {
|
||||||
await postOrUpdateComment(pullRequestNumber, body, BOT_MARKER);
|
await postOrUpdateComment(pullRequestNumber, body, BOT_MARKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
export async function main() {
|
||||||
const pullRequestNumber = parseInt(ensureEnvVar('PULL_REQUEST_NUMBER'));
|
const pullRequestNumber = parseInt(ensureEnvVar('PULL_REQUEST_NUMBER'));
|
||||||
await run(pullRequestNumber);
|
await run(pullRequestNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
|
await main();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ describe('computeLineStats', () => {
|
||||||
['*.snap extension', 'src/foo.snap'],
|
['*.snap extension', 'src/foo.snap'],
|
||||||
['fixtures/ directory', 'src/fixtures/data.json'],
|
['fixtures/ directory', 'src/fixtures/data.json'],
|
||||||
['__mocks__/ directory', 'src/__mocks__/axios.ts'],
|
['__mocks__/ directory', 'src/__mocks__/axios.ts'],
|
||||||
['packages/testing/**', 'packages/testing/playwright/spec.ts'],
|
['packages/quality/**', 'packages/quality/testing/playwright/spec.ts'],
|
||||||
['dot-directory *.test.mjs', '.github/scripts/owners/owners.test.mjs'],
|
['dot-directory *.test.mjs', '.github/scripts/owners/owners.test.mjs'],
|
||||||
]) {
|
]) {
|
||||||
it(`classifies ${label} as testFiles`, () => {
|
it(`classifies ${label} as testFiles`, () => {
|
||||||
|
|
@ -322,7 +322,7 @@ describe('buildRequiredReviewsSection', () => {
|
||||||
assert.equal(buildRequiredReviewsSection(new Map()), null);
|
assert.equal(buildRequiredReviewsSection(new Map()), null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('lists each required team with its file count', () => {
|
it('lists each required team with its file count and owned files', () => {
|
||||||
const section = buildRequiredReviewsSection(
|
const section = buildRequiredReviewsSection(
|
||||||
new Map([
|
new Map([
|
||||||
['@n8n-io/qa-dx', ['a.yml', 'b.yml']],
|
['@n8n-io/qa-dx', ['a.yml', 'b.yml']],
|
||||||
|
|
@ -331,8 +331,30 @@ describe('buildRequiredReviewsSection', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.match(section, /### Required reviews/);
|
assert.match(section, /### Required reviews/);
|
||||||
assert.match(section, /\| @n8n-io\/qa-dx \| 2 \|/);
|
assert.match(
|
||||||
assert.match(section, /\| @n8n-io\/migrations-review \| 1 \|/);
|
section,
|
||||||
|
/\| @n8n-io\/qa-dx \| 2 \| <code>a\.yml<\/code><br><code>b\.yml<\/code> \|/,
|
||||||
|
);
|
||||||
|
assert.match(section, /\| @n8n-io\/migrations-review \| 1 \| <code>m\.ts<\/code> \|/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows no more than five files for each team', () => {
|
||||||
|
const section = buildRequiredReviewsSection(
|
||||||
|
new Map([['@n8n-io/qa-dx', ['a.yml', 'b.yml', 'c.yml', 'd.yml', 'e.yml', 'f.yml', 'g.yml']]]),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.match(section, /<code>a\.yml<\/code>/);
|
||||||
|
assert.match(section, /<code>e\.yml<\/code>/);
|
||||||
|
assert.doesNotMatch(section, /<code>f\.yml<\/code>/);
|
||||||
|
assert.match(section, /<em>2 more files<\/em>/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('escapes file paths before adding them to the table', () => {
|
||||||
|
const section = buildRequiredReviewsSection(
|
||||||
|
new Map([['@n8n-io/qa-dx', ['packages/a|b/<script>.ts']]]),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.match(section, /<code>packages\/a|b\/<script>\.ts<\/code>/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prompts to request review from the team, plural when several teams are required', () => {
|
it('prompts to request review from the team, plural when several teams are required', () => {
|
||||||
|
|
@ -447,7 +469,7 @@ describe('run', () => {
|
||||||
|
|
||||||
const body = postOrUpdateComment.mock.calls[0].arguments[1];
|
const body = postOrUpdateComment.mock.calls[0].arguments[1];
|
||||||
assert.match(body, /### Required reviews/);
|
assert.match(body, /### Required reviews/);
|
||||||
assert.match(body, /\| @n8n-io\/qa-dx \| 1 \|/);
|
assert.match(body, /\| @n8n-io\/qa-dx \| 1 \| <code>\.github\/workflows\/ci\.yml<\/code> \|/);
|
||||||
assert.match(body, /Request a review from the team —/);
|
assert.match(body, /Request a review from the team —/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
10
.github/scripts/package.json
vendored
10
.github/scripts/package.json
vendored
|
|
@ -2,11 +2,11 @@
|
||||||
"name": "workflow-scripts",
|
"name": "workflow-scripts",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.0.0",
|
"node": ">=24.0.0",
|
||||||
"pnpm": ">=11.25.0"
|
"pnpm": ">=12.4.2"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@11.25.0",
|
"packageManager": "pnpm@12.4.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node --test --experimental-test-module-mocks ./*.test.mjs ./docker/*.test.mjs ./owners/*.test.mjs ./quality/*.test.mjs ./slack/*.test.mjs ./stale/*.test.mjs ../../scripts/*.test.mjs ../../scripts/licenses/*.test.mjs ../../scripts/mutation-health/*.test.mjs ../../.devcontainer/codespaces/*.test.mjs",
|
"test": "node --test --experimental-test-module-mocks ./*.test.mjs ./docker/*.test.mjs ./owners/*.test.mjs ./quality/*.test.mjs ./slack/*.test.mjs ./stale/*.test.mjs ../../scripts/*.test.mjs ../../scripts/codespace-preview/*.test.mjs ../../scripts/licenses/*.test.mjs ../../scripts/mutation-health/*.test.mjs ../../.devcontainer/codespaces/*.test.mjs",
|
||||||
"generate-sbom": "FETCH_LICENSE=true cdxgen -t pnpm --no-install-deps --profile license-compliance --spec-version 1.6 -o ../../sbom-source.cdx.json ../../compiled/",
|
"generate-sbom": "FETCH_LICENSE=true cdxgen -t pnpm --no-install-deps --profile license-compliance --spec-version 1.6 -o ../../sbom-source.cdx.json ../../compiled/",
|
||||||
"enrich-sbom": "node ../../scripts/licenses/enrich-sbom.mjs ../../sbom-source.cdx.json",
|
"enrich-sbom": "node ../../scripts/licenses/enrich-sbom.mjs ../../sbom-source.cdx.json",
|
||||||
"render-licenses-md": "node ../../scripts/licenses/render-licenses-md.mjs ../../sbom-source.cdx.json ../../packages/cli/THIRD_PARTY_LICENSES.md ../../compiled/node_modules",
|
"render-licenses-md": "node ../../scripts/licenses/render-licenses-md.mjs ../../sbom-source.cdx.json ../../packages/cli/THIRD_PARTY_LICENSES.md ../../compiled/node_modules",
|
||||||
|
|
@ -16,12 +16,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/github": "9.0.0",
|
"@actions/github": "9.0.0",
|
||||||
"@cyclonedx/cdxgen": "12.4.0",
|
"@cyclonedx/cdxgen": "12.4.0",
|
||||||
"@octokit/core": "7.0.6",
|
|
||||||
"ajv": "8.20.0",
|
"ajv": "8.20.0",
|
||||||
"conventional-changelog": "7.2.0",
|
"conventional-changelog": "7.2.0",
|
||||||
"debug": "4.4.3",
|
|
||||||
"glob": "13.0.6",
|
|
||||||
"json-with-bigint": "3.5.11",
|
|
||||||
"minimatch": "10.2.4",
|
"minimatch": "10.2.4",
|
||||||
"semver": "7.7.4",
|
"semver": "7.7.4",
|
||||||
"tempfile": "6.0.1",
|
"tempfile": "6.0.1",
|
||||||
|
|
|
||||||
178
.github/scripts/pnpm-lock.yaml
vendored
178
.github/scripts/pnpm-lock.yaml
vendored
|
|
@ -1,3 +1,161 @@
|
||||||
|
---
|
||||||
|
lockfileVersion: '9.0'
|
||||||
|
|
||||||
|
importers:
|
||||||
|
|
||||||
|
.:
|
||||||
|
configDependencies: {}
|
||||||
|
packageManagerDependencies:
|
||||||
|
pnpm:
|
||||||
|
specifier: 12.4.2
|
||||||
|
version: 12.4.2
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
'@pnpm/exe.android-arm64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-E255MbcQ0V1577M2BV0ajWuP7KmTPYA0jqZnk3rK6Lq3kTvZWulMMb7iqRmnLsQbyWTkMEB2CfyM70loVDA8xg==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [android]
|
||||||
|
|
||||||
|
'@pnpm/exe.android-x64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-J1pSeCUwuKxMG70ZzpWn8JzElxiEa8NN/3N0SlZRtU2xbztChaJCKF3HaBNIj9yPfeofWzJo/lwNvDDjraQuZw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [android]
|
||||||
|
|
||||||
|
'@pnpm/exe.darwin-arm64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-A0WDo8iErfZBXgrLseQxw8i8Y9ctUpOEl/Uu+cubnTzpD8tT9ykIB548L8YTM2WD4OS+ZOHSxy8aGZcvKq8PaQ==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
'@pnpm/exe.darwin-x64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-MSgJdovBWHcb5DEOvfPH9yNi/T5O1Xa4ess+E1ESGo/5yuty7S4JoiIjami+fsNXfnoQMlwsMUqYU4zAvBcNCw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
'@pnpm/exe.freebsd-x64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-h2YumlQSNvgbRPv+RXwABohX65f9bOBZn+jMIt7bFDISZPCzQ+Nvpt6Awbp4ip5PwQgYxbu5iREJ1fHE39Fm8A==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [freebsd]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-arm64-musl@12.4.2':
|
||||||
|
resolution: {integrity: sha512-LwSEtSEDTv6S51YLs3YvSkPyun/QmfMic1UGICUkPWFu6ByP43RdMlkKvmVkfGhAYCpnxO057vrmyJqtfZrPCA==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [musl]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-arm64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-2dSiDXyhx+RTHsewxex8f/jVjqQXWJ2oow4kCVHEWdZKeBpgMxvZ6fHkTAUBJXgqhbKIDHvuNlZBP7gJfUWL5A==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-ppc64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-8Itc+jQk+MTz04LS9D1RcH+VctAWmzM4l1cJQ+Sx7pAJNo7EKHdRMbC0Tok1jyQ7eEHNJZD5EleYneZqWfZM+g==}
|
||||||
|
cpu: [ppc64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-riscv64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-hleOeqhTVpH+z9RVMGnxvU4ZnrkBUClWjCbHD9u6kwyqhGSpevoU1wTGish+CBRhmIgMAy9pAfFpqhbAKOKNfw==}
|
||||||
|
cpu: [riscv64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-s390x@12.4.2':
|
||||||
|
resolution: {integrity: sha512-LAsQRRdP9aToENR6dtcIJ9l+e1zMYOX0tQcLGpRyLPVBQcYRLlvAPcmDshsiIHQjp05SDa9FI0czX1ZQ1a7a/A==}
|
||||||
|
cpu: [s390x]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-x64-musl@12.4.2':
|
||||||
|
resolution: {integrity: sha512-kzfzH2/0BWdTABK14Yj5a1xsdkTEQUp2eXEPNakaD9jKL025lq3hyaKHIz/gIZaPDMe/1bFFK/En4ztFlbBJxw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [musl]
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-x64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-/pbt0UVTa8NMDhzOWLQRfZ6G9ROKXlJPZtx845BqyWfc7hCrWXhTLBd70yO2y8+E+IWN3oHM1s/JsIQNGk1yvg==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
libc: [glibc]
|
||||||
|
|
||||||
|
'@pnpm/exe.win32-arm64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-PsW19e4dAUNpZ0cS9flaxFuAmpt2dKlH/Vvi8TZ4qyJjjQzue/CEsWm+6wKVP4CJ7IT8RdL4qh+soOPWIgF2Zw==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
'@pnpm/exe.win32-x64@12.4.2':
|
||||||
|
resolution: {integrity: sha512-+xGoeE0g55ztWvl8i5QqdmNfW3nIrTVcoQrNshEOwxthm9Ag48oXton3uxOA3/SANyz5AXexEjj2KO20NnOrEw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
pnpm@12.4.2:
|
||||||
|
resolution: {integrity: sha512-CK3GYTGAJ1x8ntraOdzwjJxhrU5+rzMKTzRh8QKw+QdCNFTRF/mOctR/7wYWBwZE17/8lzpqV/UJCm18NosHyQ==}
|
||||||
|
engines: {node: '>=18.*'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
|
snapshots:
|
||||||
|
|
||||||
|
'@pnpm/exe.android-arm64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.android-x64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.darwin-arm64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.darwin-x64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.freebsd-x64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-arm64-musl@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-arm64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-ppc64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-riscv64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-s390x@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-x64-musl@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.linux-x64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.win32-arm64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@pnpm/exe.win32-x64@12.4.2':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
pnpm@12.4.2:
|
||||||
|
optionalDependencies:
|
||||||
|
'@pnpm/exe.android-arm64': 12.4.2
|
||||||
|
'@pnpm/exe.android-x64': 12.4.2
|
||||||
|
'@pnpm/exe.darwin-arm64': 12.4.2
|
||||||
|
'@pnpm/exe.darwin-x64': 12.4.2
|
||||||
|
'@pnpm/exe.freebsd-x64': 12.4.2
|
||||||
|
'@pnpm/exe.linux-arm64': 12.4.2
|
||||||
|
'@pnpm/exe.linux-arm64-musl': 12.4.2
|
||||||
|
'@pnpm/exe.linux-ppc64': 12.4.2
|
||||||
|
'@pnpm/exe.linux-riscv64': 12.4.2
|
||||||
|
'@pnpm/exe.linux-s390x': 12.4.2
|
||||||
|
'@pnpm/exe.linux-x64': 12.4.2
|
||||||
|
'@pnpm/exe.linux-x64-musl': 12.4.2
|
||||||
|
'@pnpm/exe.win32-arm64': 12.4.2
|
||||||
|
'@pnpm/exe.win32-x64': 12.4.2
|
||||||
|
|
||||||
|
---
|
||||||
lockfileVersion: '9.0'
|
lockfileVersion: '9.0'
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
|
|
@ -14,24 +172,12 @@ importers:
|
||||||
'@cyclonedx/cdxgen':
|
'@cyclonedx/cdxgen':
|
||||||
specifier: 12.4.0
|
specifier: 12.4.0
|
||||||
version: 12.4.0
|
version: 12.4.0
|
||||||
'@octokit/core':
|
|
||||||
specifier: 7.0.6
|
|
||||||
version: 7.0.6
|
|
||||||
ajv:
|
ajv:
|
||||||
specifier: 8.20.0
|
specifier: 8.20.0
|
||||||
version: 8.20.0
|
version: 8.20.0
|
||||||
conventional-changelog:
|
conventional-changelog:
|
||||||
specifier: 7.2.0
|
specifier: 7.2.0
|
||||||
version: 7.2.0(conventional-commits-filter@5.0.0)
|
version: 7.2.0(conventional-commits-filter@5.0.0)
|
||||||
debug:
|
|
||||||
specifier: 4.4.3
|
|
||||||
version: 4.4.3
|
|
||||||
glob:
|
|
||||||
specifier: 13.0.6
|
|
||||||
version: 13.0.6
|
|
||||||
json-with-bigint:
|
|
||||||
specifier: 3.5.11
|
|
||||||
version: 3.5.11
|
|
||||||
minimatch:
|
minimatch:
|
||||||
specifier: 10.2.4
|
specifier: 10.2.4
|
||||||
version: 10.2.4
|
version: 10.2.4
|
||||||
|
|
@ -601,8 +747,8 @@ packages:
|
||||||
fast-deep-equal@3.1.3:
|
fast-deep-equal@3.1.3:
|
||||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||||
|
|
||||||
fast-uri@3.1.5:
|
fast-uri@3.1.8:
|
||||||
resolution: {integrity: sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw==}
|
resolution: {integrity: sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==}
|
||||||
|
|
||||||
fd-package-json@2.0.0:
|
fd-package-json@2.0.0:
|
||||||
resolution: {integrity: sha512-jKmm9YtsNXN789RS/0mSzOC1NUq9mkVd65vbSSVsKdjGvYXBuE4oWe2QOEoFeRmJg+lPuZxpmrfFclNhoRMneQ==}
|
resolution: {integrity: sha512-jKmm9YtsNXN789RS/0mSzOC1NUq9mkVd65vbSSVsKdjGvYXBuE4oWe2QOEoFeRmJg+lPuZxpmrfFclNhoRMneQ==}
|
||||||
|
|
@ -1548,7 +1694,7 @@ snapshots:
|
||||||
ajv@8.20.0:
|
ajv@8.20.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
fast-deep-equal: 3.1.3
|
fast-deep-equal: 3.1.3
|
||||||
fast-uri: 3.1.5
|
fast-uri: 3.1.8
|
||||||
json-schema-traverse: 1.0.0
|
json-schema-traverse: 1.0.0
|
||||||
require-from-string: 2.0.2
|
require-from-string: 2.0.2
|
||||||
|
|
||||||
|
|
@ -1848,7 +1994,7 @@ snapshots:
|
||||||
|
|
||||||
fast-deep-equal@3.1.3: {}
|
fast-deep-equal@3.1.3: {}
|
||||||
|
|
||||||
fast-uri@3.1.5: {}
|
fast-uri@3.1.8: {}
|
||||||
|
|
||||||
fd-package-json@2.0.0:
|
fd-package-json@2.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
||||||
41
.github/scripts/quality/check-pr-size.mjs
vendored
41
.github/scripts/quality/check-pr-size.mjs
vendored
|
|
@ -12,34 +12,15 @@
|
||||||
* 1 – PR exceeds the limit with no valid override
|
* 1 – PR exceeds the limit with no valid override
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { minimatch } from 'minimatch';
|
|
||||||
import { initGithub, getEventFromGithubEventPath } from '../github-helpers.mjs';
|
import { initGithub, getEventFromGithubEventPath } from '../github-helpers.mjs';
|
||||||
|
import { matchesGlob } from '../glob.mjs';
|
||||||
|
import { isTestFile, TEST_PATTERNS } from '../test-files.mjs';
|
||||||
|
|
||||||
|
export { isTestFile, TEST_PATTERNS };
|
||||||
|
|
||||||
export const SIZE_LIMIT = 1000;
|
export const SIZE_LIMIT = 1000;
|
||||||
export const OVERRIDE_COMMAND = '/size-limit-override';
|
export const OVERRIDE_COMMAND = '/size-limit-override';
|
||||||
|
|
||||||
export const TEST_PATTERNS = [
|
|
||||||
// Test files (by extension)
|
|
||||||
'**/*.test.ts',
|
|
||||||
'**/*.test.js',
|
|
||||||
'**/*.test.mjs',
|
|
||||||
'**/*.spec.ts',
|
|
||||||
'**/*.spec.js',
|
|
||||||
'**/*.spec.mjs',
|
|
||||||
// Test directories
|
|
||||||
'**/test/**',
|
|
||||||
'**/tests/**',
|
|
||||||
'**/__tests__/**',
|
|
||||||
// Snapshots
|
|
||||||
'**/__snapshots__/**',
|
|
||||||
'**/*.snap',
|
|
||||||
// Fixtures and mocks
|
|
||||||
'**/fixtures/**',
|
|
||||||
'**/__mocks__/**',
|
|
||||||
// Dedicated testing package
|
|
||||||
'packages/testing/**',
|
|
||||||
];
|
|
||||||
|
|
||||||
export const MISC_PATTERNS = [
|
export const MISC_PATTERNS = [
|
||||||
// Lock file (can produce massive diffs on dependency changes)
|
// Lock file (can produce massive diffs on dependency changes)
|
||||||
'pnpm-lock.yaml',
|
'pnpm-lock.yaml',
|
||||||
|
|
@ -49,10 +30,6 @@ export const MISC_PATTERNS = [
|
||||||
|
|
||||||
export const EXCLUDE_PATTERNS = [...TEST_PATTERNS, ...MISC_PATTERNS];
|
export const EXCLUDE_PATTERNS = [...TEST_PATTERNS, ...MISC_PATTERNS];
|
||||||
|
|
||||||
// Without `dot`, `**` refuses dot segments, so nothing under `.github/`
|
|
||||||
// would ever match a pattern.
|
|
||||||
const MATCH_OPTIONS = { dot: true };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Categorize a changed file for line statistics.
|
* Categorize a changed file for line statistics.
|
||||||
*
|
*
|
||||||
|
|
@ -60,8 +37,8 @@ const MATCH_OPTIONS = { dot: true };
|
||||||
* @returns { 'testFiles' | 'misc' | 'sourceCode' }
|
* @returns { 'testFiles' | 'misc' | 'sourceCode' }
|
||||||
*/
|
*/
|
||||||
export function categorizeFile(filename) {
|
export function categorizeFile(filename) {
|
||||||
if (TEST_PATTERNS.some((pattern) => minimatch(filename, pattern, MATCH_OPTIONS))) return 'testFiles';
|
if (isTestFile(filename)) return 'testFiles';
|
||||||
if (MISC_PATTERNS.some((pattern) => minimatch(filename, pattern, MATCH_OPTIONS))) return 'misc';
|
if (MISC_PATTERNS.some((pattern) => matchesGlob(filename, pattern))) return 'misc';
|
||||||
return 'sourceCode';
|
return 'sourceCode';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,11 +79,11 @@ export async function hasValidOverride(comments, getPermission) {
|
||||||
*/
|
*/
|
||||||
export function countFilteredAdditions(files, excludePatterns) {
|
export function countFilteredAdditions(files, excludePatterns) {
|
||||||
return files
|
return files
|
||||||
.filter((file) => !excludePatterns.some((pattern) => minimatch(file.filename, pattern, MATCH_OPTIONS)))
|
.filter((file) => !excludePatterns.some((pattern) => matchesGlob(file.filename, pattern)))
|
||||||
.reduce((sum, file) => sum + file.additions, 0);
|
.reduce((sum, file) => sum + file.additions, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
export async function main() {
|
||||||
const event = getEventFromGithubEventPath();
|
const event = getEventFromGithubEventPath();
|
||||||
const pr = event.pull_request;
|
const pr = event.pull_request;
|
||||||
const { octokit, owner, repo } = initGithub();
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
@ -173,7 +150,7 @@ async function main() {
|
||||||
console.log(
|
console.log(
|
||||||
`::error::PR adds ${additions.toLocaleString()} lines (test files excluded), exceeding the ${SIZE_LIMIT.toLocaleString()}-line limit. Reduce PR size or ask a maintainer to comment \`${OVERRIDE_COMMAND}\`.`,
|
`::error::PR adds ${additions.toLocaleString()} lines (test files excluded), exceeding the ${SIZE_LIMIT.toLocaleString()}-line limit. Reduce PR size or ask a maintainer to comment \`${OVERRIDE_COMMAND}\`.`,
|
||||||
);
|
);
|
||||||
process.exit(1);
|
throw new Error(`PR exceeds the ${SIZE_LIMIT.toLocaleString()}-line size limit`);
|
||||||
} else {
|
} else {
|
||||||
if (botComment) {
|
if (botComment) {
|
||||||
await octokit.rest.issues.deleteComment({
|
await octokit.rest.issues.deleteComment({
|
||||||
|
|
|
||||||
15
.github/scripts/quality/check-pr-size.test.mjs
vendored
15
.github/scripts/quality/check-pr-size.test.mjs
vendored
|
|
@ -203,14 +203,21 @@ describe('countFilteredAdditions', () => {
|
||||||
assert.equal(countFilteredAdditions(files, EXCLUDE_PATTERNS), 50);
|
assert.equal(countFilteredAdditions(files, EXCLUDE_PATTERNS), 50);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('applies EXCLUDE_PATTERNS to packages/testing and pnpm-lock.yaml', () => {
|
it('excludes former testing workspaces but counts benchmark CLI source', () => {
|
||||||
const files = [
|
const files = [
|
||||||
{ filename: 'packages/cli/src/service.ts', additions: 50 },
|
{ filename: 'packages/cli/src/service.ts', additions: 50 },
|
||||||
{ filename: 'packages/testing/playwright/tests/workflow.spec.ts', additions: 100 },
|
{ filename: 'packages/quality/testing/playwright/tests/workflow.spec.ts', additions: 100 },
|
||||||
{ filename: 'packages/testing/playwright/pages/CanvasPage.ts', additions: 100 },
|
{ filename: 'packages/quality/testing/playwright/pages/CanvasPage.ts', additions: 100 },
|
||||||
|
{ filename: 'packages/quality/policy/code-health/src/cli.ts', additions: 100 },
|
||||||
|
{ filename: 'packages/quality/environments/containers/service-stack.ts', additions: 100 },
|
||||||
|
{
|
||||||
|
filename: 'packages/quality/efficiency/microbenchmarks/benchmarks/bench-options.ts',
|
||||||
|
additions: 100,
|
||||||
|
},
|
||||||
|
{ filename: 'packages/quality/efficiency/scale/benchmark/src/commands/list.ts', additions: 100 },
|
||||||
{ filename: 'pnpm-lock.yaml', additions: 500 },
|
{ filename: 'pnpm-lock.yaml', additions: 500 },
|
||||||
];
|
];
|
||||||
assert.equal(countFilteredAdditions(files, EXCLUDE_PATTERNS), 50);
|
assert.equal(countFilteredAdditions(files, EXCLUDE_PATTERNS), 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('applies EXCLUDE_PATTERNS to markdown files', () => {
|
it('applies EXCLUDE_PATTERNS to markdown files', () => {
|
||||||
|
|
|
||||||
77
.github/scripts/quality/cubic-config.schema.json
vendored
77
.github/scripts/quality/cubic-config.schema.json
vendored
|
|
@ -5,7 +5,9 @@
|
||||||
"description": "JSON schema for cubic.yaml (and the legacy .cubic.yaml) so editors can validate and autocomplete repository settings.",
|
"description": "JSON schema for cubic.yaml (and the legacy .cubic.yaml) so editors can validate and autocomplete repository settings.",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
"required": ["version"],
|
"required": [
|
||||||
|
"version"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"version": {
|
"version": {
|
||||||
"const": 1,
|
"const": 1,
|
||||||
|
|
@ -16,13 +18,26 @@
|
||||||
"description": "AI review behavior and optional YAML-defined custom agents.",
|
"description": "AI review behavior and optional YAML-defined custom agents.",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"senior_reviewers": {
|
||||||
|
"type": "array",
|
||||||
|
"maxItems": 5,
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$"
|
||||||
|
},
|
||||||
|
"description": "GitHub usernames to learn review patterns from. Overrides dashboard selections; an empty list disables senior reviewer learning."
|
||||||
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Master toggle for AI reviews on this repository."
|
"description": "Master toggle for AI reviews on this repository."
|
||||||
},
|
},
|
||||||
"sensitivity": {
|
"sensitivity": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["low", "medium", "high"],
|
"enum": [
|
||||||
|
"low",
|
||||||
|
"medium",
|
||||||
|
"high"
|
||||||
|
],
|
||||||
"description": "Controls how strictly Cubic flags issues."
|
"description": "Controls how strictly Cubic flags issues."
|
||||||
},
|
},
|
||||||
"incremental_commits": {
|
"incremental_commits": {
|
||||||
|
|
@ -63,12 +78,21 @@
|
||||||
},
|
},
|
||||||
"auto_approve_behavior": {
|
"auto_approve_behavior": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["disabled", "shadow", "live"],
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"shadow",
|
||||||
|
"live"
|
||||||
|
],
|
||||||
"description": "Controls whether auto-approval is disabled, simulated in shadow mode, or submitted live to GitHub."
|
"description": "Controls whether auto-approval is disabled, simulated in shadow mode, or submitted live to GitHub."
|
||||||
},
|
},
|
||||||
"auto_approve": {
|
"auto_approve": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["disabled", "always", "low_risk_only", "custom"],
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"always",
|
||||||
|
"low_risk_only",
|
||||||
|
"custom"
|
||||||
|
],
|
||||||
"description": "Auto-approve mode: disabled, always approve clean runs, use low-risk heuristics, or use a custom prompt."
|
"description": "Auto-approve mode: disabled, always approve clean runs, use low-risk heuristics, or use a custom prompt."
|
||||||
},
|
},
|
||||||
"auto_approve_custom_prompt": {
|
"auto_approve_custom_prompt": {
|
||||||
|
|
@ -80,12 +104,20 @@
|
||||||
},
|
},
|
||||||
"ultrareview": {
|
"ultrareview": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["disabled", "manual", "automatic"],
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"manual",
|
||||||
|
"automatic"
|
||||||
|
],
|
||||||
"description": "Master switch for ultrareviews. disabled blocks all ultrareviews (manual and automatic), manual allows only manual triggers (the default), automatic also enables the automatic triggers."
|
"description": "Master switch for ultrareviews. disabled blocks all ultrareviews (manual and automatic), manual allows only manual triggers (the default), automatic also enables the automatic triggers."
|
||||||
},
|
},
|
||||||
"auto_ultrareview": {
|
"auto_ultrareview": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["disabled", "high_risk_only", "custom"],
|
"enum": [
|
||||||
|
"disabled",
|
||||||
|
"high_risk_only",
|
||||||
|
"custom"
|
||||||
|
],
|
||||||
"description": "Auto-trigger ultrareview mode: disabled, let cubic decide per PR using built-in high-risk criteria, or use a custom prompt."
|
"description": "Auto-trigger ultrareview mode: disabled, let cubic decide per PR using built-in high-risk criteria, or use a custom prompt."
|
||||||
},
|
},
|
||||||
"auto_ultrareview_custom_prompt": {
|
"auto_ultrareview_custom_prompt": {
|
||||||
|
|
@ -159,7 +191,10 @@
|
||||||
},
|
},
|
||||||
"coding_agent_provider": {
|
"coding_agent_provider": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["cubic", "cursor_cloud_agent"],
|
"enum": [
|
||||||
|
"cubic",
|
||||||
|
"cursor_cloud_agent"
|
||||||
|
],
|
||||||
"description": "Which coding agent applies automatic fixes. 'cubic' uses cubic's built-in agent; 'cursor_cloud_agent' dispatches a Cursor cloud agent (requires Cursor configuration)."
|
"description": "Which coding agent applies automatic fixes. 'cubic' uses cubic's built-in agent; 'cursor_cloud_agent' dispatches a Cursor cloud agent (requires Cursor configuration)."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -222,8 +257,20 @@
|
||||||
},
|
},
|
||||||
"exclude_external_contributors": {
|
"exclude_external_contributors": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": true,
|
||||||
"description": "If true, public-repository PRs from external contributors are reviewed but never auto-approved."
|
"description": "If true, public-repository PRs from external contributors, or from authors cubic cannot verify, are reviewed but never auto-approved."
|
||||||
|
},
|
||||||
|
"allow_open_issues": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"none",
|
||||||
|
"p3",
|
||||||
|
"p2_and_p3",
|
||||||
|
"p1_to_p3",
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"default": "none",
|
||||||
|
"description": "Open cubic findings that don't block auto-approval, by priority. none blocks on any open finding; p3, p2_and_p3, and p1_to_p3 allow that range; all allows every open finding. A finding without a recorded priority blocks unless this is all. Every other auto-approval rule still applies."
|
||||||
},
|
},
|
||||||
"exclude_authors": {
|
"exclude_authors": {
|
||||||
"$ref": "#/$defs/globList",
|
"$ref": "#/$defs/globList",
|
||||||
|
|
@ -271,13 +318,19 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Definition of a YAML-managed custom agent.",
|
"description": "Definition of a YAML-managed custom agent.",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": ["name"],
|
"required": [
|
||||||
|
"name"
|
||||||
|
],
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"required": ["description"]
|
"required": [
|
||||||
|
"description"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"required": ["file_paths"]
|
"required": [
|
||||||
|
"file_paths"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
12
.github/scripts/quality/handle-size-override.mjs
vendored
12
.github/scripts/quality/handle-size-override.mjs
vendored
|
|
@ -32,10 +32,9 @@ export async function run({ octokit, owner, repo, prNumber, commenter, commentId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!['admin', 'write', 'maintain'].includes(perm.permission)) {
|
if (!['admin', 'write', 'maintain'].includes(perm.permission)) {
|
||||||
console.log(
|
throw new Error(
|
||||||
`::error::@${commenter} does not have permission to override the PR size limit (requires write access).`,
|
`@${commenter} does not have permission to override the PR size limit (requires write access).`,
|
||||||
);
|
);
|
||||||
process.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: pr } = await octokit.rest.pulls.get({
|
const { data: pr } = await octokit.rest.pulls.get({
|
||||||
|
|
@ -56,10 +55,9 @@ export async function run({ octokit, owner, repo, prNumber, commenter, commentId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (check_runs.length === 0) {
|
if (check_runs.length === 0) {
|
||||||
console.log(
|
throw new Error(
|
||||||
`::error::No '${CHECK_NAME}' check run found for ${headSha}. Push a new commit to trigger it.`,
|
`No '${CHECK_NAME}' check run found for ${headSha}. Push a new commit to trigger it.`,
|
||||||
);
|
);
|
||||||
process.exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await octokit.rest.checks.rerequestRun({
|
await octokit.rest.checks.rerequestRun({
|
||||||
|
|
@ -78,7 +76,7 @@ export async function run({ octokit, owner, repo, prNumber, commenter, commentId
|
||||||
console.log(`Re-requested '${CHECK_NAME}' check run (${check_runs[0].id}) for ${headSha}`);
|
console.log(`Re-requested '${CHECK_NAME}' check run (${check_runs[0].id}) for ${headSha}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
export async function main() {
|
||||||
const event = getEventFromGithubEventPath();
|
const event = getEventFromGithubEventPath();
|
||||||
const { octokit, owner, repo } = initGithub();
|
const { octokit, owner, repo } = initGithub();
|
||||||
|
|
||||||
|
|
|
||||||
68
.github/scripts/split-jscpd-report.mjs
vendored
Normal file
68
.github/scripts/split-jscpd-report.mjs
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
// Splits a jscpd JSON report's `duplicates` array into N bucket files so a
|
||||||
|
// caller can download and sample one small file instead of the whole report
|
||||||
|
// (which can run into tens of MB on a large monorepo). Round-robin, not
|
||||||
|
// contiguous chunks, so a run of similarly-sized clusters in scan order
|
||||||
|
// doesn't pile up in one bucket.
|
||||||
|
|
||||||
|
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
|
||||||
|
export function splitDuplicates(duplicates, bucketCount) {
|
||||||
|
const buckets = Array.from({ length: bucketCount }, () => []);
|
||||||
|
duplicates.forEach((dup, i) => buckets[i % bucketCount].push(dup));
|
||||||
|
return buckets;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function writeBuckets(buckets, outputDir, deps = {}) {
|
||||||
|
const mkdirImpl = deps.mkdir ?? mkdirSync;
|
||||||
|
const writeImpl = deps.write ?? writeFileSync;
|
||||||
|
mkdirImpl(outputDir, { recursive: true });
|
||||||
|
return buckets.map((duplicates, i) => {
|
||||||
|
const path = join(outputDir, `bucket-${i}.json`);
|
||||||
|
writeImpl(path, JSON.stringify({ duplicates }));
|
||||||
|
return path;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseBucketCount(raw) {
|
||||||
|
const count = Number(raw ?? 20);
|
||||||
|
if (!Number.isInteger(count) || count <= 0) {
|
||||||
|
throw new Error(`BUCKET_COUNT must be a positive integer, got '${raw}'`);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadDuplicates(reportPath, deps = {}) {
|
||||||
|
const readImpl = deps.read ?? readFileSync;
|
||||||
|
const report = JSON.parse(readImpl(reportPath, 'utf8'));
|
||||||
|
if (!Array.isArray(report.duplicates)) {
|
||||||
|
throw new Error('report.duplicates must be an array');
|
||||||
|
}
|
||||||
|
return report.duplicates;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exits non-zero on any failure. The workflow step already runs with
|
||||||
|
// continue-on-error, so this can't fail the job — it only stops a broken
|
||||||
|
// split (zero buckets written) from reporting success.
|
||||||
|
function main() {
|
||||||
|
const reportPath = process.env.REPORT_PATH;
|
||||||
|
const outputDir = process.env.OUTPUT_DIR;
|
||||||
|
if (!reportPath || !outputDir) {
|
||||||
|
process.stderr.write('split-jscpd-report: REPORT_PATH and OUTPUT_DIR are required\n');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const bucketCount = parseBucketCount(process.env.BUCKET_COUNT);
|
||||||
|
const duplicates = loadDuplicates(reportPath);
|
||||||
|
const buckets = splitDuplicates(duplicates, bucketCount);
|
||||||
|
writeBuckets(buckets, outputDir);
|
||||||
|
} catch (err) {
|
||||||
|
process.stderr.write(`split-jscpd-report: ${err.message}\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||||
|
main();
|
||||||
|
}
|
||||||
111
.github/scripts/split-jscpd-report.test.mjs
vendored
Normal file
111
.github/scripts/split-jscpd-report.test.mjs
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
/**
|
||||||
|
* Run these tests by running
|
||||||
|
*
|
||||||
|
* node --test .github/scripts/split-jscpd-report.test.mjs
|
||||||
|
* */
|
||||||
|
|
||||||
|
import { describe, it } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { splitDuplicates, writeBuckets, parseBucketCount, loadDuplicates } from './split-jscpd-report.mjs';
|
||||||
|
|
||||||
|
describe('splitDuplicates', () => {
|
||||||
|
it('distributes entries round-robin across buckets', () => {
|
||||||
|
const duplicates = [1, 2, 3, 4, 5, 6];
|
||||||
|
const buckets = splitDuplicates(duplicates, 3);
|
||||||
|
assert.deepEqual(buckets, [
|
||||||
|
[1, 4],
|
||||||
|
[2, 5],
|
||||||
|
[3, 6],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('leaves later buckets empty when there are fewer entries than buckets', () => {
|
||||||
|
const buckets = splitDuplicates([1, 2], 5);
|
||||||
|
assert.equal(buckets.length, 5);
|
||||||
|
assert.deepEqual(buckets[0], [1]);
|
||||||
|
assert.deepEqual(buckets[1], [2]);
|
||||||
|
assert.deepEqual(buckets[2], []);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns bucketCount empty arrays for an empty report', () => {
|
||||||
|
const buckets = splitDuplicates([], 4);
|
||||||
|
assert.deepEqual(buckets, [[], [], [], []]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('writeBuckets', () => {
|
||||||
|
it('writes one JSON file per bucket, named by index', () => {
|
||||||
|
const written = [];
|
||||||
|
const paths = writeBuckets([[{ a: 1 }], [{ b: 2 }]], '/tmp/buckets', {
|
||||||
|
mkdir: () => {},
|
||||||
|
write: (path, contents) => written.push({ path, contents }),
|
||||||
|
});
|
||||||
|
assert.deepEqual(paths, ['/tmp/buckets/bucket-0.json', '/tmp/buckets/bucket-1.json']);
|
||||||
|
assert.deepEqual(JSON.parse(written[0].contents), { duplicates: [{ a: 1 }] });
|
||||||
|
assert.deepEqual(JSON.parse(written[1].contents), { duplicates: [{ b: 2 }] });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates the output directory before writing', () => {
|
||||||
|
let mkdirCalledWith = null;
|
||||||
|
writeBuckets([[]], '/tmp/buckets', {
|
||||||
|
mkdir: (dir, opts) => {
|
||||||
|
mkdirCalledWith = { dir, opts };
|
||||||
|
},
|
||||||
|
write: () => {},
|
||||||
|
});
|
||||||
|
assert.deepEqual(mkdirCalledWith, { dir: '/tmp/buckets', opts: { recursive: true } });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('parseBucketCount', () => {
|
||||||
|
it('parses a numeric string', () => {
|
||||||
|
assert.equal(parseBucketCount('20'), 20);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('defaults to 20 when unset', () => {
|
||||||
|
assert.equal(parseBucketCount(undefined), 20);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects zero', () => {
|
||||||
|
assert.throws(() => parseBucketCount('0'), /positive integer/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects a negative count', () => {
|
||||||
|
assert.throws(() => parseBucketCount('-1'), /positive integer/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects a non-integer', () => {
|
||||||
|
assert.throws(() => parseBucketCount('1.5'), /positive integer/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects a non-numeric value', () => {
|
||||||
|
assert.throws(() => parseBucketCount('abc'), /positive integer/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('loadDuplicates', () => {
|
||||||
|
it('returns the duplicates array from a valid report', () => {
|
||||||
|
const duplicates = loadDuplicates('/tmp/report.json', {
|
||||||
|
read: () => JSON.stringify({ duplicates: [{ a: 1 }] }),
|
||||||
|
});
|
||||||
|
assert.deepEqual(duplicates, [{ a: 1 }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects a report missing the duplicates array', () => {
|
||||||
|
assert.throws(
|
||||||
|
() => loadDuplicates('/tmp/report.json', { read: () => JSON.stringify({}) }),
|
||||||
|
/duplicates must be an array/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects a report whose duplicates field is not an array', () => {
|
||||||
|
assert.throws(
|
||||||
|
() => loadDuplicates('/tmp/report.json', { read: () => JSON.stringify({ duplicates: 'x' }) }),
|
||||||
|
/duplicates must be an array/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('propagates a JSON parse failure', () => {
|
||||||
|
assert.throws(() => loadDuplicates('/tmp/report.json', { read: () => 'not json' }), SyntaxError);
|
||||||
|
});
|
||||||
|
});
|
||||||
30
.github/scripts/sync-bundle-branch.mjs
vendored
30
.github/scripts/sync-bundle-branch.mjs
vendored
|
|
@ -12,7 +12,7 @@
|
||||||
* why only a rewrite breaks this.
|
* why only a rewrite breaks this.
|
||||||
*
|
*
|
||||||
* The cost of merging is a merge commit per run, plus already-published fixes staying in the
|
* The cost of merging is a merge commit per run, plus already-published fixes staying in the
|
||||||
* branch's log (the rebase used to drop them as empty). Neither reaches anything downstream:
|
* branch's log. Neither reaches anything downstream:
|
||||||
* a bundle is published as one squashed, deliberately obfuscated commit, and the squash is
|
* a bundle is published as one squashed, deliberately obfuscated commit, and the squash is
|
||||||
* taken from the tree, not the history. For a list of what a bundle actually carries, read
|
* taken from the tree, not the history. For a list of what a bundle actually carries, read
|
||||||
* the fix PRs merged into the branch since the last cut, not `base..bundle`.
|
* the fix PRs merged into the branch since the last cut, not `base..bundle`.
|
||||||
|
|
@ -26,9 +26,13 @@
|
||||||
* of being re-litigated on every later run. Contrast `sync-master-to-3x.mjs`, which
|
* of being re-litigated on every later run. Contrast `sync-master-to-3x.mjs`, which
|
||||||
* auto-resolves mechanical files and opens a conflict PR.
|
* auto-resolves mechanical files and opens a conflict PR.
|
||||||
*
|
*
|
||||||
|
* PUBLIC HISTORY ONLY: the base is fetched directly from the public repo. Private master can
|
||||||
|
* temporarily contain a bundle cut that public master does not have yet. Using the private base
|
||||||
|
* would strand that commit on a recreated bundle branch after the private mirror replaces it.
|
||||||
|
*
|
||||||
* Runs from a full checkout (fetch-depth 0) of any branch. Assumes credentials are NOT
|
* Runs from a full checkout (fetch-depth 0) of any branch. Assumes credentials are NOT
|
||||||
* persisted by checkout — every fetch and the push go through an explicit token URL, which
|
* persisted by checkout. The bundle fetch and push use an explicit token URL. The public base
|
||||||
* matters because the repository is private.
|
* fetch is anonymous.
|
||||||
*
|
*
|
||||||
* Env: BUNDLE_BRANCH (e.g. bundle/2.x), BASE_BRANCH (e.g. master),
|
* Env: BUNDLE_BRANCH (e.g. bundle/2.x), BASE_BRANCH (e.g. master),
|
||||||
* GH_TOKEN (installation token with contents:write),
|
* GH_TOKEN (installation token with contents:write),
|
||||||
|
|
@ -48,6 +52,10 @@ import {
|
||||||
const BOT_NAME = 'n8n-assistant[bot]';
|
const BOT_NAME = 'n8n-assistant[bot]';
|
||||||
const BOT_EMAIL = 'n8n-assistant[bot]@users.noreply.github.com';
|
const BOT_EMAIL = 'n8n-assistant[bot]@users.noreply.github.com';
|
||||||
|
|
||||||
|
// Hard-coded like the mirror in sec-sync-public-to-private.yml, and fetched anonymously: the
|
||||||
|
// installation token this script holds is scoped to the private repo.
|
||||||
|
const PUBLIC_REMOTE = 'https://github.com/n8n-io/n8n.git';
|
||||||
|
|
||||||
function required(env, name) {
|
function required(env, name) {
|
||||||
const value = env[name];
|
const value = env[name];
|
||||||
if (!value) throw new Error(`${name} env var is required`);
|
if (!value) throw new Error(`${name} env var is required`);
|
||||||
|
|
@ -61,7 +69,7 @@ export function annotation(title, message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBundleBranch({ git, log, bundle, base, baseSha, remote }) {
|
function createBundleBranch({ git, log, bundle, base, baseSha, remote }) {
|
||||||
log(`${bundle} does not exist yet; creating it at ${base} ${baseSha}.`);
|
log(`${bundle} does not exist yet; creating it at public ${base} ${baseSha}.`);
|
||||||
git(['checkout', '--force', '-B', bundle, baseSha]);
|
git(['checkout', '--force', '-B', bundle, baseSha]);
|
||||||
|
|
||||||
const push = attempt(git, ['push', remote, `HEAD:refs/heads/${bundle}`]);
|
const push = attempt(git, ['push', remote, `HEAD:refs/heads/${bundle}`]);
|
||||||
|
|
@ -78,9 +86,11 @@ function createBundleBranch({ git, log, bundle, base, baseSha, remote }) {
|
||||||
* caller re-runs from a fresh fetch rather than forcing anything.
|
* caller re-runs from a fresh fetch rather than forcing anything.
|
||||||
*/
|
*/
|
||||||
function mergeBaseIntoBundle({ git, log, bundle, base, remote }) {
|
function mergeBaseIntoBundle({ git, log, bundle, base, remote }) {
|
||||||
// Pin both sides to the fetched SHAs — fetching by URL never updates the origin/* tracking
|
// Pin the base to the public SHA. Private master can temporarily contain an unpublished cut.
|
||||||
// refs, so FETCH_HEAD is the only handle. Base first: the second fetch overwrites it.
|
const publicFetch = attempt(git, ['fetch', PUBLIC_REMOTE, base]);
|
||||||
git(['fetch', remote, base]);
|
if (!publicFetch.ok) {
|
||||||
|
throw new Error(`Could not fetch ${base} from the public repo:\n${publicFetch.out}`);
|
||||||
|
}
|
||||||
const baseSha = git(['rev-parse', 'FETCH_HEAD']);
|
const baseSha = git(['rev-parse', 'FETCH_HEAD']);
|
||||||
|
|
||||||
const listed = attempt(git, ['ls-remote', '--heads', remote, `refs/heads/${bundle}`]);
|
const listed = attempt(git, ['ls-remote', '--heads', remote, `refs/heads/${bundle}`]);
|
||||||
|
|
@ -107,7 +117,9 @@ function mergeBaseIntoBundle({ git, log, bundle, base, remote }) {
|
||||||
'--format=%h %s',
|
'--format=%h %s',
|
||||||
`${baseSha}..${preHead}`,
|
`${baseSha}..${preHead}`,
|
||||||
]);
|
]);
|
||||||
log(`Merging ${base} ${baseSha} into ${bundle}. Commits on ${bundle}:\n${pending || '(none)'}`);
|
log(
|
||||||
|
`Merging public ${base} ${baseSha} into ${bundle}. Commits on ${bundle}:\n${pending || '(none)'}`,
|
||||||
|
);
|
||||||
|
|
||||||
// The content the merge must produce — and whether the two sides conflict at all. Computed
|
// The content the merge must produce — and whether the two sides conflict at all. Computed
|
||||||
// without touching the working tree, so a conflict costs the branch nothing.
|
// without touching the working tree, so a conflict costs the branch nothing.
|
||||||
|
|
@ -139,7 +151,7 @@ function mergeBaseIntoBundle({ git, log, bundle, base, remote }) {
|
||||||
if (push.out) log(push.out);
|
if (push.out) log(push.out);
|
||||||
return { status: 'rejected' };
|
return { status: 'rejected' };
|
||||||
}
|
}
|
||||||
log(`Merged ${base} into ${bundle} — nothing rewritten.`);
|
log(`Merged public ${base} into ${bundle}; nothing was rewritten.`);
|
||||||
return { status: 'merged' };
|
return { status: 'merged' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
107
.github/scripts/sync-bundle-branch.test.mjs
vendored
107
.github/scripts/sync-bundle-branch.test.mjs
vendored
|
|
@ -3,13 +3,14 @@ import { test } from 'node:test';
|
||||||
|
|
||||||
import { annotation, syncBundleBranch } from './sync-bundle-branch.mjs';
|
import { annotation, syncBundleBranch } from './sync-bundle-branch.mjs';
|
||||||
|
|
||||||
// A git stub: routes calls by a matcher, records every invocation.
|
// A git stub: routes calls by a matcher, records every invocation. Route results also receive
|
||||||
|
// the calls so far, which is how FETCH_HEAD is modelled — see `fetchHead`.
|
||||||
function makeStub(routes = []) {
|
function makeStub(routes = []) {
|
||||||
const calls = [];
|
const calls = [];
|
||||||
const fn = (args) => {
|
const fn = (args) => {
|
||||||
calls.push(args);
|
calls.push(args);
|
||||||
for (const [match, result] of routes) {
|
for (const [match, result] of routes) {
|
||||||
if (match(args)) return typeof result === 'function' ? result(args) : result;
|
if (match(args)) return typeof result === 'function' ? result(args, calls) : result;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
@ -27,9 +28,12 @@ const fail =
|
||||||
};
|
};
|
||||||
|
|
||||||
const PRE_HEAD = 'PREHEAD';
|
const PRE_HEAD = 'PREHEAD';
|
||||||
const BASE = 'BASESHA';
|
const PUBLIC = 'PUBLICSHA';
|
||||||
const MERGE_TREE = 'MERGETREEOID';
|
const MERGE_TREE = 'MERGETREEOID';
|
||||||
const REMOTE = 'https://x-access-token:tok@github.com/n8n-io/n8n-private.git';
|
const REMOTE = 'https://x-access-token:tok@github.com/n8n-io/n8n-private.git';
|
||||||
|
// Spelled out rather than imported: a duplicated literal is what makes the "the private token
|
||||||
|
// never reaches the public repo" assertion below a real one.
|
||||||
|
const PUBLIC_REMOTE = 'https://github.com/n8n-io/n8n.git';
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
BUNDLE_BRANCH: 'bundle/2.x',
|
BUNDLE_BRANCH: 'bundle/2.x',
|
||||||
|
|
@ -46,14 +50,23 @@ const isPush = (a) => a[0] === 'push';
|
||||||
const conflictedMergeTree = (...paths) =>
|
const conflictedMergeTree = (...paths) =>
|
||||||
fail(`${MERGE_TREE}\n${paths.join('\n')}\n\nCONFLICT (content): Merge conflict in ${paths[0]}`);
|
fail(`${MERGE_TREE}\n${paths.join('\n')}\n\nCONFLICT (content): Merge conflict in ${paths[0]}`);
|
||||||
|
|
||||||
// Routes shared by every path: base fetched, the bundle branch hasn't absorbed it yet, the
|
// FETCH_HEAD is one slot holding whatever the last fetch brought down, so the stub has to answer
|
||||||
// merge tree is computable, and the merge lands on exactly that tree. git grep exits
|
// by looking back at that fetch.
|
||||||
// non-zero => no markers.
|
const fetchHead = (_args, calls) => {
|
||||||
|
const [, url, ref] = [...calls].reverse().find((a) => a[0] === 'fetch') ?? [];
|
||||||
|
if (url === PUBLIC_REMOTE) return PUBLIC;
|
||||||
|
if (ref?.startsWith('bundle/')) return PRE_HEAD;
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Routes shared by every path: the bundle branch has not absorbed the public base yet, the
|
||||||
|
// merge tree is computable, and the merge lands on exactly that tree. git grep exits non-zero
|
||||||
|
// => no markers.
|
||||||
const baseGitRoutes = [
|
const baseGitRoutes = [
|
||||||
[(a) => a[0] === 'ls-remote', `${PRE_HEAD}\trefs/heads/bundle/2.x`],
|
[(a) => a[0] === 'ls-remote', `${PRE_HEAD}\trefs/heads/bundle/2.x`],
|
||||||
[(a) => a[0] === 'rev-parse' && a[1] === 'FETCH_HEAD', BASE],
|
[(a) => a[0] === 'rev-parse' && a[1] === 'FETCH_HEAD', fetchHead],
|
||||||
[(a) => a[0] === 'rev-parse' && a[1] === 'HEAD', PRE_HEAD],
|
[(a) => a[0] === 'rev-parse' && a[1] === 'HEAD', PRE_HEAD],
|
||||||
[(a) => a[0] === 'merge-base', fail()],
|
[(a) => a[0] === 'merge-base' && a[3] === PRE_HEAD, fail()],
|
||||||
[(a) => a[0] === 'merge-tree', MERGE_TREE],
|
[(a) => a[0] === 'merge-tree', MERGE_TREE],
|
||||||
[(a) => a[0] === 'rev-parse' && a[1] === 'HEAD^{tree}', MERGE_TREE],
|
[(a) => a[0] === 'rev-parse' && a[1] === 'HEAD^{tree}', MERGE_TREE],
|
||||||
[(a) => a[0] === 'grep', fail()],
|
[(a) => a[0] === 'grep', fail()],
|
||||||
|
|
@ -83,21 +96,45 @@ test('a clean sync merges the base in and pushes without forcing', () => {
|
||||||
'--no-edit',
|
'--no-edit',
|
||||||
'-m',
|
'-m',
|
||||||
'Merge master into bundle/2.x',
|
'Merge master into bundle/2.x',
|
||||||
BASE,
|
PUBLIC,
|
||||||
]);
|
]);
|
||||||
// No lease and no --force: the branch is append-only, so a non-fast-forward must be
|
// No lease and no --force: the branch is append-only, so a non-fast-forward must be
|
||||||
// refused by git rather than resolved by overwriting whatever landed.
|
// refused by git rather than resolved by overwriting whatever landed.
|
||||||
assert.deepEqual(git.calls.find(isPush), ['push', REMOTE, 'HEAD:refs/heads/bundle/2.x']);
|
assert.deepEqual(git.calls.find(isPush), ['push', REMOTE, 'HEAD:refs/heads/bundle/2.x']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('both fetches are authenticated — the private repo rejects an anonymous origin fetch', () => {
|
test('the bundle fetch is authenticated and the public base fetch is not', () => {
|
||||||
const git = makeStub(baseGitRoutes);
|
const git = makeStub(baseGitRoutes);
|
||||||
syncBundleBranch({ git, env, log: silent });
|
syncBundleBranch({ git, env, log: silent });
|
||||||
|
|
||||||
|
// The private repo rejects an anonymous fetch; the public repo needs no credential.
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
git.calls.filter((a) => a[0] === 'fetch'),
|
git.calls.filter((a) => a[0] === 'fetch'),
|
||||||
[
|
[
|
||||||
['fetch', REMOTE, 'master'],
|
['fetch', PUBLIC_REMOTE, 'master'],
|
||||||
|
['fetch', REMOTE, 'bundle/2.x'],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// The token is scoped to the private repo, so it must never be sent to the public one.
|
||||||
|
assert.equal(
|
||||||
|
git.calls.some((a) =>
|
||||||
|
a.some((arg) => String(arg).includes('x-access-token') && String(arg).includes('/n8n.git')),
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the public tip is read straight after its own fetch', () => {
|
||||||
|
const git = makeStub(baseGitRoutes);
|
||||||
|
syncBundleBranch({ git, env, log: silent });
|
||||||
|
|
||||||
|
// Separating a fetch from the read that consumes it would silently pin the wrong SHA.
|
||||||
|
assert.deepEqual(
|
||||||
|
git.calls.filter((a) => a[0] === 'fetch' || (a[0] === 'rev-parse' && a[1] === 'FETCH_HEAD')),
|
||||||
|
[
|
||||||
|
['fetch', PUBLIC_REMOTE, 'master'],
|
||||||
|
['rev-parse', 'FETCH_HEAD'],
|
||||||
['fetch', REMOTE, 'bundle/2.x'],
|
['fetch', REMOTE, 'bundle/2.x'],
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
@ -105,7 +142,7 @@ test('both fetches are authenticated — the private repo rejects an anonymous o
|
||||||
|
|
||||||
test('a bundle branch that already contains its base is left alone', () => {
|
test('a bundle branch that already contains its base is left alone', () => {
|
||||||
const git = makeStub([
|
const git = makeStub([
|
||||||
[(a) => a[0] === 'merge-base', ''], // --is-ancestor succeeds
|
[(a) => a[0] === 'merge-base' && a[3] === PRE_HEAD, ''], // --is-ancestor succeeds
|
||||||
...baseGitRoutes,
|
...baseGitRoutes,
|
||||||
]);
|
]);
|
||||||
const result = syncBundleBranch({ git, env, log: silent });
|
const result = syncBundleBranch({ git, env, log: silent });
|
||||||
|
|
@ -173,8 +210,9 @@ test('a fix landing mid-run is retried from a fresh fetch, never forced', () =>
|
||||||
|
|
||||||
assert.deepEqual(result, { status: 'merged' });
|
assert.deepEqual(result, { status: 'merged' });
|
||||||
assert.equal(pushes, 2);
|
assert.equal(pushes, 2);
|
||||||
// The retry re-fetches rather than reusing the tip it already merged onto.
|
// The retry re-fetches both tips instead of reusing the merge that lost the push race.
|
||||||
assert.equal(git.calls.filter((a) => a[0] === 'fetch').length, 4);
|
assert.equal(git.calls.filter((a) => a[0] === 'fetch').length, 4);
|
||||||
|
assert.equal(git.calls.filter((a) => a[1] === PUBLIC_REMOTE).length, 2);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
git.calls.every((a) => !a.some((arg) => String(arg).includes('force-with-lease'))),
|
git.calls.every((a) => !a.some((arg) => String(arg).includes('force-with-lease'))),
|
||||||
true,
|
true,
|
||||||
|
|
@ -189,19 +227,19 @@ test('a branch that keeps moving fails instead of forcing', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a bundle branch that does not exist yet is created at its base', () => {
|
test('a bundle branch that does not exist yet is created at the public base', () => {
|
||||||
const git = makeStub([[(a) => a[0] === 'ls-remote', ''], ...baseGitRoutes]);
|
const git = makeStub([[(a) => a[0] === 'ls-remote', ''], ...baseGitRoutes]);
|
||||||
const result = syncBundleBranch({ git, env, log: silent });
|
const result = syncBundleBranch({ git, env, log: silent });
|
||||||
|
|
||||||
assert.deepEqual(result, { status: 'created' });
|
assert.deepEqual(result, { status: 'created' });
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
git.calls.find((a) => a[0] === 'checkout'),
|
git.calls.find((a) => a[0] === 'checkout'),
|
||||||
['checkout', '--force', '-B', 'bundle/2.x', BASE],
|
['checkout', '--force', '-B', 'bundle/2.x', PUBLIC],
|
||||||
);
|
);
|
||||||
assert.equal(git.calls.some(isMerge), false);
|
assert.equal(git.calls.some(isMerge), false);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
git.calls.filter((a) => a[0] === 'fetch'),
|
git.calls.filter((a) => a[0] === 'fetch'),
|
||||||
[['fetch', REMOTE, 'master']],
|
[['fetch', PUBLIC_REMOTE, 'master']],
|
||||||
);
|
);
|
||||||
assert.deepEqual(git.calls.find(isPush), ['push', REMOTE, 'HEAD:refs/heads/bundle/2.x']);
|
assert.deepEqual(git.calls.find(isPush), ['push', REMOTE, 'HEAD:refs/heads/bundle/2.x']);
|
||||||
});
|
});
|
||||||
|
|
@ -242,3 +280,40 @@ test('a branch created under us mid-run is merged into on the retry', () => {
|
||||||
test('annotation keeps a multi-line message on one line', () => {
|
test('annotation keeps a multi-line message on one line', () => {
|
||||||
assert.equal(annotation('t', 'a\nb'), '::error title=t::a%0Ab');
|
assert.equal(annotation('t', 'a\nb'), '::error title=t::a%0Ab');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a public fetch that fails stops the run instead of guessing', () => {
|
||||||
|
const git = makeStub([
|
||||||
|
[(a) => a[0] === 'fetch' && a[1] === PUBLIC_REMOTE, fail('could not read from remote')],
|
||||||
|
...baseGitRoutes,
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.throws(() => syncBundleBranch({ git, env, log: silent }), {
|
||||||
|
message: /Could not fetch master from the public repo/,
|
||||||
|
});
|
||||||
|
assert.equal(
|
||||||
|
git.calls.some((a) => a[0] === 'checkout'),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
assert.equal(git.calls.some(isPush), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the 1.x bundle branch is checked against public 1.x', () => {
|
||||||
|
const git = makeStub([
|
||||||
|
[(a) => a[0] === 'ls-remote', `${PRE_HEAD}\trefs/heads/bundle/1.x`],
|
||||||
|
...baseGitRoutes,
|
||||||
|
]);
|
||||||
|
syncBundleBranch({
|
||||||
|
git,
|
||||||
|
env: { ...env, BUNDLE_BRANCH: 'bundle/1.x', BASE_BRANCH: '1.x' },
|
||||||
|
log: silent,
|
||||||
|
});
|
||||||
|
|
||||||
|
// The base branch name carries over to the public side unchanged.
|
||||||
|
assert.deepEqual(
|
||||||
|
git.calls.filter((a) => a[0] === 'fetch'),
|
||||||
|
[
|
||||||
|
['fetch', PUBLIC_REMOTE, '1.x'],
|
||||||
|
['fetch', REMOTE, 'bundle/1.x'],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
|
||||||
2
.github/scripts/sync-conflict-owners.mjs
vendored
2
.github/scripts/sync-conflict-owners.mjs
vendored
|
|
@ -254,7 +254,7 @@ export function buildOutputs({
|
||||||
? [
|
? [
|
||||||
'',
|
'',
|
||||||
'> [!NOTE]',
|
'> [!NOTE]',
|
||||||
'> `pnpm-lock.yaml` still carries its conflict markers because a manifest (`package.json` / `pnpm-workspace.yaml`) is conflicted too, or its regeneration failed. After resolving the manifests, regenerate it with `pnpm install --lockfile-only` and commit the result.',
|
'> `pnpm-lock.yaml` still carries its conflict markers. Resolve the other conflicts first. Then regenerate it with `pnpm install --lockfile-only` and commit the result.',
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
'',
|
'',
|
||||||
|
|
|
||||||
|
|
@ -210,12 +210,12 @@ test('buildOutputs lists mechanically pre-resolved files apart from the code con
|
||||||
syncBranch: 'sync/master-to-3x',
|
syncBranch: 'sync/master-to-3x',
|
||||||
files: ['packages/cli/x.ts'],
|
files: ['packages/cli/x.ts'],
|
||||||
owners: ['alice'],
|
owners: ['alice'],
|
||||||
preResolved: ['pnpm-lock.yaml'],
|
preResolved: ['packages/frontend/editor-ui/data/node-popularity.json'],
|
||||||
});
|
});
|
||||||
assert.match(out.body, /### Conflicted files\n- `packages\/cli\/x\.ts`/);
|
assert.match(out.body, /### Conflicted files\n- `packages\/cli\/x\.ts`/);
|
||||||
assert.match(out.body, /### Auto-resolved for you/);
|
assert.match(out.body, /### Auto-resolved for you/);
|
||||||
assert.match(out.body, /resolved mechanically — no action needed/);
|
assert.match(out.body, /resolved mechanically — no action needed/);
|
||||||
assert.ok(out.body.indexOf('pnpm-lock.yaml') > out.body.indexOf('Auto-resolved'));
|
assert.ok(out.body.indexOf('node-popularity.json') > out.body.indexOf('Auto-resolved'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('buildOutputs carries the regen instruction when the lockfile was deferred', () => {
|
test('buildOutputs carries the regen instruction when the lockfile was deferred', () => {
|
||||||
|
|
|
||||||
92
.github/scripts/sync-master-to-3x.mjs
vendored
92
.github/scripts/sync-master-to-3x.mjs
vendored
|
|
@ -24,20 +24,16 @@
|
||||||
* the human's fix commit is in the queue and does the real work. Stalls the strategy
|
* the human's fix commit is in the queue and does the real work. Stalls the strategy
|
||||||
* option cannot settle (modify/delete — `-X` never resolves those) are resolved in
|
* option cannot settle (modify/delete — `-X` never resolves those) are resolved in
|
||||||
* place toward the queue commit's side. Tree is then proven.
|
* place toward the queue commit's side. Tree is then proven.
|
||||||
* 3. master conflicts with 3.x, but ONLY on mechanical files — tool-generated content
|
* 3. master conflicts with 3.x, but ONLY on non-lockfile mechanical files — bot-maintained
|
||||||
* with a deterministic resolution (the pnpm lockfile, bot-maintained data files).
|
* data with a deterministic resolution. These are resolved in place while the replay
|
||||||
* These are resolved in place while the replay is stopped, exactly as a human
|
* is stopped and folded into the stalled commit — still no commit of its own and no PR.
|
||||||
* resolver would (regenerate the lockfile, take master's blob), and folded into the
|
* 4. The content does NOT reconcile on a real code path, or `pnpm-lock.yaml` conflicts →
|
||||||
* stalled commit — still no commit of its own and no PR. When the `-X theirs` route
|
* a genuinely new conflict. 3.x is left UNTOUCHED and a draft PR is opened on the sync
|
||||||
* resolves lockfile hunks without stalling, the lockfile is reconciled at the tip
|
* branch carrying the conflict markers. Other mechanical files are pre-resolved. The
|
||||||
* instead (folded into the tip commit by amending — never a commit of its own).
|
* lockfile is left for the resolver because pnpm validation is not reliable while the
|
||||||
* 4. The content does NOT reconcile on a real code path → a genuinely new conflict. 3.x
|
* merge index is unresolved. Delete/modify conflicts leave no markers, so they are
|
||||||
* is left UNTOUCHED and a draft PR is opened on the sync branch carrying the conflict
|
* resolved toward 3.x and reported as an explicit decision instead. Syncs pause until
|
||||||
* markers — with the mechanical files pre-resolved, so the resolver only deals with
|
* the PR is merged.
|
||||||
* real code — naming both ends of the clash: the authors of the breaking commits and
|
|
||||||
* the master commits that touched the same files. Delete/modify conflicts leave no
|
|
||||||
* markers, so they are resolved toward 3.x and reported as an explicit decision
|
|
||||||
* instead. Syncs pause until it is merged.
|
|
||||||
*
|
*
|
||||||
* The conflict branch carries the conflict markers, so the resolver sees exactly what clashed
|
* The conflict branch carries the conflict markers, so the resolver sees exactly what clashed
|
||||||
* and the required checks stay red until they fix it in a commit of their own. A conflict git
|
* and the required checks stay red until they fix it in a commit of their own. A conflict git
|
||||||
|
|
@ -64,6 +60,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { execFileSync } from 'node:child_process';
|
import { execFileSync } from 'node:child_process';
|
||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
attempt,
|
attempt,
|
||||||
|
|
@ -88,7 +87,8 @@ export const LOCKFILE = 'pnpm-lock.yaml';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paths whose conflicts are MECHANICAL: tool-generated files with a deterministic
|
* Paths whose conflicts are MECHANICAL: tool-generated files with a deterministic
|
||||||
* resolution, so no human judgement is lost by resolving them automatically.
|
* resolution during replay. Conflict PRs defer the lockfile but still pre-resolve the
|
||||||
|
* other paths.
|
||||||
* Keys are exact repo-relative paths; values pick the resolution strategy:
|
* Keys are exact repo-relative paths; values pick the resolution strategy:
|
||||||
* - 'pnpm-regen': pnpm natively merges a conflicted lockfile when regenerating
|
* - 'pnpm-regen': pnpm natively merges a conflicted lockfile when regenerating
|
||||||
* (`pnpm install --lockfile-only`).
|
* (`pnpm install --lockfile-only`).
|
||||||
|
|
@ -131,12 +131,18 @@ export function classifyPaths(paths) {
|
||||||
return { mechanical, code };
|
return { mechanical, code };
|
||||||
}
|
}
|
||||||
|
|
||||||
// A conflicted manifest makes lockfile regeneration meaningless until it is resolved
|
/** Run the trusted frozen install without using a store restored by the sync job. */
|
||||||
// (catalogs live in pnpm-workspace.yaml, so it counts as a manifest too).
|
export function validateLockfile(pnpm, env = process.env) {
|
||||||
export function blocksLockfileRegen(codePaths) {
|
const validationDir = join(env.RUNNER_TEMP || tmpdir(), `n8n-sync-lockfile-${randomUUID()}`);
|
||||||
return codePaths.some(
|
pnpm([
|
||||||
(p) => p === 'package.json' || p.endsWith('/package.json') || p === 'pnpm-workspace.yaml',
|
'install',
|
||||||
);
|
'--frozen-lockfile',
|
||||||
|
'--trust-lockfile',
|
||||||
|
'--store-dir',
|
||||||
|
join(validationDir, 'store'),
|
||||||
|
'--virtual-store-dir',
|
||||||
|
join(validationDir, 'virtual-store'),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -150,6 +156,12 @@ export function resolveMechanicalPath({ git, pnpm, path, masterSha, log = consol
|
||||||
// is required: pnpm flips `--frozen-lockfile` on by default when CI=true.
|
// is required: pnpm flips `--frozen-lockfile` on by default when CI=true.
|
||||||
log(`Regenerating ${path} with pnpm...`);
|
log(`Regenerating ${path} with pnpm...`);
|
||||||
pnpm(['install', '--lockfile-only', '--no-frozen-lockfile']);
|
pnpm(['install', '--lockfile-only', '--no-frozen-lockfile']);
|
||||||
|
try {
|
||||||
|
validateLockfile(pnpm);
|
||||||
|
} catch (error) {
|
||||||
|
git(['checkout', '--conflict=merge', '--', path]);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
git(['add', '--', path]);
|
git(['add', '--', path]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -305,6 +317,7 @@ export function reconcileWithMergeTreeAtTip({
|
||||||
*/
|
*/
|
||||||
export function reconcileLockfileAtTip({ git, pnpm, masterSha, log = console.log }) {
|
export function reconcileLockfileAtTip({ git, pnpm, masterSha, log = console.log }) {
|
||||||
pnpm(['install', '--lockfile-only', '--no-frozen-lockfile']);
|
pnpm(['install', '--lockfile-only', '--no-frozen-lockfile']);
|
||||||
|
validateLockfile(pnpm);
|
||||||
if (attempt(git, ['diff', '--quiet', '--', LOCKFILE]).ok) return;
|
if (attempt(git, ['diff', '--quiet', '--', LOCKFILE]).ok) return;
|
||||||
if (git(['rev-parse', 'HEAD']) === masterSha) {
|
if (git(['rev-parse', 'HEAD']) === masterSha) {
|
||||||
throw new Error('Lockfile reconciliation would amend a master commit; refusing.');
|
throw new Error('Lockfile reconciliation would amend a master commit; refusing.');
|
||||||
|
|
@ -316,28 +329,28 @@ export function reconcileLockfileAtTip({ git, pnpm, masterSha, log = console.log
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the conflict branch: master merged into 3.x with the conflict markers committed as
|
* Build the conflict branch: master merged into 3.x with the conflict markers committed as
|
||||||
* they are — except mechanical files, which are pre-resolved so the resolver only deals
|
* they are — except non-lockfile mechanical files, which are pre-resolved so the resolver
|
||||||
* with real code conflicts. The remaining markers are the review surface: the resolver sees
|
* only deals with code and lockfile conflicts. The remaining markers are the review surface:
|
||||||
* exactly what clashed, and the required checks stay red until they fix it, so the PR
|
* the resolver sees exactly what clashed, and the required checks stay red until they fix it,
|
||||||
* cannot be merged half-resolved (an auto-resolved branch would be green with master's
|
* so the PR cannot be merged half-resolved (an auto-resolved branch would be green with
|
||||||
* change silently dropped).
|
* master's change silently dropped).
|
||||||
*
|
*
|
||||||
* Delete/modify conflicts have no markers to leave, so they are resolved toward 3.x's side
|
* Delete/modify conflicts have no markers to leave, so they are resolved toward 3.x's side
|
||||||
* — the same side the replay favours — and reported separately. Left to `add -A` they would
|
* — the same side the replay favours — and reported separately. Left to `add -A` they would
|
||||||
* commit master's surviving blob instead, re-adding a file 3.x deleted on purpose with
|
* commit master's surviving blob instead, re-adding a file 3.x deleted on purpose with
|
||||||
* nothing in the diff to suggest a decision was made.
|
* nothing in the diff to suggest a decision was made.
|
||||||
*
|
*
|
||||||
* The lockfile is left with its markers when a manifest is among the code conflicts
|
* The lockfile is always left with its markers. pnpm install validation can give different
|
||||||
* (regenerating is meaningless until the manifests are resolved) or when the regen fails
|
* results while the merge index is unresolved, even with isolated stores. `lockfileDeferred`
|
||||||
* transiently — flagged via `lockfileDeferred` so the PR body carries the instruction.
|
* makes the PR body carry the resolver instruction.
|
||||||
*
|
*
|
||||||
* 3.x never carries the markers at its tip, and not for long in its history either: this
|
* 3.x never carries the markers at its tip, and not for long in its history either: this
|
||||||
* merge commit is dropped by the next replay, which takes the queue's commits only.
|
* merge commit is dropped by the next replay, which takes the queue's commits only.
|
||||||
*
|
*
|
||||||
* @returns {{ files: string[], deleteConflicts: Array<{path: string, deletedBy: string}>,
|
* @returns {{ files: string[], deleteConflicts: Array<{path: string, deletedBy: string}>,
|
||||||
* preResolved: string[], lockfileDeferred: boolean }}
|
* preResolved: string[], lockfileDeferred: boolean }}
|
||||||
* `files` is the marker-carrying list the PR reports, or every conflict when none are
|
* `files` is the code-conflict list, or the unresolved mechanical list when there are no
|
||||||
* code (a fallback after a failed auto-resolution); owners are attributed for both lists.
|
* code conflicts. Owners are attributed for both lists.
|
||||||
*/
|
*/
|
||||||
export function buildConflictBranch({
|
export function buildConflictBranch({
|
||||||
git,
|
git,
|
||||||
|
|
@ -361,8 +374,7 @@ export function buildConflictBranch({
|
||||||
const preResolved = [];
|
const preResolved = [];
|
||||||
let lockfileDeferred = false;
|
let lockfileDeferred = false;
|
||||||
for (const path of mechanical) {
|
for (const path of mechanical) {
|
||||||
const needsManifests = MECHANICAL_PATHS[path] === 'pnpm-regen' && blocksLockfileRegen(code);
|
if (path === LOCKFILE) {
|
||||||
if (needsManifests) {
|
|
||||||
lockfileDeferred = true;
|
lockfileDeferred = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -373,7 +385,6 @@ export function buildConflictBranch({
|
||||||
// Degrade gracefully (e.g. a transient registry failure): leave the markers
|
// Degrade gracefully (e.g. a transient registry failure): leave the markers
|
||||||
// for the resolver rather than failing the PR-opening path.
|
// for the resolver rather than failing the PR-opening path.
|
||||||
log(`warning: could not pre-resolve ${path}: ${error.message}`);
|
log(`warning: could not pre-resolve ${path}: ${error.message}`);
|
||||||
if (MECHANICAL_PATHS[path] === 'pnpm-regen') lockfileDeferred = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -393,8 +404,13 @@ export function buildConflictBranch({
|
||||||
|
|
||||||
git(['add', '-A']);
|
git(['add', '-A']);
|
||||||
git(['commit', '--no-edit', '--no-verify']);
|
git(['commit', '--no-edit', '--no-verify']);
|
||||||
|
const preResolvedSet = new Set(preResolved);
|
||||||
|
const unresolvedMechanical = mechanical.filter((path) => !preResolvedSet.has(path));
|
||||||
return {
|
return {
|
||||||
files: code.length > 0 ? code.filter((p) => !deleted.has(p)) : all,
|
files:
|
||||||
|
code.length > 0
|
||||||
|
? code.filter((path) => !deleted.has(path))
|
||||||
|
: unresolvedMechanical.filter((path) => !deleted.has(path)),
|
||||||
deleteConflicts,
|
deleteConflicts,
|
||||||
preResolved,
|
preResolved,
|
||||||
lockfileDeferred,
|
lockfileDeferred,
|
||||||
|
|
@ -543,7 +559,7 @@ export async function sync({
|
||||||
if (!merged.ok) {
|
if (!merged.ok) {
|
||||||
const { mechanical, code } = classifyPaths(merged.conflictedPaths);
|
const { mechanical, code } = classifyPaths(merged.conflictedPaths);
|
||||||
|
|
||||||
if (code.length === 0 && mechanical.length > 0) {
|
if (code.length === 0 && mechanical.length > 0 && !mechanical.includes(LOCKFILE)) {
|
||||||
log(
|
log(
|
||||||
`master conflicts with ${target} only on mechanical files (${mechanical.join(', ')}); auto-resolving.`,
|
`master conflicts with ${target} only on mechanical files (${mechanical.join(', ')}); auto-resolving.`,
|
||||||
);
|
);
|
||||||
|
|
@ -584,7 +600,9 @@ export async function sync({
|
||||||
log('Mechanical auto-resolution did not complete; falling back to a conflict PR.');
|
log('Mechanical auto-resolution did not complete; falling back to a conflict PR.');
|
||||||
} else {
|
} else {
|
||||||
log(
|
log(
|
||||||
`master conflicts with ${target} — leaving ${target} untouched and opening a conflict PR.`,
|
mechanical.includes(LOCKFILE)
|
||||||
|
? `master conflicts with ${target} on ${LOCKFILE} — deferring the lockfile and opening a conflict PR.`
|
||||||
|
: `master conflicts with ${target} — leaving ${target} untouched and opening a conflict PR.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
180
.github/scripts/sync-master-to-3x.test.mjs
vendored
180
.github/scripts/sync-master-to-3x.test.mjs
vendored
|
|
@ -1,11 +1,12 @@
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
import { test } from 'node:test';
|
import { test } from 'node:test';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
hasOpenConflictPr,
|
hasOpenConflictPr,
|
||||||
mergeTree,
|
mergeTree,
|
||||||
classifyPaths,
|
classifyPaths,
|
||||||
blocksLockfileRegen,
|
validateLockfile,
|
||||||
resolveMechanicalPath,
|
resolveMechanicalPath,
|
||||||
resolveQueueSidePath,
|
resolveQueueSidePath,
|
||||||
deleteModifyConflicts,
|
deleteModifyConflicts,
|
||||||
|
|
@ -87,6 +88,22 @@ const baseGitRoutes = [
|
||||||
const env = { GH_TOKEN: 'tok', GITHUB_REPOSITORY: 'n8n-io/n8n' };
|
const env = { GH_TOKEN: 'tok', GITHUB_REPOSITORY: 'n8n-io/n8n' };
|
||||||
const noOpenPr = [[(a) => a[0] === 'pr' && a[1] === 'list', '[]']];
|
const noOpenPr = [[(a) => a[0] === 'pr' && a[1] === 'list', '[]']];
|
||||||
|
|
||||||
|
function isolatedValidationPaths(args) {
|
||||||
|
assert.deepEqual(args.slice(0, 3), ['install', '--frozen-lockfile', '--trust-lockfile']);
|
||||||
|
assert.equal(args.includes('--force'), false);
|
||||||
|
assert.equal(args.length, 7);
|
||||||
|
const storeDirIndex = args.indexOf('--store-dir');
|
||||||
|
const virtualStoreDirIndex = args.indexOf('--virtual-store-dir');
|
||||||
|
assert.ok(storeDirIndex >= 3);
|
||||||
|
assert.ok(virtualStoreDirIndex >= 3);
|
||||||
|
const storeDir = args[storeDirIndex + 1];
|
||||||
|
const virtualStoreDir = args[virtualStoreDirIndex + 1];
|
||||||
|
assert.ok(storeDir);
|
||||||
|
assert.ok(virtualStoreDir);
|
||||||
|
assert.notEqual(storeDir, virtualStoreDir);
|
||||||
|
return { storeDir, virtualStoreDir };
|
||||||
|
}
|
||||||
|
|
||||||
test('targetBranch defaults to 3.x and honours the rehearsal override', () => {
|
test('targetBranch defaults to 3.x and honours the rehearsal override', () => {
|
||||||
assert.equal(targetBranch({}), TARGET_BRANCH);
|
assert.equal(targetBranch({}), TARGET_BRANCH);
|
||||||
assert.equal(targetBranch({ SYNC_TARGET_BRANCH: '3x-sync-test' }), '3x-sync-test');
|
assert.equal(targetBranch({ SYNC_TARGET_BRANCH: '3x-sync-test' }), '3x-sync-test');
|
||||||
|
|
@ -135,7 +152,7 @@ test('mergeTree reports the tree when clean, and the conflicted paths when the s
|
||||||
assert.deepEqual(res.conflictedPaths, [LOCKFILE, 'packages/cli/x.ts']);
|
assert.deepEqual(res.conflictedPaths, [LOCKFILE, 'packages/cli/x.ts']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('classifyPaths and blocksLockfileRegen split mechanical from code conflicts', () => {
|
test('classifyPaths splits mechanical from code conflicts', () => {
|
||||||
const { mechanical, code } = classifyPaths([
|
const { mechanical, code } = classifyPaths([
|
||||||
LOCKFILE,
|
LOCKFILE,
|
||||||
'packages/cli/x.ts',
|
'packages/cli/x.ts',
|
||||||
|
|
@ -148,11 +165,23 @@ test('classifyPaths and blocksLockfileRegen split mechanical from code conflicts
|
||||||
'.github/test-metrics/e2e-impact-map.json',
|
'.github/test-metrics/e2e-impact-map.json',
|
||||||
]);
|
]);
|
||||||
assert.deepEqual(code, ['packages/cli/x.ts']);
|
assert.deepEqual(code, ['packages/cli/x.ts']);
|
||||||
|
});
|
||||||
|
|
||||||
assert.equal(blocksLockfileRegen(['packages/cli/package.json']), true);
|
test('validateLockfile uses fresh stores under the configured temporary directory', () => {
|
||||||
assert.equal(blocksLockfileRegen(['package.json']), true);
|
const pnpm = makeStub();
|
||||||
assert.equal(blocksLockfileRegen(['pnpm-workspace.yaml']), true);
|
validateLockfile(pnpm, { RUNNER_TEMP: '/runner-temp' });
|
||||||
assert.equal(blocksLockfileRegen(['packages/cli/x.ts']), false);
|
validateLockfile(pnpm, { RUNNER_TEMP: '/runner-temp' });
|
||||||
|
validateLockfile(pnpm, {});
|
||||||
|
|
||||||
|
const first = isolatedValidationPaths(pnpm.calls[0]);
|
||||||
|
const second = isolatedValidationPaths(pnpm.calls[1]);
|
||||||
|
const fallback = isolatedValidationPaths(pnpm.calls[2]);
|
||||||
|
assert.ok(first.storeDir.startsWith('/runner-temp/'));
|
||||||
|
assert.ok(first.virtualStoreDir.startsWith('/runner-temp/'));
|
||||||
|
assert.notEqual(first.storeDir, second.storeDir);
|
||||||
|
assert.notEqual(first.virtualStoreDir, second.virtualStoreDir);
|
||||||
|
assert.ok(fallback.storeDir.startsWith(`${tmpdir()}/`));
|
||||||
|
assert.ok(fallback.virtualStoreDir.startsWith(`${tmpdir()}/`));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resolveMechanicalPath takes the blob from master, or the deletion when master removed the file', () => {
|
test('resolveMechanicalPath takes the blob from master, or the deletion when master removed the file', () => {
|
||||||
|
|
@ -181,12 +210,14 @@ test('resolveMechanicalPath takes the blob from master, or the deletion when mas
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resolveMechanicalPath regenerates the lockfile with pnpm and stages it', () => {
|
test('resolveMechanicalPath regenerates and applies patches before staging the lockfile', () => {
|
||||||
const git = makeStub();
|
const git = makeStub();
|
||||||
const pnpm = makeStub();
|
const pnpm = makeStub();
|
||||||
resolveMechanicalPath({ git, pnpm, path: LOCKFILE, masterSha: MASTER, log: () => {} });
|
resolveMechanicalPath({ git, pnpm, path: LOCKFILE, masterSha: MASTER, log: () => {} });
|
||||||
// `--no-frozen-lockfile` is load-bearing: pnpm defaults to frozen when CI=true.
|
// Regeneration must override CI's frozen default. Validation must use isolated stores.
|
||||||
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
|
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
|
||||||
|
isolatedValidationPaths(pnpm.calls[1]);
|
||||||
|
assert.equal(pnpm.calls.length, 2);
|
||||||
assert.ok(git.calls.some((a) => a[0] === 'add' && a.includes(LOCKFILE)));
|
assert.ok(git.calls.some((a) => a[0] === 'add' && a.includes(LOCKFILE)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -417,8 +448,26 @@ test('reconcileLockfileAtTip folds an inconsistent lockfile into the tip commit,
|
||||||
const pnpm = makeStub();
|
const pnpm = makeStub();
|
||||||
reconcileLockfileAtTip({ git: inconsistent, pnpm, masterSha: MASTER, log: () => {} });
|
reconcileLockfileAtTip({ git: inconsistent, pnpm, masterSha: MASTER, log: () => {} });
|
||||||
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
|
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
|
||||||
|
isolatedValidationPaths(pnpm.calls[1]);
|
||||||
|
assert.equal(pnpm.calls.length, 2);
|
||||||
assert.ok(inconsistent.calls.some((a) => a[0] === 'commit' && a.includes('--amend')));
|
assert.ok(inconsistent.calls.some((a) => a[0] === 'commit' && a.includes('--amend')));
|
||||||
|
|
||||||
|
const validationGit = makeStub();
|
||||||
|
const invalid = makeStub([
|
||||||
|
[(a) => a.includes('--frozen-lockfile'), fail('ERR_PNPM_PATCH_FAILED')],
|
||||||
|
]);
|
||||||
|
assert.throws(
|
||||||
|
() =>
|
||||||
|
reconcileLockfileAtTip({
|
||||||
|
git: validationGit,
|
||||||
|
pnpm: invalid,
|
||||||
|
masterSha: MASTER,
|
||||||
|
log: () => {},
|
||||||
|
}),
|
||||||
|
/command failed/,
|
||||||
|
);
|
||||||
|
assert.equal(validationGit.calls.length, 0, 'validation must fail before diff or amend checks');
|
||||||
|
|
||||||
const atMasterTip = makeStub([
|
const atMasterTip = makeStub([
|
||||||
[(a) => a[0] === 'diff', fail()],
|
[(a) => a[0] === 'diff', fail()],
|
||||||
[(a) => a[0] === 'rev-parse', MASTER],
|
[(a) => a[0] === 'rev-parse', MASTER],
|
||||||
|
|
@ -647,47 +696,39 @@ test('sync fails without pushing when even the favoured replay cannot finish', a
|
||||||
assert.equal(git.calls.filter((a) => a[0] === 'rebase' && a[1] === '--abort').length, 2);
|
assert.equal(git.calls.filter((a) => a[0] === 'rebase' && a[1] === '--abort').length, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sync auto-resolves a lockfile-only conflict during the replay — no PR, no commit', async () => {
|
test('sync opens a conflict PR for a lockfile-only conflict and defers the lockfile', async () => {
|
||||||
const git = makeStub([
|
const git = makeStub([
|
||||||
...baseGitRoutes.filter((r) => !r[0](['merge-tree'])),
|
...baseGitRoutes.filter((r) => !r[0](['merge-tree'])),
|
||||||
[(a) => a[0] === 'merge-tree', conflictedMergeTree(LOCKFILE)],
|
[(a) => a[0] === 'merge-tree', conflictedMergeTree(LOCKFILE)],
|
||||||
[(a) => a[0] === 'rebase' && a[1] === '--continue', ''],
|
[(a) => a[0] === 'merge', fail(`CONFLICT (content): Merge conflict in ${LOCKFILE}`)],
|
||||||
[isRebase, fail(`CONFLICT (content): Merge conflict in ${LOCKFILE}`)],
|
|
||||||
[isConflictedFiles, LOCKFILE],
|
[isConflictedFiles, LOCKFILE],
|
||||||
[(a) => a[0] === 'diff' && a.includes('--quiet'), ''], // tip lockfile already consistent
|
[(a) => a[0] === 'log', 'breaking-sha'],
|
||||||
[(a) => a[0] === 'diff-index', fail()], // staged resolution -> continue, not skip
|
]);
|
||||||
|
const gh = makeStub([
|
||||||
|
...noOpenPr,
|
||||||
|
[(a) => a[0] === 'pr' && a[1] === 'create', 'https://github.com/n8n-io/n8n/pull/99'],
|
||||||
]);
|
]);
|
||||||
const gh = makeStub(noOpenPr);
|
|
||||||
const pnpm = makeStub();
|
const pnpm = makeStub();
|
||||||
|
|
||||||
await sync({ git, gh, pnpm, env, log: () => {} });
|
await sync({ git, gh, pnpm, env, fetchFn: okFetch(['alice']), log: () => {} });
|
||||||
|
|
||||||
// The stall regen plus the tip reconciliation check.
|
assert.equal(pnpm.calls.length, 0, 'the conflict-PR path must not run pnpm');
|
||||||
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
|
|
||||||
assert.equal(pnpm.calls.length, 2);
|
|
||||||
assert.ok(git.calls.some((a) => a[0] === 'add' && a.includes(LOCKFILE)));
|
|
||||||
assert.ok(git.calls.some((a) => a[0] === 'rebase' && a[1] === '--continue'));
|
|
||||||
const push = git.calls.find((a) => a[0] === 'push');
|
|
||||||
assert.equal(push[1], `--force-with-lease=refs/heads/${TARGET_BRANCH}:${PRE_HEAD}`);
|
|
||||||
// No human surface: no merge commit, no amend, no conflict PR.
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
git.calls.some((a) => a[0] === 'merge'),
|
git.calls.some((a) => a[0] === 'rebase'),
|
||||||
false,
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
git.calls.some((a) => a[0] === 'commit'),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
assert.equal(
|
|
||||||
gh.calls.some((a) => a[0] === 'pr' && a[1] === 'create'),
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
const create = gh.calls.find((a) => a[0] === 'pr' && a[1] === 'create');
|
||||||
|
assert.ok(create, 'expected a conflict PR');
|
||||||
|
assert.match(create[create.indexOf('--body') + 1], /pnpm-lock\.yaml.*conflict markers/);
|
||||||
|
const pushes = git.calls.filter((a) => a[0] === 'push');
|
||||||
|
assert.equal(pushes.length, 1);
|
||||||
|
assert.equal(pushes[0].at(-1), `HEAD:refs/heads/${SYNC_BRANCH}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sync falls back to a conflict PR when mechanical auto-resolution cannot complete', async () => {
|
test('sync falls back to a conflict PR when mechanical auto-resolution cannot complete', async () => {
|
||||||
const git = makeStub([
|
const git = makeStub([
|
||||||
...baseGitRoutes.filter((r) => !r[0](['merge-tree'])),
|
...baseGitRoutes.filter((r) => !r[0](['merge-tree'])),
|
||||||
[(a) => a[0] === 'merge-tree', conflictedMergeTree(LOCKFILE)],
|
[(a) => a[0] === 'merge-tree', conflictedMergeTree(POPULARITY)],
|
||||||
[isRebase, fail('CONFLICT')],
|
[isRebase, fail('CONFLICT')],
|
||||||
// Both replay attempts stall on a code file the endpoints do not reconcile.
|
// Both replay attempts stall on a code file the endpoints do not reconcile.
|
||||||
[isConflictedFiles, 'packages/cli/x.ts'],
|
[isConflictedFiles, 'packages/cli/x.ts'],
|
||||||
|
|
@ -793,7 +834,7 @@ test('buildConflictBranch resolves marker-less delete/modify conflicts toward 3.
|
||||||
assert.ok(git.calls.some((a) => a[0] === 'checkout' && a.includes('--ours')));
|
assert.ok(git.calls.some((a) => a[0] === 'checkout' && a.includes('--ours')));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('buildConflictBranch pre-resolves mechanical files so only code conflicts remain', () => {
|
test('buildConflictBranch defers the lockfile with code and pre-resolves other mechanical files', () => {
|
||||||
const git = makeStub([
|
const git = makeStub([
|
||||||
[(a) => a[0] === 'merge', fail('CONFLICT')],
|
[(a) => a[0] === 'merge', fail('CONFLICT')],
|
||||||
[isConflictedFiles, `packages/cli/x.ts\n${LOCKFILE}\n${POPULARITY}`],
|
[isConflictedFiles, `packages/cli/x.ts\n${LOCKFILE}\n${POPULARITY}`],
|
||||||
|
|
@ -809,40 +850,20 @@ test('buildConflictBranch pre-resolves mechanical files so only code conflicts r
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.deepEqual(files, ['packages/cli/x.ts']);
|
assert.deepEqual(files, ['packages/cli/x.ts']);
|
||||||
assert.deepEqual(preResolved, [LOCKFILE, POPULARITY]);
|
assert.deepEqual(preResolved, [POPULARITY]);
|
||||||
assert.equal(lockfileDeferred, false);
|
assert.equal(lockfileDeferred, true);
|
||||||
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
|
assert.equal(pnpm.calls.length, 0);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
git.calls.some((a) => a[0] === 'checkout' && a[1] === MASTER && a.includes(POPULARITY)),
|
git.calls.some((a) => a[0] === 'checkout' && a[1] === MASTER && a.includes(POPULARITY)),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('buildConflictBranch defers the lockfile when a manifest is conflicted too', () => {
|
test('buildConflictBranch defers the lockfile with a code conflict without running pnpm', () => {
|
||||||
const git = makeStub([
|
|
||||||
[(a) => a[0] === 'merge', fail('CONFLICT')],
|
|
||||||
[isConflictedFiles, `packages/cli/package.json\n${LOCKFILE}`],
|
|
||||||
]);
|
|
||||||
const pnpm = makeStub();
|
|
||||||
|
|
||||||
const { files, preResolved, lockfileDeferred } = buildConflictBranch({
|
|
||||||
git,
|
|
||||||
pnpm,
|
|
||||||
masterSha: MASTER,
|
|
||||||
log: () => {},
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.deepEqual(files, ['packages/cli/package.json']);
|
|
||||||
assert.deepEqual(preResolved, []);
|
|
||||||
assert.equal(lockfileDeferred, true);
|
|
||||||
assert.equal(pnpm.calls.length, 0, 'regen is meaningless until the manifests are resolved');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('buildConflictBranch degrades to a deferred lockfile when the regen fails', () => {
|
|
||||||
const git = makeStub([
|
const git = makeStub([
|
||||||
[(a) => a[0] === 'merge', fail('CONFLICT')],
|
[(a) => a[0] === 'merge', fail('CONFLICT')],
|
||||||
[isConflictedFiles, `packages/cli/x.ts\n${LOCKFILE}`],
|
[isConflictedFiles, `packages/cli/x.ts\n${LOCKFILE}`],
|
||||||
]);
|
]);
|
||||||
const pnpm = makeStub([[() => true, fail('ERR_PNPM_REGISTRY unreachable')]]);
|
const pnpm = makeStub();
|
||||||
|
|
||||||
const { files, preResolved, lockfileDeferred } = buildConflictBranch({
|
const { files, preResolved, lockfileDeferred } = buildConflictBranch({
|
||||||
git,
|
git,
|
||||||
|
|
@ -854,9 +875,35 @@ test('buildConflictBranch degrades to a deferred lockfile when the regen fails',
|
||||||
assert.deepEqual(files, ['packages/cli/x.ts']);
|
assert.deepEqual(files, ['packages/cli/x.ts']);
|
||||||
assert.deepEqual(preResolved, []);
|
assert.deepEqual(preResolved, []);
|
||||||
assert.equal(lockfileDeferred, true);
|
assert.equal(lockfileDeferred, true);
|
||||||
|
assert.equal(pnpm.calls.length, 0, 'the conflict-PR path must not run pnpm');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('buildConflictBranch reports only the deferred lockfile after resolving another mechanical file', () => {
|
||||||
|
const git = makeStub([
|
||||||
|
[(a) => a[0] === 'merge', fail('CONFLICT')],
|
||||||
|
[isConflictedFiles, `${LOCKFILE}\n${POPULARITY}`],
|
||||||
|
[(a) => a[0] === 'cat-file', ''],
|
||||||
|
]);
|
||||||
|
const pnpm = makeStub();
|
||||||
|
|
||||||
|
const { files, preResolved, lockfileDeferred } = buildConflictBranch({
|
||||||
|
git,
|
||||||
|
pnpm,
|
||||||
|
masterSha: MASTER,
|
||||||
|
log: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(files, [LOCKFILE]);
|
||||||
|
assert.deepEqual(preResolved, [POPULARITY]);
|
||||||
|
assert.equal(lockfileDeferred, true);
|
||||||
|
assert.equal(pnpm.calls.length, 0);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
git.calls.some((a) => a[0] === 'commit'),
|
git.calls.some((a) => a[0] === 'checkout' && a[1] === MASTER && a.includes(POPULARITY)),
|
||||||
'the conflict branch must still be committed',
|
);
|
||||||
|
assert.equal(
|
||||||
|
git.calls.some((a) => a[0] === 'checkout' && a.includes(LOCKFILE)),
|
||||||
|
false,
|
||||||
|
'the lockfile conflict markers must stay untouched',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -915,7 +962,7 @@ test('sync opens a draft conflict PR and leaves 3.x untouched on a real conflict
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sync reports only the code conflicts on a mixed conflict, with mechanical files pre-resolved', async () => {
|
test('sync reports the code conflict and defers the lockfile on a mixed conflict', async () => {
|
||||||
const git = makeStub([
|
const git = makeStub([
|
||||||
...baseGitRoutes.filter((r) => !r[0](['merge-tree'])),
|
...baseGitRoutes.filter((r) => !r[0](['merge-tree'])),
|
||||||
[(a) => a[0] === 'merge-tree', conflictedMergeTree(LOCKFILE, 'packages/cli/x.ts')],
|
[(a) => a[0] === 'merge-tree', conflictedMergeTree(LOCKFILE, 'packages/cli/x.ts')],
|
||||||
|
|
@ -931,16 +978,13 @@ test('sync reports only the code conflicts on a mixed conflict, with mechanical
|
||||||
|
|
||||||
await sync({ git, gh, pnpm, env, fetchFn: okFetch(['alice']), log: () => {} });
|
await sync({ git, gh, pnpm, env, fetchFn: okFetch(['alice']), log: () => {} });
|
||||||
|
|
||||||
assert.equal(pnpm.calls.length, 1, 'the lockfile is regenerated for the conflict branch');
|
assert.equal(pnpm.calls.length, 0, 'the conflict-PR path must not run pnpm');
|
||||||
|
|
||||||
const create = gh.calls.find((a) => a[0] === 'pr' && a[1] === 'create');
|
const create = gh.calls.find((a) => a[0] === 'pr' && a[1] === 'create');
|
||||||
const body = create[create.indexOf('--body') + 1];
|
const body = create[create.indexOf('--body') + 1];
|
||||||
assert.match(body, /### Conflicted files\n- `packages\/cli\/x\.ts`/);
|
assert.match(body, /### Conflicted files\n- `packages\/cli\/x\.ts`/);
|
||||||
assert.match(body, /### Auto-resolved for you/);
|
assert.doesNotMatch(body, /### Auto-resolved for you/);
|
||||||
assert.ok(
|
assert.match(body, /pnpm-lock\.yaml.*conflict markers/);
|
||||||
body.indexOf(LOCKFILE) > body.indexOf('Auto-resolved'),
|
|
||||||
'the lockfile belongs to the auto-resolved section',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Owner attribution is scoped to the real code conflicts only.
|
// Owner attribution is scoped to the real code conflicts only.
|
||||||
const attributions = git.calls.filter((a) => a[0] === 'log' && a.includes('--format=%H'));
|
const attributions = git.calls.filter((a) => a[0] === 'log' && a.includes('--format=%H'));
|
||||||
|
|
|
||||||
34
.github/scripts/test-files.mjs
vendored
Normal file
34
.github/scripts/test-files.mjs
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { matchesGlob } from './glob.mjs';
|
||||||
|
|
||||||
|
export const TEST_PATTERNS = [
|
||||||
|
// Test files (by extension)
|
||||||
|
'**/*.test.ts',
|
||||||
|
'**/*.test.js',
|
||||||
|
'**/*.test.mjs',
|
||||||
|
'**/*.spec.ts',
|
||||||
|
'**/*.spec.js',
|
||||||
|
'**/*.spec.mjs',
|
||||||
|
// Test directories
|
||||||
|
'**/test/**',
|
||||||
|
'**/tests/**',
|
||||||
|
'**/__tests__/**',
|
||||||
|
// Snapshots
|
||||||
|
'**/__snapshots__/**',
|
||||||
|
'**/*.snap',
|
||||||
|
// Fixtures and mocks
|
||||||
|
'**/fixtures/**',
|
||||||
|
'**/__mocks__/**',
|
||||||
|
// Former packages/testing workspaces
|
||||||
|
'packages/quality/policy/**',
|
||||||
|
'packages/quality/testing/**',
|
||||||
|
'packages/quality/environments/**',
|
||||||
|
'packages/quality/efficiency/microbenchmarks/**',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param { string } filename
|
||||||
|
* @returns { boolean }
|
||||||
|
*/
|
||||||
|
export function isTestFile(filename) {
|
||||||
|
return TEST_PATTERNS.some((pattern) => matchesGlob(filename, pattern));
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user