From 7304c707e337a2f406f4c93fdd6a3e3d26abef00 Mon Sep 17 00:00:00 2001 From: Will Schurman Date: Mon, 16 Sep 2024 12:07:19 -0700 Subject: [PATCH] [continuous-deploy-fingerprint] Improve build filtering --- build/command/index.js | 12 ++++++- build/continuous-deploy-fingerprint/index.js | 35 +++++++++++--------- build/preview-build/index.js | 12 ++++++- build/preview-comment/index.js | 12 ++++++- build/preview/index.js | 12 ++++++- build/setup/index.js | 12 ++++++- src/actions/continuous-deploy-fingerprint.ts | 28 ++++++---------- src/expo.ts | 11 ++++++ 8 files changed, 96 insertions(+), 38 deletions(-) diff --git a/build/command/index.js b/build/command/index.js index 68307fb5..be6fc805 100644 --- a/build/command/index.js +++ b/build/command/index.js @@ -38699,7 +38699,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0; +exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.BuildStatus = exports.AppPlatform = void 0; const core_1 = __nccwpck_require__(2186); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -38711,6 +38711,16 @@ var AppPlatform; AppPlatform["Android"] = "ANDROID"; AppPlatform["Ios"] = "IOS"; })(AppPlatform || (exports.AppPlatform = AppPlatform = {})); +var BuildStatus; +(function (BuildStatus) { + BuildStatus["New"] = "NEW"; + BuildStatus["InQueue"] = "IN_QUEUE"; + BuildStatus["InProgress"] = "IN_PROGRESS"; + BuildStatus["PendingCancel"] = "PENDING_CANCEL"; + BuildStatus["Errored"] = "ERRORED"; + BuildStatus["Finished"] = "FINISHED"; + BuildStatus["Canceled"] = "CANCELED"; +})(BuildStatus || (exports.BuildStatus = BuildStatus = {})); exports.appPlatformDisplayNames = { [AppPlatform.Android]: 'Android', [AppPlatform.Ios]: 'iOS', diff --git a/build/continuous-deploy-fingerprint/index.js b/build/continuous-deploy-fingerprint/index.js index 92a03de4..1692964f 100644 --- a/build/continuous-deploy-fingerprint/index.js +++ b/build/continuous-deploy-fingerprint/index.js @@ -41968,7 +41968,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0; +exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.BuildStatus = exports.AppPlatform = void 0; const core_1 = __nccwpck_require__(2186); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -41980,6 +41980,16 @@ var AppPlatform; AppPlatform["Android"] = "ANDROID"; AppPlatform["Ios"] = "IOS"; })(AppPlatform || (exports.AppPlatform = AppPlatform = {})); +var BuildStatus; +(function (BuildStatus) { + BuildStatus["New"] = "NEW"; + BuildStatus["InQueue"] = "IN_QUEUE"; + BuildStatus["InProgress"] = "IN_PROGRESS"; + BuildStatus["PendingCancel"] = "PENDING_CANCEL"; + BuildStatus["Errored"] = "ERRORED"; + BuildStatus["Finished"] = "FINISHED"; + BuildStatus["Canceled"] = "CANCELED"; +})(BuildStatus || (exports.BuildStatus = BuildStatus = {})); exports.appPlatformDisplayNames = { [AppPlatform.Android]: 'Android', [AppPlatform.Ios]: 'iOS', @@ -44631,8 +44641,6 @@ async function getBuildInfoWithFingerprintAsync({ cwd, platform, profile, finger 'build:list', '--platform', platform, - '--status', - 'finished', '--buildProfile', profile, '--runtimeVersion', @@ -44654,20 +44662,15 @@ async function getBuildInfoWithFingerprintAsync({ cwd, platform, profile, finger if (!builds || !Array.isArray(builds)) { throw new Error(`Could not get EAS builds for project`); } - if (!builds[0]) { - return null; - } - const build = builds[0]; - if (excludeExpiredBuilds) { + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + const buildsThatAreValid = builds.filter(build => { + const isValidStatus = [expo_1.BuildStatus.New, expo_1.BuildStatus.InQueue, expo_1.BuildStatus.InProgress, expo_1.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; - } - } - return build; + const isValidExpiry = excludeExpiredBuilds ? new Date(build.expirationDate) < tomorrow : true; + return isValidStatus && isValidExpiry; + }); + return buildsThatAreValid[0] ?? null; } async function createEASBuildAsync({ cwd, profile, platform, }) { let stdout; diff --git a/build/preview-build/index.js b/build/preview-build/index.js index 155c0f10..240ffcd3 100644 --- a/build/preview-build/index.js +++ b/build/preview-build/index.js @@ -89299,7 +89299,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0; +exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.BuildStatus = exports.AppPlatform = void 0; const core_1 = __nccwpck_require__(2186); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -89311,6 +89311,16 @@ var AppPlatform; AppPlatform["Android"] = "ANDROID"; AppPlatform["Ios"] = "IOS"; })(AppPlatform || (exports.AppPlatform = AppPlatform = {})); +var BuildStatus; +(function (BuildStatus) { + BuildStatus["New"] = "NEW"; + BuildStatus["InQueue"] = "IN_QUEUE"; + BuildStatus["InProgress"] = "IN_PROGRESS"; + BuildStatus["PendingCancel"] = "PENDING_CANCEL"; + BuildStatus["Errored"] = "ERRORED"; + BuildStatus["Finished"] = "FINISHED"; + BuildStatus["Canceled"] = "CANCELED"; +})(BuildStatus || (exports.BuildStatus = BuildStatus = {})); exports.appPlatformDisplayNames = { [AppPlatform.Android]: 'Android', [AppPlatform.Ios]: 'iOS', diff --git a/build/preview-comment/index.js b/build/preview-comment/index.js index 0751c1b7..7aa61d10 100644 --- a/build/preview-comment/index.js +++ b/build/preview-comment/index.js @@ -38643,7 +38643,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0; +exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.BuildStatus = exports.AppPlatform = void 0; const core_1 = __nccwpck_require__(2186); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -38655,6 +38655,16 @@ var AppPlatform; AppPlatform["Android"] = "ANDROID"; AppPlatform["Ios"] = "IOS"; })(AppPlatform || (exports.AppPlatform = AppPlatform = {})); +var BuildStatus; +(function (BuildStatus) { + BuildStatus["New"] = "NEW"; + BuildStatus["InQueue"] = "IN_QUEUE"; + BuildStatus["InProgress"] = "IN_PROGRESS"; + BuildStatus["PendingCancel"] = "PENDING_CANCEL"; + BuildStatus["Errored"] = "ERRORED"; + BuildStatus["Finished"] = "FINISHED"; + BuildStatus["Canceled"] = "CANCELED"; +})(BuildStatus || (exports.BuildStatus = BuildStatus = {})); exports.appPlatformDisplayNames = { [AppPlatform.Android]: 'Android', [AppPlatform.Ios]: 'iOS', diff --git a/build/preview/index.js b/build/preview/index.js index eeeb7456..810f45f1 100644 --- a/build/preview/index.js +++ b/build/preview/index.js @@ -42176,7 +42176,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0; +exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.BuildStatus = exports.AppPlatform = void 0; const core_1 = __nccwpck_require__(2186); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -42188,6 +42188,16 @@ var AppPlatform; AppPlatform["Android"] = "ANDROID"; AppPlatform["Ios"] = "IOS"; })(AppPlatform || (exports.AppPlatform = AppPlatform = {})); +var BuildStatus; +(function (BuildStatus) { + BuildStatus["New"] = "NEW"; + BuildStatus["InQueue"] = "IN_QUEUE"; + BuildStatus["InProgress"] = "IN_PROGRESS"; + BuildStatus["PendingCancel"] = "PENDING_CANCEL"; + BuildStatus["Errored"] = "ERRORED"; + BuildStatus["Finished"] = "FINISHED"; + BuildStatus["Canceled"] = "CANCELED"; +})(BuildStatus || (exports.BuildStatus = BuildStatus = {})); exports.appPlatformDisplayNames = { [AppPlatform.Android]: 'Android', [AppPlatform.Ios]: 'iOS', diff --git a/build/setup/index.js b/build/setup/index.js index 7bfcb2af..f3cd921f 100644 --- a/build/setup/index.js +++ b/build/setup/index.js @@ -88920,7 +88920,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0; +exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.BuildStatus = exports.AppPlatform = void 0; const core_1 = __nccwpck_require__(2186); const exec_1 = __nccwpck_require__(1514); const io_1 = __nccwpck_require__(7436); @@ -88932,6 +88932,16 @@ var AppPlatform; AppPlatform["Android"] = "ANDROID"; AppPlatform["Ios"] = "IOS"; })(AppPlatform || (exports.AppPlatform = AppPlatform = {})); +var BuildStatus; +(function (BuildStatus) { + BuildStatus["New"] = "NEW"; + BuildStatus["InQueue"] = "IN_QUEUE"; + BuildStatus["InProgress"] = "IN_PROGRESS"; + BuildStatus["PendingCancel"] = "PENDING_CANCEL"; + BuildStatus["Errored"] = "ERRORED"; + BuildStatus["Finished"] = "FINISHED"; + BuildStatus["Canceled"] = "CANCELED"; +})(BuildStatus || (exports.BuildStatus = BuildStatus = {})); exports.appPlatformDisplayNames = { [AppPlatform.Android]: 'Android', [AppPlatform.Ios]: 'iOS', diff --git a/src/actions/continuous-deploy-fingerprint.ts b/src/actions/continuous-deploy-fingerprint.ts index d5e97d81..b53c308d 100644 --- a/src/actions/continuous-deploy-fingerprint.ts +++ b/src/actions/continuous-deploy-fingerprint.ts @@ -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'; @@ -151,8 +151,6 @@ async function getBuildInfoWithFingerprintAsync({ 'build:list', '--platform', platform, - '--status', - 'finished', '--buildProfile', profile, '--runtimeVersion', @@ -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({ diff --git a/src/expo.ts b/src/expo.ts index 9567b716..d8405bda 100644 --- a/src/expo.ts +++ b/src/expo.ts @@ -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; @@ -43,6 +53,7 @@ export type BuildInfo = { appVersion: string; gitCommitHash: string; expirationDate: string; + status: BuildStatus; }; export const appPlatformDisplayNames: Record = {