1- // Decides which CI jobs a change needs. Prints `key=value` lines for
2- // $GITHUB_OUTPUT; a job runs unless its key is "false".
3- //
4- // node ci-changes.cjs --paths <file> gate by the listed paths
5- // node ci-changes.cjs --paths <file> --full run every Linux job, gate only the macOS lint
6- // node ci-changes.cjs changed paths unknown: run everything
7- //
8- // Every changed path maps to workspace packages, which then pull in their
9- // dependents from package.json. A path this file does not recognize runs
10- // everything, so a new root file or directory can only cost minutes.
1+ // Unknown paths run every job; recognized packages pull in their dependents.
2+ // scripts/check-changed.ts shares these decisions so local checks match CI.
113const fs = require ( "node:fs" ) ;
124const path = require ( "node:path" ) ;
135
146const root = path . resolve ( __dirname , "../.." ) ;
157
16- // Never read by a build, typecheck, or test. Lint still formats them.
178const INERT = [
189 / ^ d o c s \/ / ,
1910 / ^ \. ( a g e n t s | c u r s o r | v s c o d e | d e v c o n t a i n e r | m a c r o s c o p e | r e p o s ) \/ / ,
2011 / ^ [ ^ / ] + \. m d $ / ,
2112 / ^ L I C E N S E $ / ,
2213] ;
2314
24- // Run everything: the root vite.config.ts loads the first as setup for every
25- // package's tests, and the vendored mobile tarballs are installed dependencies.
15+ // Shared test setup and vendored mobile dependencies affect every package.
2616const RUNS_EVERYTHING = [
2717 / ^ p a c k a g e s \/ s h a r e d \/ s r c \/ ( H o s t P r o c e s s | t e s t i n g \/ l o n g T e m p D i r ) \. t s $ / ,
2818 / ^ a p p s \/ m o b i l e \/ d e p s \/ / ,
2919] ;
3020
31- // Paths outside a package, or files inside one that other packages read
32- // through relative imports rather than a package.json dependency.
21+ // Includes cross-package reads absent from package.json dependencies.
3322const EXTRA_OWNERS = [
3423 // Vite configs and tsconfigs of these apps import scripts/lib directly.
3524 [ / ^ s c r i p t s \/ l i b \/ / , [ "@t3tools/desktop" , "@t3tools/mobile" , "@t3tools/web" , "t3" ] ] ,
3625 // scripts/build-desktop-artifact.ts reads the GNOME extension manifest.
3726 [ / ^ a p p s \/ d e s k t o p \/ g n o m e - e x t e n s i o n \/ / , [ "@t3tools/scripts" ] ] ,
3827 [ / ^ n a t i v e \/ b r o w s e r - s e c r e t \/ / , [ "@t3tools/desktop" ] ] ,
28+ [ / ^ n a t i v e \/ k d e - s n a p - s h o t \/ / , [ "@t3tools/desktop" ] ] ,
3929 [ / ^ n a t i v e \/ l i b g h o s t t y - v t \/ / , [ "@t3tools/web" ] ] ,
4030] ;
4131const RUST = / ^ n a t i v e \/ ( r e s o u r c e - m o n i t o r | k d e - s n a p - s h o t | h y p r l a n d - s n a p - s h o t ) \/ / ;
4232
43- // Tests that read another package's files without declaring it. The scripts
44- // tests read app manifests, assets, and sources (cursor-sdk-packaging,
45- // third-party-licenses, brand-assets, build-desktop-artifact).
33+ // These tests read other packages without declaring dependencies.
4634const TEST_ONLY_DEPS = {
4735 "@t3tools/provider-pi" : [ "@t3tools/client-runtime" ] ,
4836 "@t3tools/scripts" : [
@@ -53,17 +41,12 @@ const TEST_ONLY_DEPS = {
5341 "@t3tools/provider-cursor" ,
5442 ] ,
5543} ;
56- // Declared dependencies that only feed a build step: the server bundles the
57- // built web app (apps/server/vite.config.ts) but never imports it.
44+ // The server bundles the web build without importing it.
5845const BUILD_ONLY_DEPS = { t3 : [ "@t3tools/web" ] } ;
5946
60- // Sources scripts/mobile-native-static-check.ts lints, plus the tool and rule
61- // configuration that decides how it lints them, plus the root package.json
62- // that defines the lint:mobile command.
6347const MOBILE_NATIVE =
6448 / ^ a p p s \/ m o b i l e \/ .* \. ( s w i f t | k t | k t s ) $ | ^ a p p s \/ m o b i l e \/ ( \. s w i f t l i n t \. y m l | d e t e k t \. y m l | \. e d i t o r c o n f i g | B r e w f i l e ) $ | ^ s c r i p t s \/ m o b i l e - n a t i v e - s t a t i c - c h e c k \. t s $ | ^ p a c k a g e \. j s o n $ | ^ \. g i t h u b \/ w o r k f l o w s \/ c i \. y m l $ | ^ \. g i t h u b \/ s c r i p t s \/ c i - c h a n g e s \. c j s $ | ^ \. g i t h u b \/ a c t i o n s \/ c i - c h a n g e s \/ / ;
6549
66- // Jobs that test every package except these, which have jobs of their own.
6750const OWN_TEST_JOB = new Set ( [ "t3" , "@t3tools/web" , "@t3tools/monorepo" ] ) ;
6851
6952function readWorkspace ( ) {
@@ -105,17 +88,16 @@ function readWorkspace() {
10588 return packages ;
10689}
10790
108- // Returns the packages a path touches, [] for an inert path, or null when the
109- // path is not understood and everything must run.
91+ // [] means inert; null means unknown and requires every job.
11092function ownersOf ( file , packages ) {
11193 if ( INERT . some ( ( pattern ) => pattern . test ( file ) ) ) return [ ] ;
11294 // A manifest can change dependencies or versions other packages read.
11395 if ( path . posix . basename ( file ) === "package.json" ) return null ;
11496 if ( RUNS_EVERYTHING . some ( ( pattern ) => pattern . test ( file ) ) ) return null ;
97+ const extra = EXTRA_OWNERS . flatMap ( ( [ pattern , names ] ) => ( pattern . test ( file ) ? names : [ ] ) ) ;
11598 // scripts/build-desktop-artifact.test.ts reads the crates' sources.
116- if ( RUST . test ( file ) ) return [ "@t3tools/scripts" ] ;
99+ if ( RUST . test ( file ) ) return [ "@t3tools/scripts" , ... extra ] ;
117100
118- const extra = EXTRA_OWNERS . flatMap ( ( [ pattern , names ] ) => ( pattern . test ( file ) ? names : [ ] ) ) ;
119101 const owner = packages
120102 . filter ( ( pkg ) => file . startsWith ( `${ pkg . dir } /` ) )
121103 . sort ( ( a , b ) => b . dir . length - a . dir . length ) [ 0 ] ;
@@ -145,7 +127,6 @@ function decide(files, packages, full) {
145127 if ( everything ) {
146128 affected = all ;
147129 } else {
148- // Add dependents until nothing changes.
149130 let grew = true ;
150131 while ( grew ) {
151132 grew = false ;
@@ -200,4 +181,6 @@ function main() {
200181 for ( const [ key , value ] of Object . entries ( outputs ) ) console . log ( `${ key } =${ value } ` ) ;
201182}
202183
203- main ( ) ;
184+ module . exports = { readWorkspace, decide } ;
185+
186+ if ( require . main === module ) main ( ) ;
0 commit comments