Converting caching from shell to typescript
parent
584aa65154
commit
9079429c8d
|
|
@ -2005,136 +2005,124 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.DownloadRepository = void 0;
|
exports.DownloadRepository = void 0;
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
const run_cli_1 = __webpack_require__(33639);
|
const run_cli_1 = __webpack_require__(33639);
|
||||||
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||||
|
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
class DownloadRepository {
|
class DownloadRepository {
|
||||||
static run() {
|
static run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`tree -f -L 2tree -f -L 2`);
|
||||||
tree -f -L 2tree -f -L 2
|
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.buildPathFull);
|
||||||
echo "test"
|
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
||||||
mkdir -p ${cloud_runner_state_1.CloudRunnerState.buildPathFull}
|
cloud_runner_logger_1.default.log(`Initializing source repository for cloning with caching of LFS files`);
|
||||||
mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
echo ' '
|
cd ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
||||||
echo 'Initializing source repository for cloning with caching of LFS files'
|
# stop annoying git detatched head info
|
||||||
githubSha=$GITHUB_SHA
|
git config --global advice.detachedHead false
|
||||||
|
echo ' '
|
||||||
|
echo "Cloning the repository being built:"
|
||||||
|
git lfs install --skip-smudge
|
||||||
|
echo "${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl}"
|
||||||
|
git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
||||||
|
git checkout ${process.env.GITHUB_SHA}
|
||||||
|
echo "Checked out ${process.env.GITHUB_SHA}"
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
cd ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
||||||
# stop annoying git detatched head info
|
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
||||||
git config --global advice.detachedHead false
|
|
||||||
echo ' '
|
|
||||||
echo "Cloning the repository being built:"
|
|
||||||
git lfs install --skip-smudge
|
|
||||||
echo "${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl}"
|
|
||||||
git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
|
||||||
git checkout $githubSha
|
|
||||||
echo "Checked out $githubSha"
|
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
const LFS_ASSETS_HASH = fs_1.default.readFileSync(`${cloud_runner_state_1.CloudRunnerState.repoPathFull}/.lfs-assets-guid`, 'utf8');
|
||||||
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
echo ' '
|
||||||
`);
|
echo 'Contents of .lfs-assets-guid file:'
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
cat .lfs-assets-guid
|
||||||
export LFS_ASSETS_HASH="$(cat ${cloud_runner_state_1.CloudRunnerState.repoPathFull}/.lfs-assets-guid)"
|
echo ' '
|
||||||
`);
|
echo 'Contents of .lfs-assets-guid-sum file:'
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
cat .lfs-assets-guid-sum
|
||||||
echo ' '
|
echo ' '
|
||||||
echo 'Contents of .lfs-assets-guid file:'
|
echo 'Source repository initialized'
|
||||||
cat .lfs-assets-guid
|
ls ${cloud_runner_state_1.CloudRunnerState.projectPathFull}
|
||||||
echo ' '
|
echo ' '
|
||||||
echo 'Contents of .lfs-assets-guid-sum file:'
|
|
||||||
cat .lfs-assets-guid-sum
|
|
||||||
echo ' '
|
|
||||||
echo 'Source repository initialized'
|
|
||||||
ls ${cloud_runner_state_1.CloudRunnerState.projectPathFull}
|
|
||||||
echo ' '
|
|
||||||
`);
|
`);
|
||||||
const lfsCacheFolder = `${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lfs`;
|
const lfsCacheFolder = `${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lfs`;
|
||||||
const libraryCacheFolder = `${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib`;
|
const libraryCacheFolder = `${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib`;
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`tree ${cloud_runner_state_1.CloudRunnerState.builderPathFull}`);
|
||||||
tree ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
cloud_runner_logger_1.default.log(`Starting checks of cache for the Unity project Library and git LFS files`);
|
||||||
echo 'Starting checks of cache for the Unity project Library and git LFS files'
|
fs_1.default.mkdirSync(lfsCacheFolder);
|
||||||
mkdir -p "${lfsCacheFolder}"
|
fs_1.default.mkdirSync(libraryCacheFolder);
|
||||||
mkdir -p "${libraryCacheFolder}"
|
cloud_runner_logger_1.default.log(`Library Caching`);
|
||||||
echo 'Library Caching'
|
//if the unity git project has included the library delete it and echo a warning
|
||||||
|
if (fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) {
|
||||||
|
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull, { recursive: true });
|
||||||
|
cloud_runner_logger_1.default.log(`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`);
|
||||||
|
}
|
||||||
|
//Restore library cache
|
||||||
|
const latestLibraryCacheFile = yield run_cli_1.RunCli.RunCli(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
|
||||||
|
yield run_cli_1.RunCli.RunCli(`ls -lh "${libraryCacheFolder}"`);
|
||||||
|
cloud_runner_logger_1.default.log(`Checking if Library cache ${libraryCacheFolder}/${latestLibraryCacheFile} exists`);
|
||||||
|
if (fs_1.default.existsSync(latestLibraryCacheFile)) {
|
||||||
|
cloud_runner_logger_1.default.log(`Library cache exists`);
|
||||||
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
|
unzip -q "${libraryCacheFolder}/${latestLibraryCacheFile}" -d "$projectPathFull"
|
||||||
|
tree "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}"
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
}
|
||||||
# if the unity git project has included the library delete it and echo a warning
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
if [ -d "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}" ]; then
|
echo ' '
|
||||||
rm -r "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}"
|
echo 'Large File Caching'
|
||||||
echo "!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)"
|
echo "Checking large file cache exists (${lfsCacheFolder}/${LFS_ASSETS_HASH}.zip)"
|
||||||
fi
|
cd ${lfsCacheFolder}
|
||||||
|
if [ -f "${LFS_ASSETS_HASH}.zip" ]; then
|
||||||
|
echo "Match found: using large file hash match ${LFS_ASSETS_HASH}.zip"
|
||||||
|
latestLFSCacheFile="${LFS_ASSETS_HASH}"
|
||||||
|
else
|
||||||
|
latestLFSCacheFile=$(ls -t "${lfsCacheFolder}" | grep .zip$ | head -1)
|
||||||
|
echo "Match not found: using latest large file cache $latestLFSCacheFile"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$latestLFSCacheFile" ]; then
|
||||||
|
echo "LFS cache exists from build $latestLFSCacheFile from $branch"
|
||||||
|
rm -r "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}"
|
||||||
|
unzip -q "${lfsCacheFolder}/$latestLFSCacheFile" -d "$repoPathFull/.git"
|
||||||
|
echo "git LFS folder, (should not contain $latestLFSCacheFile)"
|
||||||
|
ls -lh "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/"
|
||||||
|
fi
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
# Restore library cache
|
echo ' '
|
||||||
ls -lh "${libraryCacheFolder}"
|
echo "LFS cache for $branch"
|
||||||
latestLibraryCacheFile=$(ls -t "${libraryCacheFolder}" | grep .zip$ | head -1)
|
du -sch "${lfsCacheFolder}/"
|
||||||
echo "Checking if Library cache ${libraryCacheFolder}/$latestLibraryCacheFile exists"
|
echo '**'
|
||||||
cd ${libraryCacheFolder}
|
echo "Library cache for $branch"
|
||||||
if [ -f "$latestLibraryCacheFile" ]; then
|
du -sch "${libraryCacheFolder}/"
|
||||||
echo "Library cache exists"
|
echo '**'
|
||||||
unzip -q "${libraryCacheFolder}/$latestLibraryCacheFile" -d "$projectPathFull"
|
echo "Branch: $branch"
|
||||||
tree "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}"
|
du -sch "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/"
|
||||||
fi
|
echo '**'
|
||||||
|
echo 'Full cache'
|
||||||
|
du -sch "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/"
|
||||||
|
echo ' '
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
echo ' '
|
cd "${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||||
echo 'Large File Caching'
|
git lfs pull
|
||||||
echo "Checking large file cache exists (${lfsCacheFolder}/$LFS_ASSETS_HASH.zip)"
|
echo 'pulled latest LFS files'
|
||||||
cd ${lfsCacheFolder}
|
|
||||||
if [ -f "$LFS_ASSETS_HASH.zip" ]; then
|
|
||||||
echo "Match found: using large file hash match $LFS_ASSETS_HASH.zip"
|
|
||||||
latestLFSCacheFile="$LFS_ASSETS_HASH"
|
|
||||||
else
|
|
||||||
latestLFSCacheFile=$(ls -t "${lfsCacheFolder}" | grep .zip$ | head -1)
|
|
||||||
echo "Match not found: using latest large file cache $latestLFSCacheFile"
|
|
||||||
fi
|
|
||||||
if [ ! -f "$latestLFSCacheFile" ]; then
|
|
||||||
echo "LFS cache exists from build $latestLFSCacheFile from $branch"
|
|
||||||
rm -r "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}"
|
|
||||||
unzip -q "${lfsCacheFolder}/$latestLFSCacheFile" -d "$repoPathFull/.git"
|
|
||||||
echo "git LFS folder, (should not contain $latestLFSCacheFile)"
|
|
||||||
ls -lh "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/"
|
|
||||||
fi
|
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
echo ' '
|
cd "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/.."
|
||||||
echo "LFS cache for $branch"
|
zip -q -r "${LFS_ASSETS_HASH}.zip" "./lfs"
|
||||||
du -sch "${lfsCacheFolder}/"
|
cp "${LFS_ASSETS_HASH}.zip" "${lfsCacheFolder}"
|
||||||
echo '**'
|
echo "copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}"
|
||||||
echo "Library cache for $branch"
|
|
||||||
du -sch "${libraryCacheFolder}/"
|
|
||||||
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 ' '
|
|
||||||
`);
|
`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
if (process.env.purgeRemoteCaching !== undefined) {
|
||||||
cd "${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
cloud_runner_logger_1.default.log(`purging ${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}`);
|
||||||
git lfs pull
|
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.cacheFolder, { recursive: true });
|
||||||
echo 'pulled latest LFS files'
|
}
|
||||||
`);
|
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
|
||||||
cd "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/.."
|
|
||||||
zip -q -r "$LFS_ASSETS_HASH.zip" "./lfs"
|
|
||||||
cp "$LFS_ASSETS_HASH.zip" "${lfsCacheFolder}"
|
|
||||||
echo "copied $LFS_ASSETS_HASH to ${lfsCacheFolder}"
|
|
||||||
`);
|
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
|
||||||
# purge cache
|
|
||||||
if [ -z "${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}" ]; then
|
|
||||||
echo ' '
|
|
||||||
echo "purging ${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}"
|
|
||||||
rm -r "${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}"
|
|
||||||
echo ' '
|
|
||||||
fi
|
|
||||||
`);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2570,25 +2558,25 @@ class BuildStep {
|
||||||
}
|
}
|
||||||
static BuildStep(image, environmentVariables, secrets) {
|
static BuildStep(image, environmentVariables, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cloud_runner_logger_1.default.logLine('Starting part 2/4 (build unity project)');
|
cloud_runner_logger_1.default.logLine('Starting part 2/2 (build unity project)');
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
||||||
`
|
`
|
||||||
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
||||||
chmod -R +x "/entrypoint.sh"
|
chmod -R +x "/entrypoint.sh"
|
||||||
chmod -R +x "/steps"
|
chmod -R +x "/steps"
|
||||||
/entrypoint.sh
|
/entrypoint.sh
|
||||||
apk update -q
|
apk update -q
|
||||||
apk add zip tree -q
|
apk add zip tree -q
|
||||||
cd "$libraryFolderFull/.."
|
cd "$libraryFolderFull/.."
|
||||||
zip -r "lib-$BUILDID.zip" "./Library"
|
zip -r "lib-$BUILDID.zip" "./Library"
|
||||||
mv "lib-$BUILDID.zip" "/$cacheFolderFull/lib"
|
mv "lib-$BUILDID.zip" "/$cacheFolderFull/lib"
|
||||||
cd "$repoPathFull"
|
cd "$repoPathFull"
|
||||||
ls -lh "$repoPathFull"
|
ls -lh "$repoPathFull"
|
||||||
zip -r "build-$BUILDID.zip" "./${cloud_runner_state_1.CloudRunnerState.buildParams.buildPath}"
|
zip -r "build-$BUILDID.zip" "./${cloud_runner_state_1.CloudRunnerState.buildParams.buildPath}"
|
||||||
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
||||||
`,
|
`,
|
||||||
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
|
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
|
||||||
});
|
});
|
||||||
|
|
@ -2599,7 +2587,7 @@ exports.BuildStep = BuildStep;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 12929:
|
/***/ 10359:
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
@ -2617,34 +2605,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.DownloadRepositoryStep = void 0;
|
exports.DownloadStep = void 0;
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
class DownloadRepositoryStep {
|
class DownloadStep {
|
||||||
run(cloudRunnerStepState) {
|
run(cloudRunnerStepState) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
yield DownloadRepositoryStep.downloadRepositoryStep(cloudRunnerStepState.image, cloudRunnerStepState.environment, cloudRunnerStepState.secrets);
|
yield DownloadStep.downloadRepository(cloudRunnerStepState.image, cloudRunnerStepState.environment, cloudRunnerStepState.secrets);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static downloadRepositoryStep(image, environmentVariables, secrets) {
|
static downloadRepository(image, environmentVariables, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
cloud_runner_logger_1.default.logLine('Starting step 1/4 clone and restore cache');
|
cloud_runner_logger_1.default.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
||||||
`
|
`
|
||||||
apk update -q
|
apk update -q
|
||||||
apk add unzip zip git-lfs jq tree nodejs -q
|
apk add unzip zip git-lfs jq tree nodejs -q
|
||||||
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||||
mkdir -p ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
mkdir -p ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
||||||
echo "${cloud_runner_state_1.CloudRunnerState.cloneBuilderCommand}"
|
echo "${cloud_runner_state_1.CloudRunnerState.cloneBuilderCommand}"
|
||||||
${cloud_runner_state_1.CloudRunnerState.cloneBuilderCommand}
|
${cloud_runner_state_1.CloudRunnerState.cloneBuilderCommand}
|
||||||
chmod +x ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js
|
chmod +x ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js
|
||||||
node ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
|
node ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
|
||||||
`,
|
`,
|
||||||
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}/`, environmentVariables, secrets);
|
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}/`, environmentVariables, secrets);
|
||||||
}
|
}
|
||||||
|
|
@ -2655,7 +2643,7 @@ class DownloadRepositoryStep {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.DownloadRepositoryStep = DownloadRepositoryStep;
|
exports.DownloadStep = DownloadStep;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
@ -2683,7 +2671,7 @@ const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
const cloud_runner_step_state_1 = __webpack_require__(64854);
|
const cloud_runner_step_state_1 = __webpack_require__(64854);
|
||||||
const build_step_1 = __webpack_require__(91491);
|
const build_step_1 = __webpack_require__(91491);
|
||||||
const download_repository_step_1 = __webpack_require__(12929);
|
const download_step_1 = __webpack_require__(10359);
|
||||||
const custom_workflow_1 = __webpack_require__(3786);
|
const custom_workflow_1 = __webpack_require__(3786);
|
||||||
class BuildAutomationWorkflow {
|
class BuildAutomationWorkflow {
|
||||||
run(cloudRunnerStepState) {
|
run(cloudRunnerStepState) {
|
||||||
|
|
@ -2700,7 +2688,7 @@ class BuildAutomationWorkflow {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
cloud_runner_logger_1.default.log(`Cloud Runner is running standard build automation`);
|
cloud_runner_logger_1.default.log(`Cloud Runner is running standard build automation`);
|
||||||
yield new download_repository_step_1.DownloadRepositoryStep().run(new cloud_runner_step_state_1.CloudRunnerStepState('alpine/git', cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
yield new download_step_1.DownloadStep().run(new cloud_runner_step_state_1.CloudRunnerStepState('alpine/git', cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
||||||
cloud_runner_logger_1.default.logWithTime('Download repository step time');
|
cloud_runner_logger_1.default.logWithTime('Download repository step time');
|
||||||
if (cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps !== '') {
|
if (cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps !== '') {
|
||||||
yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps);
|
yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps);
|
||||||
|
|
@ -2869,7 +2857,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.WorkflowCompositionRoot = void 0;
|
exports.WorkflowCompositionRoot = void 0;
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
const cloud_runner_step_state_1 = __webpack_require__(64854);
|
const cloud_runner_step_state_1 = __webpack_require__(64854);
|
||||||
const download_repository_step_1 = __webpack_require__(12929);
|
const download_step_1 = __webpack_require__(10359);
|
||||||
const custom_workflow_1 = __webpack_require__(3786);
|
const custom_workflow_1 = __webpack_require__(3786);
|
||||||
const ephemeral_github_runner_workflow_1 = __webpack_require__(37092);
|
const ephemeral_github_runner_workflow_1 = __webpack_require__(37092);
|
||||||
const core = __importStar(__webpack_require__(42186));
|
const core = __importStar(__webpack_require__(42186));
|
||||||
|
|
@ -2897,7 +2885,7 @@ class WorkflowCompositionRoot {
|
||||||
yield new ephemeral_github_runner_workflow_1.EphemeralGitHubRunnerWorkflow().run(new cloud_runner_step_state_1.CloudRunnerStepState(baseImage, cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
yield new ephemeral_github_runner_workflow_1.EphemeralGitHubRunnerWorkflow().run(new cloud_runner_step_state_1.CloudRunnerStepState(baseImage, cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
||||||
}
|
}
|
||||||
else if (cloud_runner_state_1.CloudRunnerState.buildParams.customBuildSteps === 'download') {
|
else if (cloud_runner_state_1.CloudRunnerState.buildParams.customBuildSteps === 'download') {
|
||||||
yield new download_repository_step_1.DownloadRepositoryStep().run(new cloud_runner_step_state_1.CloudRunnerStepState('alpine/git', cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
yield new download_step_1.DownloadStep().run(new cloud_runner_step_state_1.CloudRunnerStepState('alpine/git', cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.customBuildSteps);
|
yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.customBuildSteps);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,17 +1,15 @@
|
||||||
import { CloudRunnerState } from '../../state/cloud-runner-state';
|
import { CloudRunnerState } from '../../state/cloud-runner-state';
|
||||||
import { RunCli } from '../run-cli';
|
import { RunCli } from '../run-cli';
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import CloudRunnerLogger from '../../services/cloud-runner-logger';
|
||||||
|
|
||||||
export class DownloadRepository {
|
export class DownloadRepository {
|
||||||
public static async run() {
|
public static async run() {
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`tree -f -L 2tree -f -L 2`);
|
||||||
tree -f -L 2tree -f -L 2
|
fs.mkdirSync(CloudRunnerState.buildPathFull);
|
||||||
echo "test"
|
fs.mkdirSync(CloudRunnerState.repoPathFull);
|
||||||
mkdir -p ${CloudRunnerState.buildPathFull}
|
CloudRunnerLogger.log(`Initializing source repository for cloning with caching of LFS files`);
|
||||||
mkdir -p ${CloudRunnerState.repoPathFull}
|
|
||||||
echo ' '
|
|
||||||
echo 'Initializing source repository for cloning with caching of LFS files'
|
|
||||||
githubSha=$GITHUB_SHA
|
|
||||||
`);
|
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
cd ${CloudRunnerState.repoPathFull}
|
cd ${CloudRunnerState.repoPathFull}
|
||||||
# stop annoying git detatched head info
|
# stop annoying git detatched head info
|
||||||
|
|
@ -21,16 +19,14 @@ export class DownloadRepository {
|
||||||
git lfs install --skip-smudge
|
git lfs install --skip-smudge
|
||||||
echo "${CloudRunnerState.targetBuildRepoUrl}"
|
echo "${CloudRunnerState.targetBuildRepoUrl}"
|
||||||
git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}
|
git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}
|
||||||
git checkout $githubSha
|
git checkout ${process.env.GITHUB_SHA}
|
||||||
echo "Checked out $githubSha"
|
echo "Checked out ${process.env.GITHUB_SHA}"
|
||||||
`);
|
`);
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
||||||
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
||||||
`);
|
`);
|
||||||
await RunCli.RunCli(`
|
const LFS_ASSETS_HASH = fs.readFileSync(`${CloudRunnerState.repoPathFull}/.lfs-assets-guid`, 'utf8');
|
||||||
export LFS_ASSETS_HASH="$(cat ${CloudRunnerState.repoPathFull}/.lfs-assets-guid)"
|
|
||||||
`);
|
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
echo ' '
|
echo ' '
|
||||||
echo 'Contents of .lfs-assets-guid file:'
|
echo 'Contents of .lfs-assets-guid file:'
|
||||||
|
|
@ -45,40 +41,37 @@ export class DownloadRepository {
|
||||||
`);
|
`);
|
||||||
const lfsCacheFolder = `${CloudRunnerState.cacheFolderFull}/lfs`;
|
const lfsCacheFolder = `${CloudRunnerState.cacheFolderFull}/lfs`;
|
||||||
const libraryCacheFolder = `${CloudRunnerState.cacheFolderFull}/lib`;
|
const libraryCacheFolder = `${CloudRunnerState.cacheFolderFull}/lib`;
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`tree ${CloudRunnerState.builderPathFull}`);
|
||||||
tree ${CloudRunnerState.builderPathFull}
|
CloudRunnerLogger.log(`Starting checks of cache for the Unity project Library and git LFS files`);
|
||||||
echo 'Starting checks of cache for the Unity project Library and git LFS files'
|
fs.mkdirSync(lfsCacheFolder);
|
||||||
mkdir -p "${lfsCacheFolder}"
|
fs.mkdirSync(libraryCacheFolder);
|
||||||
mkdir -p "${libraryCacheFolder}"
|
CloudRunnerLogger.log(`Library Caching`);
|
||||||
echo 'Library Caching'
|
//if the unity git project has included the library delete it and echo a warning
|
||||||
`);
|
if (fs.existsSync(CloudRunnerState.libraryFolderFull)) {
|
||||||
await RunCli.RunCli(`
|
fs.rmdirSync(CloudRunnerState.libraryFolderFull, { recursive: true });
|
||||||
# if the unity git project has included the library delete it and echo a warning
|
CloudRunnerLogger.log(
|
||||||
if [ -d "${CloudRunnerState.libraryFolderFull}" ]; then
|
`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`,
|
||||||
rm -r "${CloudRunnerState.libraryFolderFull}"
|
);
|
||||||
echo "!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)"
|
}
|
||||||
fi
|
//Restore library cache
|
||||||
`);
|
const latestLibraryCacheFile = await RunCli.RunCli(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`ls -lh "${libraryCacheFolder}"`);
|
||||||
# Restore library cache
|
CloudRunnerLogger.log(`Checking if Library cache ${libraryCacheFolder}/${latestLibraryCacheFile} exists`);
|
||||||
ls -lh "${libraryCacheFolder}"
|
if (fs.existsSync(latestLibraryCacheFile)) {
|
||||||
latestLibraryCacheFile=$(ls -t "${libraryCacheFolder}" | grep .zip$ | head -1)
|
CloudRunnerLogger.log(`Library cache exists`);
|
||||||
echo "Checking if Library cache ${libraryCacheFolder}/$latestLibraryCacheFile exists"
|
await RunCli.RunCli(`
|
||||||
cd ${libraryCacheFolder}
|
unzip -q "${libraryCacheFolder}/${latestLibraryCacheFile}" -d "$projectPathFull"
|
||||||
if [ -f "$latestLibraryCacheFile" ]; then
|
tree "${CloudRunnerState.libraryFolderFull}"
|
||||||
echo "Library cache exists"
|
|
||||||
unzip -q "${libraryCacheFolder}/$latestLibraryCacheFile" -d "$projectPathFull"
|
|
||||||
tree "${CloudRunnerState.libraryFolderFull}"
|
|
||||||
fi
|
|
||||||
`);
|
`);
|
||||||
|
}
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
echo ' '
|
echo ' '
|
||||||
echo 'Large File Caching'
|
echo 'Large File Caching'
|
||||||
echo "Checking large file cache exists (${lfsCacheFolder}/$LFS_ASSETS_HASH.zip)"
|
echo "Checking large file cache exists (${lfsCacheFolder}/${LFS_ASSETS_HASH}.zip)"
|
||||||
cd ${lfsCacheFolder}
|
cd ${lfsCacheFolder}
|
||||||
if [ -f "$LFS_ASSETS_HASH.zip" ]; then
|
if [ -f "${LFS_ASSETS_HASH}.zip" ]; then
|
||||||
echo "Match found: using large file hash match $LFS_ASSETS_HASH.zip"
|
echo "Match found: using large file hash match ${LFS_ASSETS_HASH}.zip"
|
||||||
latestLFSCacheFile="$LFS_ASSETS_HASH"
|
latestLFSCacheFile="${LFS_ASSETS_HASH}"
|
||||||
else
|
else
|
||||||
latestLFSCacheFile=$(ls -t "${lfsCacheFolder}" | grep .zip$ | head -1)
|
latestLFSCacheFile=$(ls -t "${lfsCacheFolder}" | grep .zip$ | head -1)
|
||||||
echo "Match not found: using latest large file cache $latestLFSCacheFile"
|
echo "Match not found: using latest large file cache $latestLFSCacheFile"
|
||||||
|
|
@ -113,18 +106,13 @@ export class DownloadRepository {
|
||||||
`);
|
`);
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
cd "${CloudRunnerState.lfsDirectory}/.."
|
cd "${CloudRunnerState.lfsDirectory}/.."
|
||||||
zip -q -r "$LFS_ASSETS_HASH.zip" "./lfs"
|
zip -q -r "${LFS_ASSETS_HASH}.zip" "./lfs"
|
||||||
cp "$LFS_ASSETS_HASH.zip" "${lfsCacheFolder}"
|
cp "${LFS_ASSETS_HASH}.zip" "${lfsCacheFolder}"
|
||||||
echo "copied $LFS_ASSETS_HASH to ${lfsCacheFolder}"
|
echo "copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}"
|
||||||
`);
|
`);
|
||||||
await RunCli.RunCli(`
|
if (process.env.purgeRemoteCaching !== undefined) {
|
||||||
# purge cache
|
CloudRunnerLogger.log(`purging ${CloudRunnerState.purgeRemoteCaching}`);
|
||||||
if [ -z "${CloudRunnerState.purgeRemoteCaching}" ]; then
|
fs.rmdirSync(CloudRunnerState.cacheFolder, { recursive: true });
|
||||||
echo ' '
|
}
|
||||||
echo "purging ${CloudRunnerState.purgeRemoteCaching}"
|
|
||||||
rm -r "${CloudRunnerState.purgeRemoteCaching}"
|
|
||||||
echo ' '
|
|
||||||
fi
|
|
||||||
`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export class BuildStep implements StepInterface {
|
||||||
environmentVariables: CloudRunnerEnvironmentVariable[],
|
environmentVariables: CloudRunnerEnvironmentVariable[],
|
||||||
secrets: CloudRunnerSecret[],
|
secrets: CloudRunnerSecret[],
|
||||||
) {
|
) {
|
||||||
CloudRunnerLogger.logLine('Starting part 2/4 (build unity project)');
|
CloudRunnerLogger.logLine('Starting part 2/2 (build unity project)');
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
image,
|
image,
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import { CloudRunnerState } from '../state/cloud-runner-state';
|
||||||
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
||||||
import { StepInterface } from './step-interface';
|
import { StepInterface } from './step-interface';
|
||||||
|
|
||||||
export class DownloadRepositoryStep implements StepInterface {
|
export class DownloadStep implements StepInterface {
|
||||||
async run(cloudRunnerStepState: CloudRunnerStepState) {
|
async run(cloudRunnerStepState: CloudRunnerStepState) {
|
||||||
try {
|
try {
|
||||||
await DownloadRepositoryStep.downloadRepositoryStep(
|
await DownloadStep.downloadRepository(
|
||||||
cloudRunnerStepState.image,
|
cloudRunnerStepState.image,
|
||||||
cloudRunnerStepState.environment,
|
cloudRunnerStepState.environment,
|
||||||
cloudRunnerStepState.secrets,
|
cloudRunnerStepState.secrets,
|
||||||
|
|
@ -18,13 +18,13 @@ export class DownloadRepositoryStep implements StepInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async downloadRepositoryStep(
|
private static async downloadRepository(
|
||||||
image: string,
|
image: string,
|
||||||
environmentVariables: CloudRunnerEnvironmentVariable[],
|
environmentVariables: CloudRunnerEnvironmentVariable[],
|
||||||
secrets: CloudRunnerSecret[],
|
secrets: CloudRunnerSecret[],
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
CloudRunnerLogger.logLine('Starting step 1/4 clone and restore cache');
|
CloudRunnerLogger.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
image,
|
image,
|
||||||
|
|
@ -2,7 +2,7 @@ import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
import { CloudRunnerState } from '../state/cloud-runner-state';
|
import { CloudRunnerState } from '../state/cloud-runner-state';
|
||||||
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
||||||
import { BuildStep } from '../steps/build-step';
|
import { BuildStep } from '../steps/build-step';
|
||||||
import { DownloadRepositoryStep } from '../steps/download-repository-step';
|
import { DownloadStep } from '../steps/download-step';
|
||||||
import { CustomWorkflow } from './custom-workflow';
|
import { CustomWorkflow } from './custom-workflow';
|
||||||
import { WorkflowInterface } from './workflow-interface';
|
import { WorkflowInterface } from './workflow-interface';
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
|
||||||
try {
|
try {
|
||||||
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
|
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
|
||||||
|
|
||||||
await new DownloadRepositoryStep().run(
|
await new DownloadStep().run(
|
||||||
new CloudRunnerStepState(
|
new CloudRunnerStepState(
|
||||||
'alpine/git',
|
'alpine/git',
|
||||||
CloudRunnerState.readBuildEnvironmentVariables(),
|
CloudRunnerState.readBuildEnvironmentVariables(),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { CloudRunnerState } from '../state/cloud-runner-state';
|
import { CloudRunnerState } from '../state/cloud-runner-state';
|
||||||
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
import { CloudRunnerStepState } from '../state/cloud-runner-step-state';
|
||||||
import { DownloadRepositoryStep } from '../steps/download-repository-step';
|
import { DownloadStep } from '../steps/download-step';
|
||||||
import { CustomWorkflow } from './custom-workflow';
|
import { CustomWorkflow } from './custom-workflow';
|
||||||
import { EphemeralGitHubRunnerWorkflow } from './ephemeral-github-runner-workflow';
|
import { EphemeralGitHubRunnerWorkflow } from './ephemeral-github-runner-workflow';
|
||||||
import { WorkflowInterface } from './workflow-interface';
|
import { WorkflowInterface } from './workflow-interface';
|
||||||
|
|
@ -43,7 +43,7 @@ export class WorkflowCompositionRoot implements WorkflowInterface {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (CloudRunnerState.buildParams.customBuildSteps === 'download') {
|
} else if (CloudRunnerState.buildParams.customBuildSteps === 'download') {
|
||||||
await new DownloadRepositoryStep().run(
|
await new DownloadStep().run(
|
||||||
new CloudRunnerStepState(
|
new CloudRunnerStepState(
|
||||||
'alpine/git',
|
'alpine/git',
|
||||||
CloudRunnerState.readBuildEnvironmentVariables(),
|
CloudRunnerState.readBuildEnvironmentVariables(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue