Test secrets are serialized correctly
parent
01ccc8ee10
commit
df240154da
|
|
@ -576,21 +576,57 @@ exports.Cli = Cli;
|
|||
/***/ }),
|
||||
|
||||
/***/ 67170:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.SharedWorkspaceLocking = void 0;
|
||||
const cloud_runner_system_1 = __nccwpck_require__(99393);
|
||||
const fs = __importStar(__nccwpck_require__(57147));
|
||||
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
||||
class SharedWorkspaceLocking {
|
||||
static GetLockedWorkspace() {
|
||||
const workspaces = SharedWorkspaceLocking.GetFreeWorkspaces();
|
||||
for (const element of workspaces) {
|
||||
if (SharedWorkspaceLocking.LockWorkspace(element)) {
|
||||
return element;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const workspaces = SharedWorkspaceLocking.GetFreeWorkspaces();
|
||||
for (const element of workspaces) {
|
||||
if (yield SharedWorkspaceLocking.LockWorkspace(element)) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
return;
|
||||
});
|
||||
}
|
||||
static GetFreeWorkspaces() {
|
||||
return [];
|
||||
|
|
@ -598,15 +634,25 @@ class SharedWorkspaceLocking {
|
|||
static GetAllWorkspaces() {
|
||||
return [];
|
||||
}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
static LockWorkspace(workspace) {
|
||||
return true;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// this job + date
|
||||
const file = `_lock_${cloud_runner_1.default.buildParameters.buildGuid}_${Date.now()}`;
|
||||
fs.writeFileSync(file, '');
|
||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`aws s3 cp ./${file} ./game-ci-test-storage/locks/${workspace}`);
|
||||
fs.rmSync(file);
|
||||
return SharedWorkspaceLocking.HasWorkspaceLock(workspace);
|
||||
});
|
||||
}
|
||||
static HasWorkspaceLock(workspace) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`aws s3 ls ./game-ci-test-storage/locks/${workspace}`);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
static IsWorkspaceLocked(workspace) { }
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
static HasWorkspaceLock(workspace) { }
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
static CreateLockableWorkspace(workspace, locked = false) { }
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
static ReleaseLock(workspace) { }
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,8 +1,11 @@
|
|||
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
|
||||
import * as fs from 'fs';
|
||||
import CloudRunner from '../cloud-runner/cloud-runner';
|
||||
export class SharedWorkspaceLocking {
|
||||
public static GetLockedWorkspace() {
|
||||
public static async GetLockedWorkspace() {
|
||||
const workspaces = SharedWorkspaceLocking.GetFreeWorkspaces();
|
||||
for (const element of workspaces) {
|
||||
if (SharedWorkspaceLocking.LockWorkspace(element)) {
|
||||
if (await SharedWorkspaceLocking.LockWorkspace(element)) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,15 +19,23 @@ export class SharedWorkspaceLocking {
|
|||
public static GetAllWorkspaces(): string[] {
|
||||
return [];
|
||||
}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public static LockWorkspace(workspace: string): boolean {
|
||||
public static async LockWorkspace(workspace: string): Promise<boolean> {
|
||||
// this job + date
|
||||
const file = `_lock_${CloudRunner.buildParameters.buildGuid}_${Date.now()}`;
|
||||
fs.writeFileSync(file, '');
|
||||
await CloudRunnerSystem.Run(`aws s3 cp ./${file} ./game-ci-test-storage/locks/${workspace}`);
|
||||
fs.rmSync(file);
|
||||
|
||||
return SharedWorkspaceLocking.HasWorkspaceLock(workspace);
|
||||
}
|
||||
public static async HasWorkspaceLock(workspace: string): Promise<boolean> {
|
||||
await CloudRunnerSystem.Run(`aws s3 ls ./game-ci-test-storage/locks/${workspace}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public static IsWorkspaceLocked(workspace: string) {}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public static HasWorkspaceLock(workspace: string) {}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public static CreateLockableWorkspace(workspace: string, locked: boolean = false) {}
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public static ReleaseLock(workspace: string) {}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ describe('Cloud Runner', () => {
|
|||
expect(file).toContain(JSON.stringify(buildParameter));
|
||||
expect(file).toContain(`${Input.ToEnvVarFormat(testSecretName)}=${testSecretValue}`);
|
||||
const environmentVariables = TaskParameterSerializer.readBuildEnvironmentVariables(buildParameter);
|
||||
const secrets = TaskParameterSerializer.readDefaultSecrets().map((x) => {
|
||||
return {
|
||||
name: x.EnvironmentVariable,
|
||||
value: x.ParameterValue,
|
||||
};
|
||||
});
|
||||
const newLinePurgedFile = file
|
||||
.replace(/\s+/g, '')
|
||||
.replace(new RegExp(`\\[${CloudRunnerStatics.logPrefix}\\]`, 'g'), '');
|
||||
|
|
@ -63,7 +69,7 @@ describe('Cloud Runner', () => {
|
|||
CloudRunnerLogger.log(`checking input/build param ${element.name} ${element.value}`);
|
||||
}
|
||||
}
|
||||
for (const element of environmentVariables) {
|
||||
for (const element of [...environmentVariables, ...secrets]) {
|
||||
if (element.value !== undefined && typeof element.value !== 'function') {
|
||||
expect(newLinePurgedFile).toContain(`${element.name}`);
|
||||
CloudRunnerLogger.log(`Contains ${element.name}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue