Skip to content

Commit 9806cfe

Browse files
committed
[build-tools] Port Maestro Tests bash step to TypeScript
Replace the bash shellscript step (defined in www/WorkflowMaestroTestJob) with a typed BuildFunction. Behaviorally identical to the bash version: runs maestro with the full flow_paths set, retries the whole set on failure, copies the latest attempt's JUnit XML to final_report_path. Smart retry (only re-running failed flows) is added in a follow-up PR. Signed-off-by: Ash Wu <hsatac@gmail.com>
1 parent 1122a7f commit 9806cfe

5 files changed

Lines changed: 849 additions & 3 deletions

File tree

‎packages/build-tools/src/steps/easFunctions.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { createRestoreCacheFunction } from './functions/restoreCache';
3535
import { parseXcactivitylogFunction } from './functions/parseXcactivitylog';
3636
import { runFastlaneFunction } from './functions/runFastlane';
3737
import { runGradleFunction } from './functions/runGradle';
38+
import { createRunMaestroTestsBuildFunction } from './functions/runMaestroTests';
3839
import { createSaveBuildCacheFunction } from './functions/saveBuildCache';
3940
import { createSaveCacheFunction } from './functions/saveCache';
4041
import { createSendSlackMessageFunction } from './functions/sendSlackMessage';
@@ -93,6 +94,7 @@ export function getEasFunctions(ctx: CustomBuildContext): BuildFunction[] {
9394
createUploadToAscBuildFunction(),
9495

9596
createReportMaestroTestResultsFunction(ctx),
97+
createRunMaestroTestsBuildFunction(),
9698
];
9799

98100
if (ctx.hasBuildJob()) {

‎packages/build-tools/src/steps/functions/__tests__/maestroResultParser.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import fs from 'fs/promises';
12
import { vol } from 'memfs';
23

34
import {
5+
copyLatestAttemptXml,
46
parseFlowMetadata,
57
parseJUnitTestCases,
68
parseMaestroResults,
@@ -803,3 +805,22 @@ describe(parseJUnitTestCases, () => {
803805
expect(results[0].properties).toEqual({});
804806
});
805807
});
808+
809+
describe('copyLatestAttemptXml', () => {
810+
it('picks the highest attempt number', async () => {
811+
vol.fromJSON({
812+
'/tmp/r/android-maestro-junit-attempt-0.xml': '<a/>',
813+
'/tmp/r/android-maestro-junit-attempt-1.xml': '<b/>',
814+
'/tmp/r/android-maestro-junit-attempt-2.xml': '<c/>',
815+
});
816+
await copyLatestAttemptXml({ sourceDir: '/tmp/r', outputPath: '/tmp/out.xml' });
817+
expect(await fs.readFile('/tmp/out.xml', 'utf-8')).toBe('<c/>');
818+
});
819+
820+
it('throws when source has no xml files', async () => {
821+
vol.fromJSON({ '/tmp/r/.keep': '' });
822+
await expect(
823+
copyLatestAttemptXml({ sourceDir: '/tmp/r', outputPath: '/tmp/out.xml' })
824+
).rejects.toThrow();
825+
});
826+
});

0 commit comments

Comments
 (0)