Skip to content

Commit 1d7c982

Browse files
chargomemydea
authored andcommitted
update text matrix for e2e tests
1 parent 17210d9 commit 1d7c982

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

dev-packages/e2e-tests/lib/getTestMatrix.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,46 @@ function getAffectedTestApplications(
143143
.map(line => line.trim())
144144
.filter(Boolean);
145145

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
147147
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(/^dev-packages\/e2e-tests\/test-applications\/([^/]+)\//);
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+
}
149186
}
150187

151188
return testApplications.filter(testApp => {

0 commit comments

Comments
 (0)