Skip to content

Commit

Permalink
[continuous-deploy-fingerprint] Improve build filtering (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
wschurman authored Sep 16, 2024
1 parent 047ecf1 commit e780e57
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 38 deletions.
12 changes: 11 additions & 1 deletion build/command/index.js

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

35 changes: 19 additions & 16 deletions build/continuous-deploy-fingerprint/index.js

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

12 changes: 11 additions & 1 deletion build/preview-build/index.js

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

12 changes: 11 additions & 1 deletion build/preview-comment/index.js

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

12 changes: 11 additions & 1 deletion build/preview/index.js

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

12 changes: 11 additions & 1 deletion build/setup/index.js

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

28 changes: 11 additions & 17 deletions src/actions/continuous-deploy-fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExpoConfig } from '@expo/config';

import { createDetails, getQrTarget, getSchemesInOrderFromConfig } from '../comment';
import { EasUpdate, getUpdateGroupQr, getUpdateGroupWebsite } from '../eas';
import { AppPlatform, BuildInfo, appPlatformEmojis, getBuildLogsUrl } from '../expo';
import { AppPlatform, BuildInfo, BuildStatus, appPlatformEmojis, getBuildLogsUrl } from '../expo';
import { createIssueComment, hasPullContext, pullContext } from '../github';
import { loadProjectConfig } from '../project';
import { executeAction } from '../worker';
Expand Down Expand Up @@ -151,8 +151,6 @@ async function getBuildInfoWithFingerprintAsync({
'build:list',
'--platform',
platform,
'--status',
'finished',
'--buildProfile',
profile,
'--runtimeVersion',
Expand All @@ -177,23 +175,19 @@ async function getBuildInfoWithFingerprintAsync({
throw new Error(`Could not get EAS builds for project`);
}

if (!builds[0]) {
return null;
}

const build = builds[0] as BuildInfo;
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);

if (excludeExpiredBuilds) {
const buildsThatAreValid = (builds as BuildInfo[]).filter(build => {
const isValidStatus = [BuildStatus.New, BuildStatus.InQueue, BuildStatus.InProgress, BuildStatus.Finished].includes(
build.status
);
// if the build is expired or will expire within the next day,
// return null to trigger a new build
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
if (tomorrow > new Date(build.expirationDate)) {
return null;
}
}
const isValidExpiry = excludeExpiredBuilds ? new Date(build.expirationDate) < tomorrow : true;
return isValidStatus && isValidExpiry;
});

return build;
return buildsThatAreValid[0] ?? null;
}

async function createEASBuildAsync({
Expand Down
11 changes: 11 additions & 0 deletions src/expo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export enum AppPlatform {
Ios = 'IOS',
}

export enum BuildStatus {
New = 'NEW',
InQueue = 'IN_QUEUE',
InProgress = 'IN_PROGRESS',
PendingCancel = 'PENDING_CANCEL',
Errored = 'ERRORED',
Finished = 'FINISHED',
Canceled = 'CANCELED',
}

export type BuildInfo = {
id: string;
platform: AppPlatform;
Expand All @@ -43,6 +53,7 @@ export type BuildInfo = {
appVersion: string;
gitCommitHash: string;
expirationDate: string;
status: BuildStatus;
};

export const appPlatformDisplayNames: Record<AppPlatform, string> = {
Expand Down

0 comments on commit e780e57

Please sign in to comment.