@@ -48,10 +48,24 @@ function run(): void {
48
48
49
49
const { base, head = 'HEAD' , optional } = values ;
50
50
51
+ // For GitHub Action debugging
52
+ // eslint-disable-next-line no-console
53
+ console . log ( `Parsed command line arguments: base=${ base } , head=${ head } , optional=${ optional } ` ) ;
54
+
51
55
const testApplications = globSync ( '*/package.json' , {
52
56
cwd : `${ __dirname } /../test-applications` ,
53
57
} ) . map ( filePath => dirname ( filePath ) ) ;
54
58
59
+ // For GitHub Action debugging
60
+ // eslint-disable-next-line no-console
61
+ console . log (
62
+ `Discovered ${ testApplications . length } test applications${
63
+ testApplications . length > 0
64
+ ? ` (sample: ${ JSON . stringify ( testApplications . slice ( 0 , 10 ) ) } ${ testApplications . length > 10 ? ' …' : '' } )`
65
+ : ''
66
+ } `,
67
+ ) ;
68
+
55
69
// If `--base=xxx` is defined, we only want to get test applications changed since that base
56
70
// Else, we take all test applications (e.g. on push)
57
71
const includedTestApplications = base
@@ -137,11 +151,22 @@ function getAffectedTestApplications(
137
151
additionalArgs . push ( `--head=${ head } ` ) ;
138
152
}
139
153
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 ) ;
154
+ let affectedProjects : string [ ] = [ ] ;
155
+ try {
156
+ affectedProjects = execSync ( `yarn --silent nx show projects --affected ${ additionalArgs . join ( ' ' ) } ` )
157
+ . toString ( )
158
+ . split ( '\n' )
159
+ . map ( line => line . trim ( ) )
160
+ . filter ( Boolean ) ;
161
+ } catch ( error ) {
162
+ // eslint-disable-next-line no-console
163
+ console . warn ( 'Failed to compute affected projects via Nx. Running all tests instead.' , error ) ;
164
+ return testApplications ;
165
+ }
166
+
167
+ // For GitHub Action debugging
168
+ // eslint-disable-next-line no-console
169
+ console . log ( 'Nx affected projects:' , JSON . stringify ( affectedProjects ) ) ;
145
170
146
171
// If something in e2e tests themselves are changed, check if only test applications were changed
147
172
if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
@@ -150,12 +175,19 @@ function getAffectedTestApplications(
150
175
151
176
// Shared code was changed, run all tests
152
177
if ( changedTestApps === false ) {
178
+ // eslint-disable-next-line no-console
179
+ console . log ( 'Shared e2e code changed. Running all test applications.' ) ;
153
180
return testApplications ;
154
181
}
155
182
156
183
// Only test applications that were changed, run selectively
157
184
if ( changedTestApps . size > 0 ) {
158
- return testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
185
+ const selected = testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
186
+ // eslint-disable-next-line no-console
187
+ console . log (
188
+ `Only changed test applications will run (${ selected . length } ): ${ JSON . stringify ( Array . from ( changedTestApps ) ) } ` ,
189
+ ) ;
190
+ return selected ;
159
191
}
160
192
} catch ( error ) {
161
193
// eslint-disable-next-line no-console
@@ -182,6 +214,10 @@ function getChangedTestApps(base: string, head?: string): false | Set<string> {
182
214
. map ( line => line . trim ( ) )
183
215
. filter ( Boolean ) ;
184
216
217
+ // For GitHub Action debugging
218
+ // eslint-disable-next-line no-console
219
+ console . log ( `Changed files since ${ base } ${ head ? `..${ head } ` : '' } :` , JSON . stringify ( changedFiles ) ) ;
220
+
185
221
const changedTestApps : Set < string > = new Set ( ) ;
186
222
const testAppsPrefix = 'dev-packages/e2e-tests/test-applications/' ;
187
223
0 commit comments