Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[continuous-deploy-fingerprint] Improve build filtering #303

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading