break download step into remote-client template

pull/310/head
Frostebite 2021-12-21 06:47:29 +00:00
parent bdc0c7f34e
commit f725479d7a
4 changed files with 96 additions and 50 deletions

68
dist/index.js vendored
View File

@ -1999,12 +1999,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DownloadRepository = void 0;
const cloud_runner_state_1 = __webpack_require__(70912);
const { exec } = __webpack_require__(63129);
const run_cli_1 = __webpack_require__(33639);
class DownloadRepository {
static run() {
return __awaiter(this, void 0, void 0, function* () {
yield new Promise((promise) => {
exec(`
yield run_cli_1.RunCli.RunCli(`
tree -f -L 2tree -f -L 2
echo "test"
mkdir -p ${cloud_runner_state_1.CloudRunnerState.buildPathFull}
@ -2013,6 +2012,8 @@ class DownloadRepository {
echo 'Initializing source repository for cloning with caching of LFS files'
repoPathFull=${cloud_runner_state_1.CloudRunnerState.repoPathFull}
githubSha=$GITHUB_SHA
`);
yield run_cli_1.RunCli.RunCli(`
cd ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
# stop annoying git detatched head info
git config --global advice.detachedHead false
@ -2023,46 +2024,81 @@ class DownloadRepository {
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(`
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
`);
yield run_cli_1.RunCli.RunCli(`
export LFS_ASSETS_HASH="$(cat ${cloud_runner_state_1.CloudRunnerState.repoPathFull}/.lfs-assets-guid)"
`);
yield run_cli_1.RunCli.RunCli(`
echo ' '
echo 'Contents of .lfs-assets-guid file:'
cat .lfs-assets-guid
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 ' '
# echo 'Starting checks of cache for the Unity project Library and git LFS files'
# ${cloud_runner_state_1.CloudRunnerState.getHandleCachingCommand}
`, (error, stdout, stderr) => {
echo 'Source repository initialized'
ls ${cloud_runner_state_1.CloudRunnerState.projectPathFull}
echo ' '
`);
yield run_cli_1.RunCli.RunCli(`
echo 'Starting checks of cache for the Unity project Library and git LFS files'
${cloud_runner_state_1.CloudRunnerState.getHandleCachingCommand}
`);
});
}
}
exports.DownloadRepository = DownloadRepository;
/***/ }),
/***/ 33639:
/***/ (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.RunCli = void 0;
const child_process_1 = __webpack_require__(63129);
class RunCli {
static RunCli(command) {
return __awaiter(this, void 0, void 0, function* () {
return yield new Promise((promise) => {
child_process_1.exec(command, (error, stdout, stderr) => {
if (error) {
// eslint-disable-next-line no-console
console.log(`error: ${error.message}`);
promise();
promise(error.message);
return;
}
if (stderr) {
// eslint-disable-next-line no-console
console.log(`stderr: ${stderr}`);
promise();
promise(stderr);
return;
}
// eslint-disable-next-line no-console
console.log(`stdout: ${stdout}`);
promise();
promise(stdout);
});
});
});
}
}
exports.DownloadRepository = DownloadRepository;
exports.RunCli = RunCli;
/***/ }),

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,9 @@
import { CloudRunnerState } from '../../state/cloud-runner-state';
const { exec } = require('child_process');
import { RunCli } from '../run-cli';
export class DownloadRepository {
public static async run() {
await new Promise<void>((promise) => {
exec(
`
await RunCli.RunCli(`
tree -f -L 2tree -f -L 2
echo "test"
mkdir -p ${CloudRunnerState.buildPathFull}
@ -15,6 +12,8 @@ export class DownloadRepository {
echo 'Initializing source repository for cloning with caching of LFS files'
repoPathFull=${CloudRunnerState.repoPathFull}
githubSha=$GITHUB_SHA
`);
await RunCli.RunCli(`
cd ${CloudRunnerState.repoPathFull}
# stop annoying git detatched head info
git config --global advice.detachedHead false
@ -25,43 +24,29 @@ export class DownloadRepository {
git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}
git checkout $githubSha
echo "Checked out $githubSha"
`);
await RunCli.RunCli(`
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
`);
await RunCli.RunCli(`
export LFS_ASSETS_HASH="$(cat ${CloudRunnerState.repoPathFull}/.lfs-assets-guid)"
`);
await RunCli.RunCli(`
echo ' '
echo 'Contents of .lfs-assets-guid file:'
cat .lfs-assets-guid
echo ' '
echo 'Contents of .lfs-assets-guid-sum file:'
cat .lfs-assets-guid-sum
echo ' '
# echo 'Source repository initialized'
# ls ${CloudRunnerState.projectPathFull}
# echo ' '
# echo 'Starting checks of cache for the Unity project Library and git LFS files'
# ${CloudRunnerState.getHandleCachingCommand}
`,
(error, stdout, stderr) => {
if (error) {
// eslint-disable-next-line no-console
console.log(`error: ${error.message}`);
promise();
return;
}
if (stderr) {
// eslint-disable-next-line no-console
console.log(`stderr: ${stderr}`);
promise();
return;
}
// eslint-disable-next-line no-console
console.log(`stdout: ${stdout}`);
promise();
},
);
});
echo 'Source repository initialized'
ls ${CloudRunnerState.projectPathFull}
echo ' '
`);
await RunCli.RunCli(`
echo 'Starting checks of cache for the Unity project Library and git LFS files'
${CloudRunnerState.getHandleCachingCommand}
`);
}
}

View File

@ -0,0 +1,25 @@
import { exec } from 'child_process';
export class RunCli {
public static async RunCli(command: string) {
return await new Promise<string>((promise) => {
exec(command, (error, stdout, stderr) => {
if (error) {
// eslint-disable-next-line no-console
console.log(`error: ${error.message}`);
promise(error.message);
return;
}
if (stderr) {
// eslint-disable-next-line no-console
console.log(`stderr: ${stderr}`);
promise(stderr);
return;
}
// eslint-disable-next-line no-console
console.log(`stdout: ${stdout}`);
promise(stdout);
});
});
}
}