mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-13 17:33:54 -07:00
fixes
This commit is contained in:
+39
-2
@@ -1573,16 +1573,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.AWSBaseStack = void 0;
|
exports.AWSBaseStack = void 0;
|
||||||
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(42864));
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(42864));
|
||||||
|
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(66965));
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
const client_cloudformation_1 = __nccwpck_require__(15650);
|
const client_cloudformation_1 = __nccwpck_require__(15650);
|
||||||
const base_stack_formation_1 = __nccwpck_require__(29643);
|
const base_stack_formation_1 = __nccwpck_require__(29643);
|
||||||
const node_crypto_1 = __importDefault(__nccwpck_require__(6005));
|
const node_crypto_1 = __importDefault(__nccwpck_require__(6005));
|
||||||
|
const LOCALSTACK_ENDPOINT_PATTERN = /localstack|localhost|127\.0\.0\.1/i;
|
||||||
|
const LOCALSTACK_WAIT_TIME_SECONDS = 600;
|
||||||
|
const DEFAULT_STACK_WAIT_TIME_SECONDS = 200;
|
||||||
|
function detectLocalStackEnvironment() {
|
||||||
|
const endpoints = [
|
||||||
|
process.env.AWS_ENDPOINT,
|
||||||
|
process.env.AWS_S3_ENDPOINT,
|
||||||
|
process.env.AWS_CLOUD_FORMATION_ENDPOINT,
|
||||||
|
process.env.AWS_ECS_ENDPOINT,
|
||||||
|
process.env.AWS_KINESIS_ENDPOINT,
|
||||||
|
process.env.AWS_CLOUD_WATCH_LOGS_ENDPOINT,
|
||||||
|
cloud_runner_options_1.default.awsEndpoint,
|
||||||
|
cloud_runner_options_1.default.awsS3Endpoint,
|
||||||
|
cloud_runner_options_1.default.awsCloudFormationEndpoint,
|
||||||
|
cloud_runner_options_1.default.awsEcsEndpoint,
|
||||||
|
cloud_runner_options_1.default.awsKinesisEndpoint,
|
||||||
|
cloud_runner_options_1.default.awsCloudWatchLogsEndpoint,
|
||||||
|
]
|
||||||
|
.filter((endpoint) => endpoint !== undefined && endpoint !== '')
|
||||||
|
.join(' ');
|
||||||
|
return LOCALSTACK_ENDPOINT_PATTERN.test(endpoints);
|
||||||
|
}
|
||||||
|
function determineStackWaitTime(isLocalStack) {
|
||||||
|
const overrideValue = Number(process.env.CLOUD_RUNNER_AWS_STACK_WAIT_TIME ?? '');
|
||||||
|
if (!Number.isNaN(overrideValue) && overrideValue > 0) {
|
||||||
|
return overrideValue;
|
||||||
|
}
|
||||||
|
return isLocalStack ? LOCALSTACK_WAIT_TIME_SECONDS : DEFAULT_STACK_WAIT_TIME_SECONDS;
|
||||||
|
}
|
||||||
class AWSBaseStack {
|
class AWSBaseStack {
|
||||||
constructor(baseStackName) {
|
constructor(baseStackName) {
|
||||||
this.baseStackName = baseStackName;
|
this.baseStackName = baseStackName;
|
||||||
}
|
}
|
||||||
async setupBaseStack(CF) {
|
async setupBaseStack(CF) {
|
||||||
const baseStackName = this.baseStackName;
|
const baseStackName = this.baseStackName;
|
||||||
|
const isLocalStack = detectLocalStackEnvironment();
|
||||||
|
const stackWaitTimeSeconds = determineStackWaitTime(isLocalStack);
|
||||||
|
if (isLocalStack) {
|
||||||
|
cloud_runner_logger_1.default.log(`LocalStack endpoints detected; will wait up to ${stackWaitTimeSeconds}s for CloudFormation transitions`);
|
||||||
|
}
|
||||||
const baseStack = base_stack_formation_1.BaseStackFormation.formation;
|
const baseStack = base_stack_formation_1.BaseStackFormation.formation;
|
||||||
// Cloud Formation Input
|
// Cloud Formation Input
|
||||||
const describeStackInput = {
|
const describeStackInput = {
|
||||||
@@ -1645,9 +1680,10 @@ class AWSBaseStack {
|
|||||||
}
|
}
|
||||||
const stackVersion = stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue;
|
const stackVersion = stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue;
|
||||||
if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
|
if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
|
||||||
|
cloud_runner_logger_1.default.log(`Waiting up to ${stackWaitTimeSeconds}s for '${baseStackName}' CloudFormation creation to finish`);
|
||||||
await (0, client_cloudformation_1.waitUntilStackCreateComplete)({
|
await (0, client_cloudformation_1.waitUntilStackCreateComplete)({
|
||||||
client: CF,
|
client: CF,
|
||||||
maxWaitTime: 200,
|
maxWaitTime: stackWaitTimeSeconds,
|
||||||
}, describeStackInput);
|
}, describeStackInput);
|
||||||
}
|
}
|
||||||
if (stackExists) {
|
if (stackExists) {
|
||||||
@@ -1676,9 +1712,10 @@ class AWSBaseStack {
|
|||||||
throw new Error(`Base stack doesn't exist, even after updating and creation, stackExists check: ${stackExists}`);
|
throw new Error(`Base stack doesn't exist, even after updating and creation, stackExists check: ${stackExists}`);
|
||||||
}
|
}
|
||||||
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
|
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
|
||||||
|
cloud_runner_logger_1.default.log(`Waiting up to ${stackWaitTimeSeconds}s for '${baseStackName}' CloudFormation update to finish`);
|
||||||
await (0, client_cloudformation_1.waitUntilStackUpdateComplete)({
|
await (0, client_cloudformation_1.waitUntilStackUpdateComplete)({
|
||||||
client: CF,
|
client: CF,
|
||||||
maxWaitTime: 200,
|
maxWaitTime: stackWaitTimeSeconds,
|
||||||
}, describeStackInput);
|
}, describeStackInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,4 +1,5 @@
|
|||||||
import CloudRunnerLogger from '../../services/core/cloud-runner-logger';
|
import CloudRunnerLogger from '../../services/core/cloud-runner-logger';
|
||||||
|
import CloudRunnerOptions from '../../options/cloud-runner-options';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {
|
import {
|
||||||
CloudFormation,
|
CloudFormation,
|
||||||
@@ -20,6 +21,39 @@ import {
|
|||||||
import { BaseStackFormation } from './cloud-formations/base-stack-formation';
|
import { BaseStackFormation } from './cloud-formations/base-stack-formation';
|
||||||
import crypto from 'node:crypto';
|
import crypto from 'node:crypto';
|
||||||
|
|
||||||
|
const LOCALSTACK_ENDPOINT_PATTERN = /localstack|localhost|127\.0\.0\.1/i;
|
||||||
|
const LOCALSTACK_WAIT_TIME_SECONDS = 600;
|
||||||
|
const DEFAULT_STACK_WAIT_TIME_SECONDS = 200;
|
||||||
|
|
||||||
|
function detectLocalStackEnvironment(): boolean {
|
||||||
|
const endpoints = [
|
||||||
|
process.env.AWS_ENDPOINT,
|
||||||
|
process.env.AWS_S3_ENDPOINT,
|
||||||
|
process.env.AWS_CLOUD_FORMATION_ENDPOINT,
|
||||||
|
process.env.AWS_ECS_ENDPOINT,
|
||||||
|
process.env.AWS_KINESIS_ENDPOINT,
|
||||||
|
process.env.AWS_CLOUD_WATCH_LOGS_ENDPOINT,
|
||||||
|
CloudRunnerOptions.awsEndpoint,
|
||||||
|
CloudRunnerOptions.awsS3Endpoint,
|
||||||
|
CloudRunnerOptions.awsCloudFormationEndpoint,
|
||||||
|
CloudRunnerOptions.awsEcsEndpoint,
|
||||||
|
CloudRunnerOptions.awsKinesisEndpoint,
|
||||||
|
CloudRunnerOptions.awsCloudWatchLogsEndpoint,
|
||||||
|
]
|
||||||
|
.filter((endpoint) => endpoint !== undefined && endpoint !== '')
|
||||||
|
.join(' ');
|
||||||
|
return LOCALSTACK_ENDPOINT_PATTERN.test(endpoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
function determineStackWaitTime(isLocalStack: boolean): number {
|
||||||
|
const overrideValue = Number(process.env.CLOUD_RUNNER_AWS_STACK_WAIT_TIME ?? '');
|
||||||
|
if (!Number.isNaN(overrideValue) && overrideValue > 0) {
|
||||||
|
return overrideValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isLocalStack ? LOCALSTACK_WAIT_TIME_SECONDS : DEFAULT_STACK_WAIT_TIME_SECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
export class AWSBaseStack {
|
export class AWSBaseStack {
|
||||||
constructor(baseStackName: string) {
|
constructor(baseStackName: string) {
|
||||||
this.baseStackName = baseStackName;
|
this.baseStackName = baseStackName;
|
||||||
@@ -28,6 +62,14 @@ export class AWSBaseStack {
|
|||||||
|
|
||||||
async setupBaseStack(CF: CloudFormation) {
|
async setupBaseStack(CF: CloudFormation) {
|
||||||
const baseStackName = this.baseStackName;
|
const baseStackName = this.baseStackName;
|
||||||
|
const isLocalStack = detectLocalStackEnvironment();
|
||||||
|
const stackWaitTimeSeconds = determineStackWaitTime(isLocalStack);
|
||||||
|
|
||||||
|
if (isLocalStack) {
|
||||||
|
CloudRunnerLogger.log(
|
||||||
|
`LocalStack endpoints detected; will wait up to ${stackWaitTimeSeconds}s for CloudFormation transitions`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const baseStack = BaseStackFormation.formation;
|
const baseStack = BaseStackFormation.formation;
|
||||||
|
|
||||||
@@ -94,10 +136,13 @@ export class AWSBaseStack {
|
|||||||
const stackVersion = stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue;
|
const stackVersion = stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue;
|
||||||
|
|
||||||
if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
|
if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
|
||||||
|
CloudRunnerLogger.log(
|
||||||
|
`Waiting up to ${stackWaitTimeSeconds}s for '${baseStackName}' CloudFormation creation to finish`,
|
||||||
|
);
|
||||||
await waitUntilStackCreateComplete(
|
await waitUntilStackCreateComplete(
|
||||||
{
|
{
|
||||||
client: CF,
|
client: CF,
|
||||||
maxWaitTime: 200,
|
maxWaitTime: stackWaitTimeSeconds,
|
||||||
},
|
},
|
||||||
describeStackInput,
|
describeStackInput,
|
||||||
);
|
);
|
||||||
@@ -128,10 +173,13 @@ export class AWSBaseStack {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
|
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
|
||||||
|
CloudRunnerLogger.log(
|
||||||
|
`Waiting up to ${stackWaitTimeSeconds}s for '${baseStackName}' CloudFormation update to finish`,
|
||||||
|
);
|
||||||
await waitUntilStackUpdateComplete(
|
await waitUntilStackUpdateComplete(
|
||||||
{
|
{
|
||||||
client: CF,
|
client: CF,
|
||||||
maxWaitTime: 200,
|
maxWaitTime: stackWaitTimeSeconds,
|
||||||
},
|
},
|
||||||
describeStackInput,
|
describeStackInput,
|
||||||
);
|
);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user