@@ -48,10 +48,18 @@ 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 . error ( `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 (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
+
55
63
// If `--base=xxx` is defined, we only want to get test applications changed since that base
56
64
// Else, we take all test applications (e.g. on push)
57
65
const includedTestApplications = base
@@ -137,11 +145,22 @@ function getAffectedTestApplications(
137
145
additionalArgs . push ( `--head=${ head } ` ) ;
138
146
}
139
147
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 ) } ` ) ;
145
164
146
165
// If something in e2e tests themselves are changed, check if only test applications were changed
147
166
if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
@@ -150,12 +169,19 @@ function getAffectedTestApplications(
150
169
151
170
// Shared code was changed, run all tests
152
171
if ( changedTestApps === false ) {
172
+ // eslint-disable-next-line no-console
173
+ console . error ( 'Shared e2e code changed. Running all test applications.' ) ;
153
174
return testApplications ;
154
175
}
155
176
156
177
// Only test applications that were changed, run selectively
157
178
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 ;
159
185
}
160
186
} catch ( error ) {
161
187
// eslint-disable-next-line no-console
@@ -182,6 +208,10 @@ function getChangedTestApps(base: string, head?: string): false | Set<string> {
182
208
. map ( line => line . trim ( ) )
183
209
. filter ( Boolean ) ;
184
210
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
+
185
215
const changedTestApps : Set < string > = new Set ( ) ;
186
216
const testAppsPrefix = 'dev-packages/e2e-tests/test-applications/' ;
187
217
0 commit comments