Move shell scripts into remote-cli

pull/310/head
Frostebite 2021-12-19 22:04:02 +00:00
parent dae249cd4a
commit 8180c2c47d
7 changed files with 81 additions and 74 deletions

View File

@ -1,32 +0,0 @@
#!/bin/sh
repoPathFull=$1
cloneUrl=$2
githubSha=$GITHUB_SHA
cd $repoPathFull
# stop annoying git detatched head info
git config --global advice.detachedHead false
echo ' '
echo "Cloning the repository being built:"
git lfs install --skip-smudge
git clone $cloneUrl $repoPathFull
git checkout $githubSha
echo "Checked out $githubSha"
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
export LFS_ASSETS_HASH="$(cat $repoPathFull/.lfs-assets-guid)"
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 ' '

60
dist/index.js vendored
View File

@ -1962,8 +1962,6 @@ class RemoteClientCli {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const buff = Buffer.from(process.env.SERIALIZED_BUILD_PARAMS || '', 'base64'); const buff = Buffer.from(process.env.SERIALIZED_BUILD_PARAMS || '', 'base64');
const text = buff.toString('ascii'); const text = buff.toString('ascii');
// eslint-disable-next-line no-console
console.log(text);
cloud_runner_state_1.CloudRunnerState.setup(JSON.parse(text)); cloud_runner_state_1.CloudRunnerState.setup(JSON.parse(text));
switch (options.remoteClientState) { switch (options.remoteClientState) {
default: default:
@ -2002,9 +2000,45 @@ class DownloadRepository {
yield new Promise((promise) => { yield new Promise((promise) => {
exec(` exec(`
echo "test" echo "test"
apk update -q mkdir -p ${cloud_runner_state_1.CloudRunnerState.buildPathFull}
apk add unzip zip git-lfs jq tree -q mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
${cloud_runner_state_1.CloudRunnerState.cloneBuilderCommand} echo ' '
echo 'Initializing source repository for cloning with caching of LFS files'
repoPathFull=${cloud_runner_state_1.CloudRunnerState.repoPathFull}
cloneUrl=${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl}
githubSha=$GITHUB_SHA
cd $repoPathFull
# stop annoying git detatched head info
git config --global advice.detachedHead false
echo ' '
echo "Cloning the repository being built:"
git lfs install --skip-smudge
git clone $cloneUrl $repoPathFull
git checkout $githubSha
echo "Checked out $githubSha"
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
export LFS_ASSETS_HASH="$(cat $repoPathFull/.lfs-assets-guid)"
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) => { `, (error, stdout, stderr) => {
if (error) { if (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@ -2241,12 +2275,9 @@ class CloudRunnerState {
}, },
]; ];
} }
static getHandleCachingCommand() { static get getHandleCachingCommand() {
return `${CloudRunnerState.builderPathFull}/dist/cloud-runner/handleCaching.sh "${CloudRunnerState.cacheFolderFull}" "${CloudRunnerState.libraryFolderFull}" "${CloudRunnerState.lfsDirectory}" "${CloudRunnerState.purgeRemoteCaching}"`; return `${CloudRunnerState.builderPathFull}/dist/cloud-runner/handleCaching.sh "${CloudRunnerState.cacheFolderFull}" "${CloudRunnerState.libraryFolderFull}" "${CloudRunnerState.lfsDirectory}" "${CloudRunnerState.purgeRemoteCaching}"`;
} }
static getCloneNoLFSCommand() {
return `${CloudRunnerState.builderPathFull}/dist/cloud-runner/cloneNoLFS.sh "${CloudRunnerState.repoPathFull}" "${CloudRunnerState.targetBuildRepoUrl}"`;
}
static get cloneBuilderCommand() { static get cloneBuilderCommand() {
const cloneCommand = `git clone -b ${CloudRunnerState.branchName} ${CloudRunnerState.unityBuilderRepoUrl} ${CloudRunnerState.builderPathFull}`; const cloneCommand = `git clone -b ${CloudRunnerState.branchName} ${CloudRunnerState.unityBuilderRepoUrl} ${CloudRunnerState.builderPathFull}`;
cloud_runner_logger_1.default.log(cloneCommand); cloud_runner_logger_1.default.log(cloneCommand);
@ -2509,23 +2540,12 @@ class DownloadRepositoryStep {
` printenv ` printenv
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.buildPathFull}
mkdir -p ${cloud_runner_state_1.CloudRunnerState.builderPathFull} mkdir -p ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
# mkdir -p ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
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
# echo ' '
# echo 'Initializing source repository for cloning with caching of LFS files'
# ${cloud_runner_state_1.CloudRunnerState.getCloneNoLFSCommand()}
# 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()}
`, `,
], `/${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);
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -5,8 +5,6 @@ export class RemoteClientCli {
static async RunRemoteClient(options) { static async RunRemoteClient(options) {
const buff = Buffer.from(process.env.SERIALIZED_BUILD_PARAMS || '', 'base64'); const buff = Buffer.from(process.env.SERIALIZED_BUILD_PARAMS || '', 'base64');
const text = buff.toString('ascii'); const text = buff.toString('ascii');
// eslint-disable-next-line no-console
console.log(text);
CloudRunnerState.setup(JSON.parse(text)); CloudRunnerState.setup(JSON.parse(text));
switch (options.remoteClientState) { switch (options.remoteClientState) {
default: default:

View File

@ -8,9 +8,45 @@ export class DownloadRepository {
exec( exec(
` `
echo "test" echo "test"
apk update -q mkdir -p ${CloudRunnerState.buildPathFull}
apk add unzip zip git-lfs jq tree -q mkdir -p ${CloudRunnerState.repoPathFull}
${CloudRunnerState.cloneBuilderCommand} echo ' '
echo 'Initializing source repository for cloning with caching of LFS files'
repoPathFull=${CloudRunnerState.repoPathFull}
cloneUrl=${CloudRunnerState.targetBuildRepoUrl}
githubSha=$GITHUB_SHA
cd $repoPathFull
# stop annoying git detatched head info
git config --global advice.detachedHead false
echo ' '
echo "Cloning the repository being built:"
git lfs install --skip-smudge
git clone $cloneUrl $repoPathFull
git checkout $githubSha
echo "Checked out $githubSha"
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
export LFS_ASSETS_HASH="$(cat $repoPathFull/.lfs-assets-guid)"
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) => { (error, stdout, stderr) => {
if (error) { if (error) {

View File

@ -129,14 +129,10 @@ export class CloudRunnerState {
]; ];
} }
public static getHandleCachingCommand() { public static get getHandleCachingCommand() {
return `${CloudRunnerState.builderPathFull}/dist/cloud-runner/handleCaching.sh "${CloudRunnerState.cacheFolderFull}" "${CloudRunnerState.libraryFolderFull}" "${CloudRunnerState.lfsDirectory}" "${CloudRunnerState.purgeRemoteCaching}"`; return `${CloudRunnerState.builderPathFull}/dist/cloud-runner/handleCaching.sh "${CloudRunnerState.cacheFolderFull}" "${CloudRunnerState.libraryFolderFull}" "${CloudRunnerState.lfsDirectory}" "${CloudRunnerState.purgeRemoteCaching}"`;
} }
public static getCloneNoLFSCommand() {
return `${CloudRunnerState.builderPathFull}/dist/cloud-runner/cloneNoLFS.sh "${CloudRunnerState.repoPathFull}" "${CloudRunnerState.targetBuildRepoUrl}"`;
}
public static get cloneBuilderCommand() { public static get cloneBuilderCommand() {
const cloneCommand = `git clone -b ${CloudRunnerState.branchName} ${CloudRunnerState.unityBuilderRepoUrl} ${CloudRunnerState.builderPathFull}`; const cloneCommand = `git clone -b ${CloudRunnerState.branchName} ${CloudRunnerState.unityBuilderRepoUrl} ${CloudRunnerState.builderPathFull}`;
CloudRunnerLogger.log(cloneCommand); CloudRunnerLogger.log(cloneCommand);

View File

@ -32,23 +32,12 @@ export class DownloadRepositoryStep implements StepInterface {
` printenv ` printenv
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 ${CloudRunnerState.buildPathFull}
mkdir -p ${CloudRunnerState.builderPathFull} mkdir -p ${CloudRunnerState.builderPathFull}
# mkdir -p ${CloudRunnerState.repoPathFull}
echo "${CloudRunnerState.cloneBuilderCommand}" echo "${CloudRunnerState.cloneBuilderCommand}"
${CloudRunnerState.cloneBuilderCommand} ${CloudRunnerState.cloneBuilderCommand}
chmod +x ${CloudRunnerState.builderPathFull}/dist/index.js chmod +x ${CloudRunnerState.builderPathFull}/dist/index.js
node ${CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli node ${CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
# echo ' '
# echo 'Initializing source repository for cloning with caching of LFS files'
# ${CloudRunnerState.getCloneNoLFSCommand()}
# echo 'Source repository initialized'
# ls ${CloudRunnerState.projectPathFull}
# echo ' '
# echo 'Starting checks of cache for the Unity project Library and git LFS files'
# ${CloudRunnerState.getHandleCachingCommand()}
`, `,
], ],
`/${CloudRunnerState.buildVolumeFolder}`, `/${CloudRunnerState.buildVolumeFolder}`,