Skip to content

Commit 4790120

Browse files
refactor build validation poll
1 parent 26474ea commit 4790120

3 files changed

Lines changed: 69 additions & 55 deletions

File tree

dist/index.js

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57680,43 +57680,51 @@ async function updateBetaBuildLocalization(betaBuildLocalization, whatsNew) {
5768057680
return betaBuildLocalization;
5768157681
}
5768257682
async function pollForValidBuild(project, maxRetries = 60, interval = 30) {
57683-
var _a, _b;
57683+
var _a, _b, _c;
5768457684
core.debug(`Polling build validation...`);
5768557685
await new Promise(resolve => setTimeout(resolve, interval * 1000));
5768657686
let retries = 0;
57687+
let lastMessage = '';
5768757688
while (retries < maxRetries) {
57688-
core.debug(`Polling for build... Attempt ${++retries}/${maxRetries}`);
57689+
lastMessage = `Polling for build... Attempt ${retries}/${maxRetries}`;
57690+
core.debug(lastMessage);
5768957691
let { preReleaseVersion, build } = await getLastPreReleaseVersionAndBuild(project);
57690-
if (!preReleaseVersion) {
57691-
throw new Error(`Failed to get the last pre-release for version ${project.versionString}!`);
57692-
}
57693-
if (!build) {
57694-
build = await getLastPrereleaseBuild(preReleaseVersion);
57695-
}
57696-
if (!build) {
57697-
throw new Error(`Build ${preReleaseVersion.id} not found!`);
57698-
}
57699-
const normalizedBuildVersion = normalizeVersion((_a = build.attributes) === null || _a === void 0 ? void 0 : _a.version);
57700-
const normalizedProjectVersion = normalizeVersion(project.bundleVersion);
57701-
switch ((_b = build.attributes) === null || _b === void 0 ? void 0 : _b.processingState) {
57702-
case 'VALID':
57703-
if (normalizedBuildVersion === normalizedProjectVersion) {
57704-
core.debug(`Build ${build.attributes.version} is VALID`);
57705-
return build;
57706-
}
57707-
else {
57708-
core.debug(`Build ${build.attributes.version} is VALID but not the latest version ${project.bundleVersion}!`);
57692+
if (preReleaseVersion) {
57693+
if (!build) {
57694+
build = await getLastPrereleaseBuild(preReleaseVersion);
57695+
}
57696+
if (build) {
57697+
const normalizedBuildVersion = normalizeVersion((_a = build.attributes) === null || _a === void 0 ? void 0 : _a.version);
57698+
const normalizedProjectVersion = normalizeVersion(project.bundleVersion);
57699+
switch ((_b = build.attributes) === null || _b === void 0 ? void 0 : _b.processingState) {
57700+
case 'VALID':
57701+
if (normalizedBuildVersion === normalizedProjectVersion) {
57702+
core.debug(`Build ${build.attributes.version} is VALID`);
57703+
return build;
57704+
}
57705+
else {
57706+
lastMessage = `Build ${build.attributes.version} is VALID but not the latest version ${project.bundleVersion}!`;
57707+
}
57708+
break;
57709+
case 'FAILED':
57710+
case 'INVALID':
57711+
throw new Error(`Build ${build.attributes.version} === ${build.attributes.processingState}!`);
57712+
default:
57713+
lastMessage = `Build ${build.attributes.version} is ${build.attributes.processingState}...`;
57714+
break;
5770957715
}
57710-
break;
57711-
case 'FAILED':
57712-
case 'INVALID':
57713-
throw new Error(`Build ${build.attributes.version} is ${build.attributes.processingState}!`);
57714-
default:
57715-
core.debug(`Build ${build.attributes.version} is ${build.attributes.processingState}...`);
57716-
break;
57716+
}
57717+
else {
57718+
lastMessage = `No build found for ${(_c = preReleaseVersion.attributes) === null || _c === void 0 ? void 0 : _c.version}!`;
57719+
}
57720+
}
57721+
else {
57722+
lastMessage = `No pre-release version found for ${project.versionString}!`;
5771757723
}
57724+
core.debug(lastMessage);
5771857725
await new Promise(resolve => setTimeout(resolve, interval * 1000));
5771957726
}
57727+
core.error(lastMessage);
5772057728
throw new Error('Timed out waiting for valid build!');
5772157729
}
5772257730
async function UpdateTestDetails(project, whatsNew) {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AppStoreConnectClient.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -240,38 +240,44 @@ async function pollForValidBuild(project: XcodeProject, maxRetries: number = 60,
240240
core.debug(`Polling build validation...`);
241241
await new Promise(resolve => setTimeout(resolve, interval * 1000));
242242
let retries = 0;
243+
let lastMessage = '';
243244
while (retries < maxRetries) {
244-
core.debug(`Polling for build... Attempt ${++retries}/${maxRetries}`);
245+
lastMessage = `Polling for build... Attempt ${retries}/${maxRetries}`;
246+
core.debug(lastMessage);
245247
let { preReleaseVersion, build } = await getLastPreReleaseVersionAndBuild(project);
246-
if (!preReleaseVersion) {
247-
throw new Error(`Failed to get the last pre-release for version ${project.versionString}!`);
248-
}
249-
if (!build) {
250-
build = await getLastPrereleaseBuild(preReleaseVersion);
251-
}
252-
if (!build) {
253-
throw new Error(`Build ${preReleaseVersion.id} not found!`);
254-
}
255-
const normalizedBuildVersion = normalizeVersion(build.attributes?.version);
256-
const normalizedProjectVersion = normalizeVersion(project.bundleVersion);
257-
switch (build.attributes?.processingState) {
258-
case 'VALID':
259-
if (normalizedBuildVersion === normalizedProjectVersion) {
260-
core.debug(`Build ${build.attributes.version} is VALID`);
261-
return build;
262-
} else {
263-
core.debug(`Build ${build.attributes.version} is VALID but not the latest version ${project.bundleVersion}!`);
248+
if (preReleaseVersion) {
249+
if (!build) {
250+
build = await getLastPrereleaseBuild(preReleaseVersion);
251+
}
252+
if (build) {
253+
const normalizedBuildVersion = normalizeVersion(build.attributes?.version);
254+
const normalizedProjectVersion = normalizeVersion(project.bundleVersion);
255+
switch (build.attributes?.processingState) {
256+
case 'VALID':
257+
if (normalizedBuildVersion === normalizedProjectVersion) {
258+
core.debug(`Build ${build.attributes.version} is VALID`);
259+
return build;
260+
} else {
261+
lastMessage = `Build ${build.attributes.version} is VALID but not the latest version ${project.bundleVersion}!`;
262+
}
263+
break;
264+
case 'FAILED':
265+
case 'INVALID':
266+
throw new Error(`Build ${build.attributes.version} === ${build.attributes.processingState}!`);
267+
default:
268+
lastMessage = `Build ${build.attributes.version} is ${build.attributes.processingState}...`;
269+
break;
264270
}
265-
break;
266-
case 'FAILED':
267-
case 'INVALID':
268-
throw new Error(`Build ${build.attributes.version} is ${build.attributes.processingState}!`);
269-
default:
270-
core.debug(`Build ${build.attributes.version} is ${build.attributes.processingState}...`);
271-
break;
271+
} else {
272+
lastMessage = `No build found for ${preReleaseVersion.attributes?.version}!`;
273+
}
274+
} else {
275+
lastMessage = `No pre-release version found for ${project.versionString}!`;
272276
}
277+
core.debug(lastMessage);
273278
await new Promise(resolve => setTimeout(resolve, interval * 1000));
274279
}
280+
core.error(lastMessage);
275281
throw new Error('Timed out waiting for valid build!');
276282
}
277283

0 commit comments

Comments
 (0)