Skip to content

Commit e01dca7

Browse files
committed
ci(test-matrix): Add logs for getTestMatrix
1 parent 6e8e561 commit e01dca7

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

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

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,24 @@ 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.log(`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
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+
5569
// If `--base=xxx` is defined, we only want to get test applications changed since that base
5670
// Else, we take all test applications (e.g. on push)
5771
const includedTestApplications = base
@@ -137,11 +151,22 @@ function getAffectedTestApplications(
137151
additionalArgs.push(`--head=${head}`);
138152
}
139153

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));
145170

146171
// If something in e2e tests themselves are changed, check if only test applications were changed
147172
if (affectedProjects.includes('@sentry-internal/e2e-tests')) {
@@ -150,12 +175,19 @@ function getAffectedTestApplications(
150175

151176
// Shared code was changed, run all tests
152177
if (changedTestApps === false) {
178+
// eslint-disable-next-line no-console
179+
console.log('Shared e2e code changed. Running all test applications.');
153180
return testApplications;
154181
}
155182

156183
// Only test applications that were changed, run selectively
157184
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;
159191
}
160192
} catch (error) {
161193
// eslint-disable-next-line no-console
@@ -182,6 +214,10 @@ function getChangedTestApps(base: string, head?: string): false | Set<string> {
182214
.map(line => line.trim())
183215
.filter(Boolean);
184216

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+
185221
const changedTestApps: Set<string> = new Set();
186222
const testAppsPrefix = 'dev-packages/e2e-tests/test-applications/';
187223

0 commit comments

Comments
 (0)