pull/310/head
Frostebite 2021-12-31 17:52:01 +00:00
parent 78945915b9
commit 7376cfa225
9 changed files with 76 additions and 31 deletions

View File

@ -78,6 +78,7 @@ jobs:
githubToken: ${{ secrets.GITHUB_TOKEN }}
awsBaseStackName: game-ci-stack-integration-tests
CloudRunnerBranch: remote-builder/unified-providers
cloudRunnerTests: true
postBuildSteps: |
name: upload
image: amazon/aws-cli

View File

@ -82,6 +82,7 @@ jobs:
projectPath: test-project
unityVersion: 2019.3.15f1
versioning: None
cloudRunnerTests: true
###########################
# Upload #

46
dist/index.js vendored
View File

@ -463,6 +463,7 @@ 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_logger_1 = __importDefault(__webpack_require__(22855));
const cloud_runner_state_1 = __webpack_require__(70912);
const cloud_runner_agent_system_1 = __webpack_require__(87685);
@ -500,7 +501,9 @@ class Caching {
cacheSelection = latest;
}
if (fs_1.default.existsSync(cacheSelection)) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
}
cloud_runner_logger_1.default.logCli(`cache item exists`);
console_1.assert(fs_1.default.existsSync(destinationFolder));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);
@ -727,6 +730,7 @@ const caching_1 = __webpack_require__(35010);
const lfs_hashing_1 = __webpack_require__(47011);
const cloud_runner_agent_system_1 = __webpack_require__(87685);
const path_1 = __importDefault(__webpack_require__(85622));
const __1 = __webpack_require__(41359);
class SetupCloudRunnerRepository {
static run() {
return __awaiter(this, void 0, void 0, function* () {
@ -735,20 +739,30 @@ class SetupCloudRunnerRepository {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
yield SetupCloudRunnerRepository.cloneRepoWithoutLFSFiles();
SetupCloudRunnerRepository.LFS_ASSETS_HASH = yield lfs_hashing_1.LFSHashing.createLFSHashFiles();
cloud_runner_logger_1.default.logCli(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
if (__1.Input.cloudRunnerTests) {
cloud_runner_logger_1.default.logCli(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
}
yield lfs_hashing_1.LFSHashing.printLFSHashState();
cloud_runner_logger_1.default.logCli(`Library Caching`);
console_1.assert(!fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull), `!Warning!: The Unity library was included in the git repository`);
cloud_runner_logger_1.default.logCli(`LFS Caching`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.lfsDirectory, '..')}`);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.lfsDirectory, '..')}`);
}
yield caching_1.Caching.PullFromCache(cloud_runner_state_1.CloudRunnerState.lfsCacheFolder, cloud_runner_state_1.CloudRunnerState.lfsDirectory, `${SetupCloudRunnerRepository.LFS_ASSETS_HASH}.zip`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.lfsDirectory, '..')}`);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.lfsDirectory, '..')}`);
}
yield caching_1.Caching.printCacheState(cloud_runner_state_1.CloudRunnerState.lfsCacheFolder, cloud_runner_state_1.CloudRunnerState.libraryCacheFolder);
yield SetupCloudRunnerRepository.pullLatestLFS();
yield caching_1.Caching.PushToCache(cloud_runner_state_1.CloudRunnerState.lfsCacheFolder, cloud_runner_state_1.CloudRunnerState.lfsDirectory, SetupCloudRunnerRepository.LFS_ASSETS_HASH);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.libraryCacheFolder, '..')}`);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.libraryCacheFolder, '..')}`);
}
yield caching_1.Caching.PullFromCache(cloud_runner_state_1.CloudRunnerState.libraryCacheFolder, cloud_runner_state_1.CloudRunnerState.libraryFolderFull);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.libraryCacheFolder, '..')}`);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.libraryCacheFolder, '..')}`);
}
caching_1.Caching.handleCachePurging();
}
catch (error) {
@ -765,8 +779,10 @@ class SetupCloudRunnerRepository {
cloud_runner_logger_1.default.logCli(`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}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -lh`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree`);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -lh`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree`);
}
cloud_runner_logger_1.default.logCli(`${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git checkout ${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
cloud_runner_logger_1.default.logCli(`Checked out ${process.env.GITHUB_SHA}`);
@ -969,14 +985,17 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AWSError = void 0;
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const core = __importStar(__webpack_require__(42186));
const __1 = __webpack_require__(41359);
class AWSError {
static handleStackCreationFailure(error, CF, taskDefStackName) {
return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.log('aws error: ');
core.error(JSON.stringify(error, undefined, 4));
cloud_runner_logger_1.default.log('Getting events and resources for task stack');
const events = (yield CF.describeStackEvents({ StackName: taskDefStackName }).promise()).StackEvents;
cloud_runner_logger_1.default.log(JSON.stringify(events, undefined, 4));
if (__1.Input.cloudRunnerTests) {
cloud_runner_logger_1.default.log('Getting events and resources for task stack');
const events = (yield CF.describeStackEvents({ StackName: taskDefStackName }).promise()).StackEvents;
cloud_runner_logger_1.default.log(JSON.stringify(events, undefined, 4));
}
});
}
}
@ -2410,16 +2429,17 @@ exports.default = KubernetesTaskRunner;
/***/ }),
/***/ 71899:
/***/ ((__unused_webpack_module, exports) => {
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CloudRunnerBuildCommandProcessor = void 0;
const __1 = __webpack_require__(41359);
class CloudRunnerBuildCommandProcessor {
static ProcessCommands(commands, buildParameters) {
return `echo "---"
printenv
${__1.Input.cloudRunnerTests ? '' : '#'} printenv
echo "start"
${commands}
echo "end---${buildParameters.logId}"

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -13,12 +13,12 @@
"format": "prettier --write \"src/**/*.{js,ts}\"",
"prepare": "husky install",
"cli": "yarn ts-node src/index.ts -m cli",
"cli-aws": "cross-env cloudRunnerCluster=aws yarn ts-node src/index.ts -m cli",
"cli-k8s": "cross-env cloudRunnerCluster=k8s yarn ts-node src/index.ts -m cli",
"test-cli": "yarn ts-node src/index.ts -m cli --projectPath test-project",
"cli-aws": "cross-env cloudRunnerCluster=aws yarn run test-cli",
"cli-k8s": "cross-env cloudRunnerCluster=k8s yarn run test-cli",
"test-cli": "cross-env cloudRunnerTests=true yarn ts-node src/index.ts -m cli --projectPath test-project",
"test": "jest",
"test-i": "yarn run test-i-aws && yarn run test-i-k8s",
"test-i-f": "yarn run test-i-aws && yarn run test-i-k8s && yarn run cli-k8s --projectPath test-project && yarn run cli-aws --projectPath test-project",
"test-i-f": "yarn run test-i-aws && yarn run test-i-k8s && yarn run cli-k8s && yarn run cli-aws",
"test-i-aws": "cross-env cloudRunnerTests=true cloudRunnerCluster=aws yarn test -i",
"test-i-k8s": "cross-env cloudRunnerTests=true cloudRunnerCluster=k8s yarn test -i"
},

View File

@ -1,6 +1,7 @@
import { assert } from 'console';
import fs from 'fs';
import path from 'path';
import { Input } from '../..';
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
import { CloudRunnerAgentSystem } from './cloud-runner-agent-system';
@ -41,7 +42,9 @@ export class Caching {
cacheSelection = latest;
}
if (fs.existsSync(cacheSelection)) {
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
}
CloudRunnerLogger.logCli(`cache item exists`);
assert(fs.existsSync(destinationFolder));
await CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);

View File

@ -6,6 +6,7 @@ import { Caching } from './caching';
import { LFSHashing } from './lfs-hashing';
import { CloudRunnerAgentSystem } from './cloud-runner-agent-system';
import path from 'path';
import { Input } from '../..';
export class SetupCloudRunnerRepository {
static LFS_ASSETS_HASH;
@ -16,7 +17,10 @@ export class SetupCloudRunnerRepository {
await SetupCloudRunnerRepository.cloneRepoWithoutLFSFiles();
SetupCloudRunnerRepository.LFS_ASSETS_HASH = await LFSHashing.createLFSHashFiles();
CloudRunnerLogger.logCli(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
if (Input.cloudRunnerTests) {
CloudRunnerLogger.logCli(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
}
await LFSHashing.printLFSHashState();
CloudRunnerLogger.logCli(`Library Caching`);
assert(
@ -24,13 +28,18 @@ export class SetupCloudRunnerRepository {
`!Warning!: The Unity library was included in the git repository`,
);
CloudRunnerLogger.logCli(`LFS Caching`);
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.lfsDirectory, '..')}`);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.lfsDirectory, '..')}`);
}
await Caching.PullFromCache(
CloudRunnerState.lfsCacheFolder,
CloudRunnerState.lfsDirectory,
`${SetupCloudRunnerRepository.LFS_ASSETS_HASH}.zip`,
);
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.lfsDirectory, '..')}`);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.lfsDirectory, '..')}`);
}
await Caching.printCacheState(CloudRunnerState.lfsCacheFolder, CloudRunnerState.libraryCacheFolder);
await SetupCloudRunnerRepository.pullLatestLFS();
await Caching.PushToCache(
@ -38,9 +47,15 @@ export class SetupCloudRunnerRepository {
CloudRunnerState.lfsDirectory,
SetupCloudRunnerRepository.LFS_ASSETS_HASH,
);
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.libraryCacheFolder, '..')}`);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.libraryCacheFolder, '..')}`);
}
await Caching.PullFromCache(CloudRunnerState.libraryCacheFolder, CloudRunnerState.libraryFolderFull);
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.libraryCacheFolder, '..')}`);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.libraryCacheFolder, '..')}`);
}
Caching.handleCachePurging();
} catch (error) {
@ -58,8 +73,10 @@ export class SetupCloudRunnerRepository {
await CloudRunnerAgentSystem.Run(
`git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}`,
);
await CloudRunnerAgentSystem.Run(`ls -lh`);
await CloudRunnerAgentSystem.Run(`tree`);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`ls -lh`);
await CloudRunnerAgentSystem.Run(`tree`);
}
CloudRunnerLogger.logCli(`${CloudRunnerState.buildParams.branch}`);
await CloudRunnerAgentSystem.Run(`git checkout ${CloudRunnerState.buildParams.branch}`);
CloudRunnerLogger.logCli(`Checked out ${process.env.GITHUB_SHA}`);

View File

@ -1,13 +1,16 @@
import CloudRunnerLogger from '../services/cloud-runner-logger';
import * as SDK from 'aws-sdk';
import * as core from '@actions/core';
import { Input } from '../..';
export class AWSError {
static async handleStackCreationFailure(error: any, CF: SDK.CloudFormation, taskDefStackName: string) {
CloudRunnerLogger.log('aws error: ');
core.error(JSON.stringify(error, undefined, 4));
CloudRunnerLogger.log('Getting events and resources for task stack');
const events = (await CF.describeStackEvents({ StackName: taskDefStackName }).promise()).StackEvents;
CloudRunnerLogger.log(JSON.stringify(events, undefined, 4));
if (Input.cloudRunnerTests) {
CloudRunnerLogger.log('Getting events and resources for task stack');
const events = (await CF.describeStackEvents({ StackName: taskDefStackName }).promise()).StackEvents;
CloudRunnerLogger.log(JSON.stringify(events, undefined, 4));
}
}
}

View File

@ -1,9 +1,9 @@
import { BuildParameters } from '../..';
import { BuildParameters, Input } from '../..';
export class CloudRunnerBuildCommandProcessor {
public static ProcessCommands(commands: string, buildParameters: BuildParameters): string {
return `echo "---"
printenv
${Input.cloudRunnerTests ? '' : '#'} printenv
echo "start"
${commands}
echo "end---${buildParameters.logId}"