@@ -48,10 +48,18 @@ function run(): void {
4848
4949 const { base, head = 'HEAD' , optional } = values ;
5050
51+ // For GitHub Action debugging
52+ // eslint-disable-next-line no-console
53+ console . error ( `Parsed command line arguments: base=${ base } , head=${ head } , optional=${ optional } ` ) ;
54+
5155 const testApplications = globSync ( '*/package.json' , {
5256 cwd : `${ __dirname } /../test-applications` ,
5357 } ) . map ( filePath => dirname ( filePath ) ) ;
5458
59+ // For GitHub Action debugging (using stderr the 'matrix=...' output is not polluted)
60+ // eslint-disable-next-line no-console
61+ console . error ( `Discovered ${ testApplications . length } test applications: ${ testApplications . join ( ', ' ) } ` ) ;
62+
5563 // If `--base=xxx` is defined, we only want to get test applications changed since that base
5664 // Else, we take all test applications (e.g. on push)
5765 const includedTestApplications = base
@@ -137,11 +145,22 @@ function getAffectedTestApplications(
137145 additionalArgs . push ( `--head=${ head } ` ) ;
138146 }
139147
140- const affectedProjects = execSync ( `yarn --silent nx show projects --affected ${ additionalArgs . join ( ' ' ) } ` )
141- . toString ( )
142- . split ( '\n' )
143- . map ( line => line . trim ( ) )
144- . filter ( Boolean ) ;
148+ let affectedProjects : string [ ] = [ ] ;
149+ try {
150+ affectedProjects = execSync ( `yarn --silent nx show projects --affected ${ additionalArgs . join ( ' ' ) } ` )
151+ . toString ( )
152+ . split ( '\n' )
153+ . map ( line => line . trim ( ) )
154+ . filter ( Boolean ) ;
155+ } catch ( error ) {
156+ // eslint-disable-next-line no-console
157+ console . error ( 'Failed to compute affected projects via Nx. Running all tests instead.' , error ) ;
158+ return testApplications ;
159+ }
160+
161+ // For GitHub Action debugging
162+ // eslint-disable-next-line no-console
163+ console . error ( `Nx affected projects (${ affectedProjects . length } ): ${ JSON . stringify ( affectedProjects ) } ` ) ;
145164
146165 // If something in e2e tests themselves are changed, check if only test applications were changed
147166 if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
@@ -150,12 +169,19 @@ function getAffectedTestApplications(
150169
151170 // Shared code was changed, run all tests
152171 if ( changedTestApps === false ) {
172+ // eslint-disable-next-line no-console
173+ console . error ( 'Shared e2e code changed. Running all test applications.' ) ;
153174 return testApplications ;
154175 }
155176
156177 // Only test applications that were changed, run selectively
157178 if ( changedTestApps . size > 0 ) {
158- return testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
179+ const selected = testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
180+ // eslint-disable-next-line no-console
181+ console . error (
182+ `Only changed test applications will run (${ selected . length } ): ${ JSON . stringify ( Array . from ( changedTestApps ) ) } ` ,
183+ ) ;
184+ return selected ;
159185 }
160186 } catch ( error ) {
161187 // eslint-disable-next-line no-console
@@ -182,6 +208,10 @@ function getChangedTestApps(base: string, head?: string): false | Set<string> {
182208 . map ( line => line . trim ( ) )
183209 . filter ( Boolean ) ;
184210
211+ // For GitHub Action debugging
212+ // eslint-disable-next-line no-console
213+ console . error ( `Changed files since ${ base } ${ head ? `..${ head } ` : '' } : ${ JSON . stringify ( changedFiles ) } ` ) ;
214+
185215 const changedTestApps : Set < string > = new Set ( ) ;
186216 const testAppsPrefix = 'dev-packages/e2e-tests/test-applications/' ;
187217
0 commit comments