populate cache key instead of using branch
parent
0208ac5353
commit
e3e8be4d6c
|
|
@ -89,9 +89,8 @@ jobs:
|
||||||
aws s3 ls
|
aws s3 ls
|
||||||
aws s3 ls game-ci-test-storage
|
aws s3 ls game-ci-test-storage
|
||||||
ls /data/cache/$CACHE_KEY
|
ls /data/cache/$CACHE_KEY
|
||||||
echo "/data/cache/build/$CACHE_KEY/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/$BUILD_FILE build-$BUILD_GUID.zip"
|
echo "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/$BUILD_FILE build-$BUILD_GUID.zip"
|
||||||
aws s3 cp /data/cache/build/$CACHE_KEY/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/build-$BUILD_GUID.zip
|
aws s3 cp /data/cache/$CACHE_KEY/build/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/build-$BUILD_GUID.zip
|
||||||
aws s3 cp /data/cache/build/$CACHE_KEY s3://game-ci-test-storage/$CACHE_KEY/$BUILD_GUID
|
|
||||||
secrets:
|
secrets:
|
||||||
- name: awsAccessKeyId
|
- name: awsAccessKeyId
|
||||||
value: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
value: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,8 @@ jobs:
|
||||||
aws s3 ls
|
aws s3 ls
|
||||||
aws s3 ls game-ci-test-storage
|
aws s3 ls game-ci-test-storage
|
||||||
ls /data/cache/$CACHE_KEY
|
ls /data/cache/$CACHE_KEY
|
||||||
echo "/data/cache/build/$CACHE_KEY/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/$BUILD_FILE"
|
echo "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/$BUILD_FILE"
|
||||||
aws s3 cp /data/cache/build/$CACHE_KEY/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/build-$BUILD_GUID.zip
|
aws s3 cp /data/cache/$CACHE_KEY/build/build-$BUILD_GUID.zip s3://game-ci-test-storage/$CACHE_KEY/build-$BUILD_GUID.zip
|
||||||
secrets:
|
secrets:
|
||||||
- name: awsAccessKeyId
|
- name: awsAccessKeyId
|
||||||
value: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
value: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
|
|
||||||
|
|
@ -682,9 +682,9 @@ const cloud_runner_system_1 = __nccwpck_require__(66879);
|
||||||
const lfs_hashing_1 = __nccwpck_require__(31938);
|
const lfs_hashing_1 = __nccwpck_require__(31938);
|
||||||
const remote_client_logger_1 = __nccwpck_require__(28082);
|
const remote_client_logger_1 = __nccwpck_require__(28082);
|
||||||
class Caching {
|
class Caching {
|
||||||
static PushToCache(cacheFolder, sourceFolder, cacheKey) {
|
static PushToCache(cacheFolder, sourceFolder, cacheArtifactName) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cacheKey = cacheKey.replace(' ', '');
|
cacheArtifactName = cacheArtifactName.replace(' ', '');
|
||||||
const startPath = process.cwd();
|
const startPath = process.cwd();
|
||||||
try {
|
try {
|
||||||
if (!fs_1.default.existsSync(cacheFolder)) {
|
if (!fs_1.default.existsSync(cacheFolder)) {
|
||||||
|
|
@ -696,20 +696,20 @@ class Caching {
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const formatFunction = function (format) {
|
const formatFunction = function (format) {
|
||||||
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(sourceFolder, '..'), cacheFolder, cacheKey], 1);
|
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(sourceFolder, '..'), cacheFolder, cacheArtifactName], 1);
|
||||||
return format.replace(/{(\d+)}/g, function (match, number) {
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`zip -q ${cacheKey}.zip ${path_1.default.basename(sourceFolder)}`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`zip -q ${cacheArtifactName}.zip ${path_1.default.basename(sourceFolder)}`);
|
||||||
console_1.assert(fs_1.default.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
console_1.assert(fs_1.default.existsSync(`${cacheArtifactName}.zip`), 'cache zip exists');
|
||||||
console_1.assert(fs_1.default.existsSync(path_1.default.basename(sourceFolder)), 'source folder exists');
|
console_1.assert(fs_1.default.existsSync(path_1.default.basename(sourceFolder)), 'source folder exists');
|
||||||
if (cloud_runner_1.default.buildParameters.cachePushOverrideCommand) {
|
if (cloud_runner_1.default.buildParameters.cachePushOverrideCommand) {
|
||||||
cloud_runner_system_1.CloudRunnerSystem.Run(formatFunction(cloud_runner_1.default.buildParameters.cachePushOverrideCommand));
|
cloud_runner_system_1.CloudRunnerSystem.Run(formatFunction(cloud_runner_1.default.buildParameters.cachePushOverrideCommand));
|
||||||
}
|
}
|
||||||
cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
cloud_runner_system_1.CloudRunnerSystem.Run(`mv ${cacheArtifactName}.zip ${cacheFolder}`);
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheArtifactName}.zip to ${cacheFolder}`);
|
||||||
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
console_1.assert(fs_1.default.existsSync(`${path_1.default.join(cacheFolder, cacheArtifactName)}.zip`), 'cache zip exists inside cache folder');
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
process.chdir(`${startPath}`);
|
process.chdir(`${startPath}`);
|
||||||
|
|
@ -718,9 +718,9 @@ class Caching {
|
||||||
process.chdir(`${startPath}`);
|
process.chdir(`${startPath}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static PullFromCache(cacheFolder, destinationFolder, cacheKey = ``) {
|
static PullFromCache(cacheFolder, destinationFolder, cacheArtifactName = ``) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cacheKey = cacheKey.replace(' ', '');
|
cacheArtifactName = cacheArtifactName.replace(' ', '');
|
||||||
const startPath = process.cwd();
|
const startPath = process.cwd();
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Caching for ${path_1.default.basename(destinationFolder)}`);
|
remote_client_logger_1.RemoteClientLogger.log(`Caching for ${path_1.default.basename(destinationFolder)}`);
|
||||||
try {
|
try {
|
||||||
|
|
@ -734,11 +734,11 @@ class Caching {
|
||||||
.replace(/\n/g, ``)
|
.replace(/\n/g, ``)
|
||||||
.replace('.zip', '');
|
.replace('.zip', '');
|
||||||
process.chdir(cacheFolder);
|
process.chdir(cacheFolder);
|
||||||
const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(`${cacheKey}.zip`) ? cacheKey : latestInBranch;
|
const cacheSelection = cacheArtifactName !== `` && fs_1.default.existsSync(`${cacheArtifactName}.zip`) ? cacheArtifactName : latestInBranch;
|
||||||
yield cloud_runner_logger_1.default.log(`cache key ${cacheKey} selection ${cacheSelection}`);
|
yield cloud_runner_logger_1.default.log(`cache key ${cacheArtifactName} selection ${cacheSelection}`);
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const formatFunction = function (format) {
|
const formatFunction = function (format) {
|
||||||
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(destinationFolder, '..'), cacheFolder, cacheKey], 1);
|
const arguments_ = Array.prototype.slice.call([path_1.default.resolve(destinationFolder, '..'), cacheFolder, cacheArtifactName], 1);
|
||||||
return format.replace(/{(\d+)}/g, function (match, number) {
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
});
|
});
|
||||||
|
|
@ -762,9 +762,9 @@ class Caching {
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv "${fullResultsFolder}/${path_1.default.basename(destinationFolder)}" "${destinationParentFolder}"`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`mv "${fullResultsFolder}/${path_1.default.basename(destinationFolder)}" "${destinationParentFolder}"`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheArtifactName} doesn't exist ${destinationFolder}`);
|
||||||
if (cacheSelection !== ``) {
|
if (cacheSelection !== ``) {
|
||||||
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey}.zip doesn't exist ${destinationFolder}`);
|
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheArtifactName}.zip doesn't exist ${destinationFolder}`);
|
||||||
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1886,9 +1886,6 @@ class CloudRunner {
|
||||||
core.setOutput(__1.Input.ToEnvVarFormat(element.name), element.value);
|
core.setOutput(__1.Input.ToEnvVarFormat(element.name), element.value);
|
||||||
}
|
}
|
||||||
for (const element of buildParameterPropertyNames) {
|
for (const element of buildParameterPropertyNames) {
|
||||||
if (buildParameters.cloudRunnerIntegrationTests) {
|
|
||||||
cloud_runner_logger_1.default.log(`Setting build parameters output ${__1.Input.ToEnvVarFormat(element)}`);
|
|
||||||
}
|
|
||||||
core.setOutput(__1.Input.ToEnvVarFormat(element), buildParameters[element]);
|
core.setOutput(__1.Input.ToEnvVarFormat(element), buildParameters[element]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4411,7 +4408,7 @@ class Input {
|
||||||
return Input.getInput('startDependenciesOverride') || '';
|
return Input.getInput('startDependenciesOverride') || '';
|
||||||
}
|
}
|
||||||
static get cacheKey() {
|
static get cacheKey() {
|
||||||
return Input.getInput('cacheKey') || '';
|
return Input.getInput('cacheKey') || Input.branch;
|
||||||
}
|
}
|
||||||
static get cloudRunnerTests() {
|
static get cloudRunnerTests() {
|
||||||
return Input.getInput(`cloudRunnerTests`) || false;
|
return Input.getInput(`cloudRunnerTests`) || false;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -9,8 +9,8 @@ import { LFSHashing } from './lfs-hashing';
|
||||||
import { RemoteClientLogger } from './remote-client-logger';
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
|
|
||||||
export class Caching {
|
export class Caching {
|
||||||
public static async PushToCache(cacheFolder: string, sourceFolder: string, cacheKey: string) {
|
public static async PushToCache(cacheFolder: string, sourceFolder: string, cacheArtifactName: string) {
|
||||||
cacheKey = cacheKey.replace(' ', '');
|
cacheArtifactName = cacheArtifactName.replace(' ', '');
|
||||||
const startPath = process.cwd();
|
const startPath = process.cwd();
|
||||||
try {
|
try {
|
||||||
if (!fs.existsSync(cacheFolder)) {
|
if (!fs.existsSync(cacheFolder)) {
|
||||||
|
|
@ -27,28 +27,31 @@ export class Caching {
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const formatFunction = function (format: string) {
|
const formatFunction = function (format: string) {
|
||||||
const arguments_ = Array.prototype.slice.call([path.resolve(sourceFolder, '..'), cacheFolder, cacheKey], 1);
|
const arguments_ = Array.prototype.slice.call(
|
||||||
|
[path.resolve(sourceFolder, '..'), cacheFolder, cacheArtifactName],
|
||||||
|
1,
|
||||||
|
);
|
||||||
return format.replace(/{(\d+)}/g, function (match, number) {
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
return typeof arguments_[number] != 'undefined' ? arguments_[number] : match;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
await CloudRunnerSystem.Run(`zip -q ${cacheKey}.zip ${path.basename(sourceFolder)}`);
|
await CloudRunnerSystem.Run(`zip -q ${cacheArtifactName}.zip ${path.basename(sourceFolder)}`);
|
||||||
assert(fs.existsSync(`${cacheKey}.zip`), 'cache zip exists');
|
assert(fs.existsSync(`${cacheArtifactName}.zip`), 'cache zip exists');
|
||||||
assert(fs.existsSync(path.basename(sourceFolder)), 'source folder exists');
|
assert(fs.existsSync(path.basename(sourceFolder)), 'source folder exists');
|
||||||
if (CloudRunner.buildParameters.cachePushOverrideCommand) {
|
if (CloudRunner.buildParameters.cachePushOverrideCommand) {
|
||||||
CloudRunnerSystem.Run(formatFunction(CloudRunner.buildParameters.cachePushOverrideCommand));
|
CloudRunnerSystem.Run(formatFunction(CloudRunner.buildParameters.cachePushOverrideCommand));
|
||||||
}
|
}
|
||||||
CloudRunnerSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
|
CloudRunnerSystem.Run(`mv ${cacheArtifactName}.zip ${cacheFolder}`);
|
||||||
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
|
RemoteClientLogger.log(`moved ${cacheArtifactName}.zip to ${cacheFolder}`);
|
||||||
assert(fs.existsSync(`${path.join(cacheFolder, cacheKey)}.zip`), 'cache zip exists inside cache folder');
|
assert(fs.existsSync(`${path.join(cacheFolder, cacheArtifactName)}.zip`), 'cache zip exists inside cache folder');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
process.chdir(`${startPath}`);
|
process.chdir(`${startPath}`);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
process.chdir(`${startPath}`);
|
process.chdir(`${startPath}`);
|
||||||
}
|
}
|
||||||
public static async PullFromCache(cacheFolder: string, destinationFolder: string, cacheKey: string = ``) {
|
public static async PullFromCache(cacheFolder: string, destinationFolder: string, cacheArtifactName: string = ``) {
|
||||||
cacheKey = cacheKey.replace(' ', '');
|
cacheArtifactName = cacheArtifactName.replace(' ', '');
|
||||||
const startPath = process.cwd();
|
const startPath = process.cwd();
|
||||||
RemoteClientLogger.log(`Caching for ${path.basename(destinationFolder)}`);
|
RemoteClientLogger.log(`Caching for ${path.basename(destinationFolder)}`);
|
||||||
try {
|
try {
|
||||||
|
|
@ -66,13 +69,14 @@ export class Caching {
|
||||||
|
|
||||||
process.chdir(cacheFolder);
|
process.chdir(cacheFolder);
|
||||||
|
|
||||||
const cacheSelection = cacheKey !== `` && fs.existsSync(`${cacheKey}.zip`) ? cacheKey : latestInBranch;
|
const cacheSelection =
|
||||||
await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`);
|
cacheArtifactName !== `` && fs.existsSync(`${cacheArtifactName}.zip`) ? cacheArtifactName : latestInBranch;
|
||||||
|
await CloudRunnerLogger.log(`cache key ${cacheArtifactName} selection ${cacheSelection}`);
|
||||||
|
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const formatFunction = function (format: string) {
|
const formatFunction = function (format: string) {
|
||||||
const arguments_ = Array.prototype.slice.call(
|
const arguments_ = Array.prototype.slice.call(
|
||||||
[path.resolve(destinationFolder, '..'), cacheFolder, cacheKey],
|
[path.resolve(destinationFolder, '..'), cacheFolder, cacheArtifactName],
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
return format.replace(/{(\d+)}/g, function (match, number) {
|
return format.replace(/{(\d+)}/g, function (match, number) {
|
||||||
|
|
@ -101,9 +105,9 @@ export class Caching {
|
||||||
`mv "${fullResultsFolder}/${path.basename(destinationFolder)}" "${destinationParentFolder}"`,
|
`mv "${fullResultsFolder}/${path.basename(destinationFolder)}" "${destinationParentFolder}"`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
|
RemoteClientLogger.logWarning(`cache item ${cacheArtifactName} doesn't exist ${destinationFolder}`);
|
||||||
if (cacheSelection !== ``) {
|
if (cacheSelection !== ``) {
|
||||||
RemoteClientLogger.logWarning(`cache item ${cacheKey}.zip doesn't exist ${destinationFolder}`);
|
RemoteClientLogger.logWarning(`cache item ${cacheArtifactName}.zip doesn't exist ${destinationFolder}`);
|
||||||
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,6 @@ class CloudRunner {
|
||||||
core.setOutput(Input.ToEnvVarFormat(element.name), element.value);
|
core.setOutput(Input.ToEnvVarFormat(element.name), element.value);
|
||||||
}
|
}
|
||||||
for (const element of buildParameterPropertyNames) {
|
for (const element of buildParameterPropertyNames) {
|
||||||
if (buildParameters.cloudRunnerIntegrationTests) {
|
|
||||||
CloudRunnerLogger.log(`Setting build parameters output ${Input.ToEnvVarFormat(element)}`);
|
|
||||||
}
|
|
||||||
core.setOutput(Input.ToEnvVarFormat(element), buildParameters[element]);
|
core.setOutput(Input.ToEnvVarFormat(element), buildParameters[element]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
static get cacheKey(): string {
|
static get cacheKey(): string {
|
||||||
return Input.getInput('cacheKey') || '';
|
return Input.getInput('cacheKey') || Input.branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get cloudRunnerTests(): boolean {
|
static get cloudRunnerTests(): boolean {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue