@@ -143,9 +143,46 @@ function getAffectedTestApplications(
143
143
. map ( line => line . trim ( ) )
144
144
. filter ( Boolean ) ;
145
145
146
- // If something in e2e tests themselves are changed, just run everything
146
+ // If something in e2e tests themselves are changed, check if only test applications were changed
147
147
if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
148
- return testApplications ;
148
+ try {
149
+ const changedFiles = execSync (
150
+ `git diff --name-only ${ base } ${ head ? `..${ head } ` : '' } -- dev-packages/e2e-tests/` ,
151
+ { encoding : 'utf-8' } ,
152
+ )
153
+ . toString ( )
154
+ . split ( '\n' )
155
+ . map ( line => line . trim ( ) )
156
+ . filter ( Boolean ) ;
157
+
158
+ // Check if only test application files were changed
159
+ const changedTestApps = new Set < string > ( ) ;
160
+ const hasSharedCodeChanges = changedFiles . some ( file => {
161
+ // Check if the file is within a test application directory
162
+ const testAppMatch = file . match ( / ^ d e v - p a c k a g e s \/ e 2 e - t e s t s \/ t e s t - a p p l i c a t i o n s \/ ( [ ^ / ] + ) \/ / ) ;
163
+ if ( testAppMatch ?. [ 1 ] ) {
164
+ changedTestApps . add ( testAppMatch [ 1 ] ) ;
165
+ return false ;
166
+ }
167
+ // If it's not in test-applications/, we assume it's shared code
168
+ return true ;
169
+ } ) ;
170
+
171
+ // Shared code was changed, run all tests
172
+ if ( hasSharedCodeChanges ) {
173
+ return testApplications ;
174
+ }
175
+
176
+ // Only test applications were changed, run selectively
177
+ if ( changedTestApps . size > 0 ) {
178
+ return testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
179
+ }
180
+ } catch ( error ) {
181
+ // Fall back to running all tests
182
+ // eslint-disable-next-line no-console
183
+ console . error ( 'Failed to get changed files, running all tests:' , error ) ;
184
+ return testApplications ;
185
+ }
149
186
}
150
187
151
188
return testApplications . filter ( testApp => {
0 commit comments