Skip to content

Commit

Permalink
[eas-cli] log time that it took to complete the previous build in eas…
Browse files Browse the repository at this point in the history
… build:dev
  • Loading branch information
szdziedzic committed Feb 4, 2025
1 parent 077d8b3 commit fe61155
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 24 deletions.
12 changes: 12 additions & 0 deletions packages/eas-cli/graphql.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 49 additions & 13 deletions packages/eas-cli/src/commands/build/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { evaluateConfigWithEnvVarsAsync } from '../../build/evaluateConfigWithEn
import { runBuildAndSubmitAsync } from '../../build/runBuildAndSubmit';
import { ensureRepoIsCleanAsync } from '../../build/utils/repository';
import EasCommand from '../../commandUtils/EasCommand';
import { BuildStatus, DistributionType } from '../../graphql/generated';
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
import { BuildFragment, BuildStatus, DistributionType } from '../../graphql/generated';
import { BuildQuery } from '../../graphql/queries/BuildQuery';
import { toAppPlatform } from '../../graphql/types/AppPlatform';
import Log from '../../log';
Expand Down Expand Up @@ -109,18 +110,11 @@ export default class BuildDev extends EasCommand {
Log.log(`✨ Calculated fingerprint hash: ${fingerprint.hash}`);
Log.newLine();

const builds = await BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
appId: projectId,
filter: {
platform: toAppPlatform(platform),
fingerprintHash: fingerprint.hash,
status: BuildStatus.Finished,
simulator: platform === Platform.IOS ? true : undefined,
distribution: platform === Platform.ANDROID ? DistributionType.Internal : undefined,
developmentClient: true,
},
offset: 0,
limit: 1,
const builds = await this.getBuildsAsync({
graphqlClient,
projectId,
platform,
fingerprint,
});
if (builds.length !== 0) {
const build = builds[0];
Expand All @@ -142,6 +136,22 @@ export default class BuildDev extends EasCommand {

Log.log('🚀 No successful build with matching fingerprint found. Starting a new build...');

const previousBuildsForSelectedProfile = await this.getBuildsAsync({
graphqlClient,
projectId,
platform,
});
if (
previousBuildsForSelectedProfile.length > 0 &&
previousBuildsForSelectedProfile[0].metrics?.buildDuration
) {
Log.log(
`🕒 Previous build for "${buildProfile.profileName}" profile completed in ${Math.floor(
previousBuildsForSelectedProfile[0].metrics.buildDuration / 60000
)} minutes.`
);
}

await runBuildAndSubmitAsync({
graphqlClient,
analytics,
Expand Down Expand Up @@ -294,4 +304,30 @@ export default class BuildDev extends EasCommand {
});
return buildProfile;
}

private async getBuildsAsync({
graphqlClient,
projectId,
platform,
fingerprint,
}: {
graphqlClient: ExpoGraphqlClient;
projectId: string;
platform: Platform;
fingerprint?: { hash: string };
}): Promise<BuildFragment[]> {
return await BuildQuery.viewBuildsOnAppAsync(graphqlClient, {
appId: projectId,
filter: {
platform: toAppPlatform(platform),
fingerprintHash: fingerprint?.hash,
status: BuildStatus.Finished,
simulator: platform === Platform.IOS ? true : undefined,
distribution: platform === Platform.ANDROID ? DistributionType.Internal : undefined,
developmentClient: true,
},
offset: 0,
limit: 1,
});
}
}
Loading

0 comments on commit fe61155

Please sign in to comment.