fix
parent
bbb3dbeb5a
commit
3e25417543
|
|
@ -343,6 +343,38 @@ class Cache {
|
||||||
exports.default = Cache;
|
exports.default = Cache;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8731:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.GetAllCliModes = exports.GetCliFunctions = exports.CliFunction = void 0;
|
||||||
|
const targets = new Array();
|
||||||
|
function CliFunction(key, description) {
|
||||||
|
return function (target, propertyKey, descriptor) {
|
||||||
|
targets.push({
|
||||||
|
target,
|
||||||
|
propertyKey,
|
||||||
|
descriptor,
|
||||||
|
key,
|
||||||
|
description,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.CliFunction = CliFunction;
|
||||||
|
function GetCliFunctions(key) {
|
||||||
|
return targets.find((x) => x.key === key);
|
||||||
|
}
|
||||||
|
exports.GetCliFunctions = GetCliFunctions;
|
||||||
|
function GetAllCliModes() {
|
||||||
|
return targets.map((x) => x.key);
|
||||||
|
}
|
||||||
|
exports.GetAllCliModes = GetAllCliModes;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 55651:
|
/***/ 55651:
|
||||||
|
|
@ -362,6 +394,12 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||||
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||||
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||||
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||||
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
|
|
@ -386,33 +424,21 @@ exports.CLI = void 0;
|
||||||
const commander_ts_1 = __webpack_require__(40451);
|
const commander_ts_1 = __webpack_require__(40451);
|
||||||
const __1 = __webpack_require__(41359);
|
const __1 = __webpack_require__(41359);
|
||||||
const core = __importStar(__webpack_require__(42186));
|
const core = __importStar(__webpack_require__(42186));
|
||||||
const remote_client_1 = __webpack_require__(95575);
|
|
||||||
const action_yaml_1 = __webpack_require__(11091);
|
const action_yaml_1 = __webpack_require__(11091);
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
|
const cli_decorator_1 = __webpack_require__(8731);
|
||||||
class CLI {
|
class CLI {
|
||||||
static RunCli(options) {
|
static RunCli(options) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
__1.Input.githubInputEnabled = false;
|
__1.Input.githubInputEnabled = false;
|
||||||
const container = new Array();
|
const results = cli_decorator_1.GetCliFunctions(options.mode);
|
||||||
container.push({
|
if (results === undefined || results.length === 0) {
|
||||||
key: `remote-cli`,
|
|
||||||
asyncFunc: remote_client_1.RemoteClient.Run,
|
|
||||||
}, {
|
|
||||||
key: `cli`,
|
|
||||||
asyncFunc: () => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
options.versioning = 'None';
|
|
||||||
__1.Input.cliOptions = options;
|
|
||||||
const buildParameter = yield __1.BuildParameters.create();
|
|
||||||
const baseImage = new __1.ImageTag(buildParameter);
|
|
||||||
return yield __1.CloudRunner.run(buildParameter, baseImage.toString());
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
const results = container.filter((x) => x.key === options.mode);
|
|
||||||
if (results.length === 0) {
|
|
||||||
throw new Error('no CLI mode found');
|
throw new Error('no CLI mode found');
|
||||||
}
|
}
|
||||||
cloud_runner_logger_1.default.log(`Entrypoint: ${results[0].key}`);
|
cloud_runner_logger_1.default.log(`Entrypoint: ${results.key}`);
|
||||||
return yield results[0].asyncFunc();
|
options.versioning = 'None';
|
||||||
|
__1.Input.cliOptions = options;
|
||||||
|
return yield results.target[results.propertyKey]();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static isCliMode(options) {
|
static isCliMode(options) {
|
||||||
|
|
@ -432,402 +458,26 @@ class CLI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info(`\n`);
|
core.info(`\n`);
|
||||||
program.option('-m, --mode <mode>', 'cli or default');
|
program.option('-m, --mode <mode>', cli_decorator_1.GetAllCliModes()
|
||||||
|
.map((x) => `${x.key} (${x.description})`)
|
||||||
|
.join(` | `));
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
return program.opts();
|
return program.opts();
|
||||||
}
|
}
|
||||||
|
static CLIBuild() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const buildParameter = yield __1.BuildParameters.create();
|
||||||
|
const baseImage = new __1.ImageTag(buildParameter);
|
||||||
|
return yield __1.CloudRunner.run(buildParameter, baseImage.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
__decorate([
|
||||||
|
cli_decorator_1.CliFunction(`cli`, `runs a cloud runner build`)
|
||||||
|
], CLI, "CLIBuild", null);
|
||||||
exports.CLI = CLI;
|
exports.CLI = CLI;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 35010:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
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.Caching = void 0;
|
|
||||||
const console_1 = __webpack_require__(57082);
|
|
||||||
const fs_1 = __importDefault(__webpack_require__(35747));
|
|
||||||
const path_1 = __importDefault(__webpack_require__(85622));
|
|
||||||
const __1 = __webpack_require__(41359);
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
|
||||||
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
|
||||||
const remote_client_logger_1 = __webpack_require__(68972);
|
|
||||||
class Caching {
|
|
||||||
static PushToCache(cacheFolder, sourceFolder, cacheKey) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield Caching.printFullCacheHierarchySize();
|
|
||||||
}
|
|
||||||
process.chdir(`${sourceFolder}/..`);
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${sourceFolder}`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
|
|
||||||
}
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip -r "${cacheKey}.zip" "${path_1.default.dirname(sourceFolder)}"`);
|
|
||||||
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`));
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`cp "${cacheKey}.zip" "${path_1.default.join(cacheFolder, `${cacheKey}.zip`)}"`);
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`copied ${cacheKey} to ${cacheFolder}`);
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
|
|
||||||
}
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield Caching.printFullCacheHierarchySize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static PullFromCache(cacheFolder, destinationFolder, cacheKey = ``) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Caching for ${path_1.default.dirname(destinationFolder)}`);
|
|
||||||
try {
|
|
||||||
if (!fs_1.default.existsSync(cacheFolder)) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mkdir -p ${cacheFolder}`);
|
|
||||||
}
|
|
||||||
if (!fs_1.default.existsSync(destinationFolder)) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mkdir -p ${destinationFolder}`);
|
|
||||||
}
|
|
||||||
const latest = yield (yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)).replace(/\n/g, ``);
|
|
||||||
process.chdir(cacheFolder);
|
|
||||||
let cacheSelection;
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
|
|
||||||
}
|
|
||||||
if (cacheKey !== ``) {
|
|
||||||
cacheSelection = fs_1.default.existsSync(cacheKey) ? cacheKey : latest;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cacheSelection = latest;
|
|
||||||
}
|
|
||||||
if (fs_1.default.existsSync(cacheSelection)) {
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
|
|
||||||
}
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`cache item exists`);
|
|
||||||
console_1.assert(fs_1.default.existsSync(destinationFolder));
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
|
||||||
if (cacheSelection !== ``) {
|
|
||||||
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static handleCachePurging() {
|
|
||||||
if (process.env.purgeRemoteCaching !== undefined) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`purging ${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}`);
|
|
||||||
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.cacheFolder, { recursive: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static printFullCacheHierarchySize() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`echo ' '
|
|
||||||
echo "LFS cache for $branch"
|
|
||||||
du -sch "${cloud_runner_state_1.CloudRunnerState.lfsCacheFolderFull}/"
|
|
||||||
echo '**'
|
|
||||||
echo "Library cache for $branch"
|
|
||||||
du -sch "${cloud_runner_state_1.CloudRunnerState.libraryCacheFolderFull}/"
|
|
||||||
echo '**'
|
|
||||||
echo "Branch: $branch"
|
|
||||||
du -sch "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/"
|
|
||||||
echo '**'
|
|
||||||
echo 'Full cache'
|
|
||||||
du -sch "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/.."
|
|
||||||
echo ' '`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Caching = Caching;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 87685:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
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());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.CloudRunnerAgentSystem = void 0;
|
|
||||||
const child_process_1 = __webpack_require__(63129);
|
|
||||||
const remote_client_logger_1 = __webpack_require__(68972);
|
|
||||||
class CloudRunnerAgentSystem {
|
|
||||||
static Run(command) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`${command}`);
|
|
||||||
return yield new Promise((promise) => {
|
|
||||||
let output = '';
|
|
||||||
const child = child_process_1.exec(command, (error, stdout, stderr) => {
|
|
||||||
if (error) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.logCliError(`${error.message}`);
|
|
||||||
throw new Error(error.toString());
|
|
||||||
}
|
|
||||||
if (stderr) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.logCliDiagnostic(`${stderr.toString()}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const outputChunk = `${stdout}`;
|
|
||||||
output += outputChunk;
|
|
||||||
});
|
|
||||||
child.on('close', function (code) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`[Exit code ${code}]`);
|
|
||||||
if (code !== 0) {
|
|
||||||
throw new Error(output);
|
|
||||||
}
|
|
||||||
const outputLines = output.split(`\n`);
|
|
||||||
for (const element of outputLines) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(element);
|
|
||||||
}
|
|
||||||
promise(output);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.CloudRunnerAgentSystem = CloudRunnerAgentSystem;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 95575:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
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());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.RemoteClient = void 0;
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
|
||||||
const remote_client_logger_1 = __webpack_require__(68972);
|
|
||||||
const setup_cloud_runner_repository_1 = __webpack_require__(39656);
|
|
||||||
class RemoteClient {
|
|
||||||
static Run() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Build Params:
|
|
||||||
${JSON.stringify(buildParameter, undefined, 4)}
|
|
||||||
`);
|
|
||||||
cloud_runner_state_1.CloudRunnerState.setup(buildParameter);
|
|
||||||
yield setup_cloud_runner_repository_1.SetupCloudRunnerRepository.run();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.RemoteClient = RemoteClient;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 47011:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
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.LFSHashing = void 0;
|
|
||||||
const path_1 = __importDefault(__webpack_require__(85622));
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
|
||||||
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
|
||||||
const fs_1 = __importDefault(__webpack_require__(35747));
|
|
||||||
const console_1 = __webpack_require__(57082);
|
|
||||||
const __1 = __webpack_require__(41359);
|
|
||||||
const remote_client_logger_1 = __webpack_require__(68972);
|
|
||||||
class LFSHashing {
|
|
||||||
static createLFSHashFiles() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`md5sum .lfs-assets-guid > .lfs-assets-guid-sum`);
|
|
||||||
console_1.assert(fs_1.default.existsSync(`.lfs-assets-guid-sum`));
|
|
||||||
console_1.assert(fs_1.default.existsSync(`.lfs-assets-guid`));
|
|
||||||
const lfsHashes = {
|
|
||||||
lfsGuid: fs_1.default.readFileSync(`${path_1.default.join(cloud_runner_state_1.CloudRunnerState.repoPathFull, `.lfs-assets-guid`)}`, 'utf8'),
|
|
||||||
lfsGuidSum: fs_1.default.readFileSync(`${path_1.default.join(cloud_runner_state_1.CloudRunnerState.repoPathFull, `.lfs-assets-guid-sum`)}`, 'utf8'),
|
|
||||||
};
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(lfsHashes.lfsGuid);
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(lfsHashes.lfsGuidSum);
|
|
||||||
}
|
|
||||||
return lfsHashes;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.LFSHashing = LFSHashing;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 68972:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.RemoteClientLogger = void 0;
|
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
|
||||||
class RemoteClientLogger {
|
|
||||||
static log(message) {
|
|
||||||
cloud_runner_logger_1.default.log(`[Client] ${message}`);
|
|
||||||
}
|
|
||||||
static logCliError(message) {
|
|
||||||
cloud_runner_logger_1.default.log(`[Client][Error] ${message}`);
|
|
||||||
}
|
|
||||||
static logCliDiagnostic(message) {
|
|
||||||
cloud_runner_logger_1.default.log(`[Client][Diagnostic] ${message}`);
|
|
||||||
}
|
|
||||||
static logWarning(message) {
|
|
||||||
cloud_runner_logger_1.default.logWarning(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.RemoteClientLogger = RemoteClientLogger;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 39656:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
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.SetupCloudRunnerRepository = void 0;
|
|
||||||
const fs_1 = __importDefault(__webpack_require__(35747));
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
|
||||||
const caching_1 = __webpack_require__(35010);
|
|
||||||
const lfs_hashing_1 = __webpack_require__(47011);
|
|
||||||
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
|
||||||
const __1 = __webpack_require__(41359);
|
|
||||||
const remote_client_logger_1 = __webpack_require__(68972);
|
|
||||||
class SetupCloudRunnerRepository {
|
|
||||||
static run() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.buildPathFull}`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
|
|
||||||
yield SetupCloudRunnerRepository.cloneRepoWithoutLFSFiles();
|
|
||||||
const lfsHashes = yield lfs_hashing_1.LFSHashing.createLFSHashFiles();
|
|
||||||
if (!fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.logWarning(`!Warning!: The Unity library was included in the git repository`);
|
|
||||||
}
|
|
||||||
yield caching_1.Caching.PullFromCache(cloud_runner_state_1.CloudRunnerState.lfsCacheFolderFull, cloud_runner_state_1.CloudRunnerState.lfsDirectory, `${lfsHashes.lfsGuid}.zip`);
|
|
||||||
yield SetupCloudRunnerRepository.pullLatestLFS();
|
|
||||||
yield caching_1.Caching.PushToCache(cloud_runner_state_1.CloudRunnerState.lfsCacheFolderFull, cloud_runner_state_1.CloudRunnerState.lfsDirectory, lfsHashes.lfsGuid);
|
|
||||||
yield caching_1.Caching.PullFromCache(cloud_runner_state_1.CloudRunnerState.libraryCacheFolderFull, cloud_runner_state_1.CloudRunnerState.libraryFolderFull);
|
|
||||||
caching_1.Caching.handleCachePurging();
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static cloneRepoWithoutLFSFiles() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`);
|
|
||||||
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git config --global advice.detachedHead false`);
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Cloning the repository being built:`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs install --skip-smudge`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
|
|
||||||
if (__1.Input.cloudRunnerTests) {
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -lh`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree`);
|
|
||||||
}
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git checkout ${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Checked out ${process.env.GITHUB_SHA}`);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static pullLatestLFS() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs pull`);
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`pulled latest LFS files`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SetupCloudRunnerRepository = SetupCloudRunnerRepository;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 28730:
|
/***/ 28730:
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,18 @@
|
||||||
|
const targets = new Array();
|
||||||
|
export function CliFunction(key: string, description: string) {
|
||||||
|
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
||||||
|
targets.push({
|
||||||
|
target,
|
||||||
|
propertyKey,
|
||||||
|
descriptor,
|
||||||
|
key,
|
||||||
|
description,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export function GetCliFunctions(key) {
|
||||||
|
return targets.find((x) => x.key === key);
|
||||||
|
}
|
||||||
|
export function GetAllCliModes() {
|
||||||
|
return targets.map((x) => x.key);
|
||||||
|
}
|
||||||
|
|
@ -1,38 +1,24 @@
|
||||||
import { Command } from 'commander-ts';
|
import { Command } from 'commander-ts';
|
||||||
import { BuildParameters, CloudRunner, ImageTag, Input } from '..';
|
import { BuildParameters, CloudRunner, ImageTag, Input } from '..';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { RemoteClient } from './remote-client';
|
|
||||||
import { ActionYamlReader } from '../input-readers/action-yaml';
|
import { ActionYamlReader } from '../input-readers/action-yaml';
|
||||||
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
|
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
|
||||||
|
import { CliFunction, GetAllCliModes, GetCliFunctions } from './cli-decorator';
|
||||||
export class CLI {
|
export class CLI {
|
||||||
static async RunCli(options: any): Promise<void> {
|
static async RunCli(options: any): Promise<void> {
|
||||||
Input.githubInputEnabled = false;
|
Input.githubInputEnabled = false;
|
||||||
const container = new Array();
|
|
||||||
container.push(
|
|
||||||
{
|
|
||||||
key: `remote-cli`,
|
|
||||||
asyncFunc: RemoteClient.Run,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: `cli`,
|
|
||||||
asyncFunc: async () => {
|
|
||||||
options.versioning = 'None';
|
|
||||||
Input.cliOptions = options;
|
|
||||||
const buildParameter = await BuildParameters.create();
|
|
||||||
const baseImage = new ImageTag(buildParameter);
|
|
||||||
return await CloudRunner.run(buildParameter, baseImage.toString());
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const results = container.filter((x) => x.key === options.mode);
|
|
||||||
|
|
||||||
if (results.length === 0) {
|
const results = GetCliFunctions(options.mode);
|
||||||
|
|
||||||
|
if (results === undefined || results.length === 0) {
|
||||||
throw new Error('no CLI mode found');
|
throw new Error('no CLI mode found');
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudRunnerLogger.log(`Entrypoint: ${results[0].key}`);
|
CloudRunnerLogger.log(`Entrypoint: ${results.key}`);
|
||||||
|
|
||||||
return await results[0].asyncFunc();
|
options.versioning = 'None';
|
||||||
|
Input.cliOptions = options;
|
||||||
|
return await results.target[results.propertyKey]();
|
||||||
}
|
}
|
||||||
static isCliMode(options: any) {
|
static isCliMode(options: any) {
|
||||||
return options.mode !== undefined && options.mode !== '';
|
return options.mode !== undefined && options.mode !== '';
|
||||||
|
|
@ -52,9 +38,21 @@ export class CLI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info(`\n`);
|
core.info(`\n`);
|
||||||
program.option('-m, --mode <mode>', 'cli or default');
|
program.option(
|
||||||
|
'-m, --mode <mode>',
|
||||||
|
GetAllCliModes()
|
||||||
|
.map((x) => `${x.key} (${x.description})`)
|
||||||
|
.join(` | `),
|
||||||
|
);
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|
||||||
return program.opts();
|
return program.opts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CliFunction(`cli`, `runs a cloud runner build`)
|
||||||
|
public static async CLIBuild(): Promise<string> {
|
||||||
|
const buildParameter = await BuildParameters.create();
|
||||||
|
const baseImage = new ImageTag(buildParameter);
|
||||||
|
return await CloudRunner.run(buildParameter, baseImage.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
||||||
|
import { CliFunction } from '../cli-decorator';
|
||||||
import { RemoteClientLogger } from './remote-client-logger';
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
import { SetupCloudRunnerRepository } from './setup-cloud-runner-repository';
|
import { SetupCloudRunnerRepository } from './setup-cloud-runner-repository';
|
||||||
|
|
||||||
export class RemoteClient {
|
export class RemoteClient {
|
||||||
static async Run() {
|
@CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`)
|
||||||
|
static async run() {
|
||||||
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
||||||
RemoteClientLogger.log(`Build Params:
|
RemoteClientLogger.log(`Build Params:
|
||||||
${JSON.stringify(buildParameter, undefined, 4)}
|
${JSON.stringify(buildParameter, undefined, 4)}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import { Input } from '../..';
|
||||||
import { RemoteClientLogger } from './remote-client-logger';
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
|
|
||||||
export class SetupCloudRunnerRepository {
|
export class SetupCloudRunnerRepository {
|
||||||
static LFS_ASSETS_HASH;
|
|
||||||
public static async run() {
|
public static async run() {
|
||||||
try {
|
try {
|
||||||
await CloudRunnerAgentSystem.Run(`mkdir -p ${CloudRunnerState.buildPathFull}`);
|
await CloudRunnerAgentSystem.Run(`mkdir -p ${CloudRunnerState.buildPathFull}`);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"experimentalDecorators": true,
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||||
"noImplicitAny": false, /* Re-enable after fixing compatibility */ /* Raise error on expressions and declarations with an implied 'any' type. */
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
|
"noImplicitAny": false /* Re-enable after fixing compatibility */ /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue