fix
parent
e9a60d4ec8
commit
0650d1de5c
|
@ -805,6 +805,10 @@ class CloudRunner {
|
||||||
case 'local-system':
|
case 'local-system':
|
||||||
CloudRunner.Provider = new local_1.default();
|
CloudRunner.Provider = new local_1.default();
|
||||||
break;
|
break;
|
||||||
|
case 'local':
|
||||||
|
default:
|
||||||
|
CloudRunner.Provider = new local_1.default();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async run(buildParameters, baseImage) {
|
static async run(buildParameters, baseImage) {
|
||||||
|
@ -4715,6 +4719,10 @@ const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
||||||
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(66965));
|
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(66965));
|
||||||
class RemoteClientLogger {
|
class RemoteClientLogger {
|
||||||
static get LogFilePath() {
|
static get LogFilePath() {
|
||||||
|
// Use a cross-platform temporary directory for local development
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return node_path_1.default.join(process.cwd(), 'temp', 'job-log.txt');
|
||||||
|
}
|
||||||
return node_path_1.default.join(`/home`, `job-log.txt`);
|
return node_path_1.default.join(`/home`, `job-log.txt`);
|
||||||
}
|
}
|
||||||
static log(message) {
|
static log(message) {
|
||||||
|
@ -4733,6 +4741,11 @@ class RemoteClientLogger {
|
||||||
}
|
}
|
||||||
static appendToFile(message) {
|
static appendToFile(message) {
|
||||||
if (cloud_runner_1.default.isCloudRunnerEnvironment) {
|
if (cloud_runner_1.default.isCloudRunnerEnvironment) {
|
||||||
|
// Ensure the directory exists before writing
|
||||||
|
const logDirectory = node_path_1.default.dirname(RemoteClientLogger.LogFilePath);
|
||||||
|
if (!node_fs_1.default.existsSync(logDirectory)) {
|
||||||
|
node_fs_1.default.mkdirSync(logDirectory, { recursive: true });
|
||||||
|
}
|
||||||
node_fs_1.default.appendFileSync(RemoteClientLogger.LogFilePath, `${message}\n`);
|
node_fs_1.default.appendFileSync(RemoteClientLogger.LogFilePath, `${message}\n`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -80,6 +80,10 @@ class CloudRunner {
|
||||||
case 'local-system':
|
case 'local-system':
|
||||||
CloudRunner.Provider = new LocalCloudRunner();
|
CloudRunner.Provider = new LocalCloudRunner();
|
||||||
break;
|
break;
|
||||||
|
case 'local':
|
||||||
|
default:
|
||||||
|
CloudRunner.Provider = new LocalCloudRunner();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ import CloudRunnerOptions from '../options/cloud-runner-options';
|
||||||
|
|
||||||
export class RemoteClientLogger {
|
export class RemoteClientLogger {
|
||||||
private static get LogFilePath() {
|
private static get LogFilePath() {
|
||||||
|
// Use a cross-platform temporary directory for local development
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return path.join(process.cwd(), 'temp', 'job-log.txt');
|
||||||
|
}
|
||||||
|
|
||||||
return path.join(`/home`, `job-log.txt`);
|
return path.join(`/home`, `job-log.txt`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +34,12 @@ export class RemoteClientLogger {
|
||||||
|
|
||||||
public static appendToFile(message: string) {
|
public static appendToFile(message: string) {
|
||||||
if (CloudRunner.isCloudRunnerEnvironment) {
|
if (CloudRunner.isCloudRunnerEnvironment) {
|
||||||
|
// Ensure the directory exists before writing
|
||||||
|
const logDirectory = path.dirname(RemoteClientLogger.LogFilePath);
|
||||||
|
if (!fs.existsSync(logDirectory)) {
|
||||||
|
fs.mkdirSync(logDirectory, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
fs.appendFileSync(RemoteClientLogger.LogFilePath, `${message}\n`);
|
fs.appendFileSync(RemoteClientLogger.LogFilePath, `${message}\n`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ describe('Cloud Runner Sync Environments', () => {
|
||||||
- name: '${testSecretName}'
|
- name: '${testSecretName}'
|
||||||
value: '${testSecretValue}'
|
value: '${testSecretValue}'
|
||||||
`,
|
`,
|
||||||
|
cloudRunnerDebug: true,
|
||||||
});
|
});
|
||||||
const baseImage = new ImageTag(buildParameter);
|
const baseImage = new ImageTag(buildParameter);
|
||||||
if (baseImage.toString().includes('undefined')) {
|
if (baseImage.toString().includes('undefined')) {
|
||||||
|
|
|
@ -94,6 +94,7 @@ commands: echo "test"`;
|
||||||
cacheKey: `test-case-${uuidv4()}`,
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
containerHookFiles: `my-test-step-pre-build,my-test-step-post-build`,
|
containerHookFiles: `my-test-step-pre-build,my-test-step-post-build`,
|
||||||
commandHookFiles: `my-test-hook-pre-build,my-test-hook-post-build`,
|
commandHookFiles: `my-test-hook-pre-build,my-test-hook-post-build`,
|
||||||
|
cloudRunnerDebug: true,
|
||||||
};
|
};
|
||||||
const buildParameter2 = await CreateParameters(overrides);
|
const buildParameter2 = await CreateParameters(overrides);
|
||||||
const baseImage2 = new ImageTag(buildParameter2);
|
const baseImage2 = new ImageTag(buildParameter2);
|
||||||
|
|
|
@ -4,7 +4,6 @@ import UnityVersioning from '../../unity-versioning';
|
||||||
import { Cli } from '../../cli/cli';
|
import { Cli } from '../../cli/cli';
|
||||||
import CloudRunnerLogger from '../services/core/cloud-runner-logger';
|
import CloudRunnerLogger from '../services/core/cloud-runner-logger';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import CloudRunnerOptions from '../options/cloud-runner-options';
|
|
||||||
import setups from './cloud-runner-suite.test';
|
import setups from './cloud-runner-suite.test';
|
||||||
import { CloudRunnerSystem } from '../services/core/cloud-runner-system';
|
import { CloudRunnerSystem } from '../services/core/cloud-runner-system';
|
||||||
import { OptionValues } from 'commander';
|
import { OptionValues } from 'commander';
|
||||||
|
@ -19,40 +18,70 @@ async function CreateParameters(overrides: OptionValues | undefined) {
|
||||||
|
|
||||||
describe('Cloud Runner pre-built S3 steps', () => {
|
describe('Cloud Runner pre-built S3 steps', () => {
|
||||||
it('Responds', () => {});
|
it('Responds', () => {});
|
||||||
|
it('Simple test to check if file is loaded', () => {
|
||||||
|
expect(true).toBe(true);
|
||||||
|
});
|
||||||
setups();
|
setups();
|
||||||
if (CloudRunnerOptions.cloudRunnerDebug && CloudRunnerOptions.providerStrategy !== `local-docker`) {
|
(() => {
|
||||||
it('Run build and prebuilt s3 cache pull, cache push and upload build', async () => {
|
// Check if we're in a CI environment or if AWS CLI is available
|
||||||
const overrides = {
|
const isCI = process.env.GITHUB_ACTIONS === 'true';
|
||||||
versioning: 'None',
|
let awsAvailable = false;
|
||||||
projectPath: 'test-project',
|
|
||||||
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
|
||||||
targetPlatform: 'StandaloneLinux64',
|
|
||||||
cacheKey: `test-case-${uuidv4()}`,
|
|
||||||
containerHookFiles: `aws-s3-pull-cache,aws-s3-upload-cache,aws-s3-upload-build`,
|
|
||||||
};
|
|
||||||
const buildParameter2 = await CreateParameters(overrides);
|
|
||||||
const baseImage2 = new ImageTag(buildParameter2);
|
|
||||||
const results2Object = await CloudRunner.run(buildParameter2, baseImage2.toString());
|
|
||||||
const results2 = results2Object.BuildResults;
|
|
||||||
CloudRunnerLogger.log(`run 2 succeeded`);
|
|
||||||
|
|
||||||
// Look for multiple indicators of a successful build
|
if (!isCI) {
|
||||||
const buildIndicators = [
|
// Only check AWS CLI locally, skip the test if not available
|
||||||
'Build succeeded',
|
try {
|
||||||
'Build succeeded!',
|
// Use synchronous check for AWS CLI availability
|
||||||
'Build Succeeded',
|
const { execSync } = require('child_process');
|
||||||
'succeeded',
|
execSync('aws --version', { stdio: 'ignore' });
|
||||||
'Cloud Runner finished running standard build automation',
|
awsAvailable = true;
|
||||||
'Cloud runner job has finished successfully',
|
} catch {
|
||||||
];
|
awsAvailable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const buildWasSuccessful = buildIndicators.some((indicator) => results2.includes(indicator));
|
// Only run the test if we're in CI or AWS CLI is available
|
||||||
expect(buildWasSuccessful).toBeTruthy();
|
if (isCI || awsAvailable) {
|
||||||
|
it('Run build and prebuilt s3 cache pull, cache push and upload build', async () => {
|
||||||
|
const overrides = {
|
||||||
|
versioning: 'None',
|
||||||
|
projectPath: 'test-project',
|
||||||
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
|
containerHookFiles: `aws-s3-pull-cache,aws-s3-upload-cache,aws-s3-upload-build`,
|
||||||
|
cloudRunnerDebug: true,
|
||||||
|
};
|
||||||
|
const buildParameter2 = await CreateParameters(overrides);
|
||||||
|
const baseImage2 = new ImageTag(buildParameter2);
|
||||||
|
const results2Object = await CloudRunner.run(buildParameter2, baseImage2.toString());
|
||||||
|
const results2 = results2Object.BuildResults;
|
||||||
|
CloudRunnerLogger.log(`run 2 succeeded`);
|
||||||
|
|
||||||
const results = await CloudRunnerSystem.RunAndReadLines(
|
// Look for multiple indicators of a successful build
|
||||||
`aws s3 ls s3://${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/`,
|
const buildIndicators = [
|
||||||
);
|
'Build succeeded',
|
||||||
CloudRunnerLogger.log(results.join(`,`));
|
'Build succeeded!',
|
||||||
}, 1_000_000_000);
|
'Build Succeeded',
|
||||||
}
|
'succeeded',
|
||||||
|
'Cloud Runner finished running standard build automation',
|
||||||
|
'Cloud runner job has finished successfully',
|
||||||
|
];
|
||||||
|
|
||||||
|
const buildWasSuccessful = buildIndicators.some((indicator) => results2.includes(indicator));
|
||||||
|
expect(buildWasSuccessful).toBeTruthy();
|
||||||
|
|
||||||
|
// Only run S3 operations if we're in CI or AWS CLI is available
|
||||||
|
if (isCI || awsAvailable) {
|
||||||
|
const results = await CloudRunnerSystem.RunAndReadLines(
|
||||||
|
`aws s3 ls s3://${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/`,
|
||||||
|
);
|
||||||
|
CloudRunnerLogger.log(results.join(`,`));
|
||||||
|
}
|
||||||
|
}, 1_000_000_000);
|
||||||
|
} else {
|
||||||
|
it.skip('Run build and prebuilt s3 cache pull, cache push and upload build - AWS CLI not available locally', () => {
|
||||||
|
CloudRunnerLogger.log('AWS CLI not available locally, skipping S3 test');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,6 +31,7 @@ describe('Cloud Runner Caching', () => {
|
||||||
cacheKey: `test-case-${uuidv4()}`,
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
containerHookFiles: `debug-cache`,
|
containerHookFiles: `debug-cache`,
|
||||||
cloudRunnerBranch: `cloud-runner-develop`,
|
cloudRunnerBranch: `cloud-runner-develop`,
|
||||||
|
cloudRunnerDebug: true,
|
||||||
};
|
};
|
||||||
if (CloudRunnerOptions.providerStrategy === `k8s`) {
|
if (CloudRunnerOptions.providerStrategy === `k8s`) {
|
||||||
overrides.containerHookFiles += `,aws-s3-pull-cache,aws-s3-upload-cache`;
|
overrides.containerHookFiles += `,aws-s3-pull-cache,aws-s3-upload-cache`;
|
||||||
|
|
|
@ -24,6 +24,7 @@ describe('Cloud Runner Retain Workspace', () => {
|
||||||
targetPlatform: 'StandaloneLinux64',
|
targetPlatform: 'StandaloneLinux64',
|
||||||
cacheKey: `test-case-${uuidv4()}`,
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
maxRetainedWorkspaces: 1,
|
maxRetainedWorkspaces: 1,
|
||||||
|
cloudRunnerDebug: true,
|
||||||
};
|
};
|
||||||
const buildParameter = await CreateParameters(overrides);
|
const buildParameter = await CreateParameters(overrides);
|
||||||
expect(buildParameter.projectPath).toEqual(overrides.projectPath);
|
expect(buildParameter.projectPath).toEqual(overrides.projectPath);
|
||||||
|
|
|
@ -34,6 +34,7 @@ describe('Cloud Runner Kubernetes', () => {
|
||||||
cacheKey: `test-case-${uuidv4()}`,
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
providerStrategy: 'k8s',
|
providerStrategy: 'k8s',
|
||||||
buildPlatform: 'linux',
|
buildPlatform: 'linux',
|
||||||
|
cloudRunnerDebug: true,
|
||||||
};
|
};
|
||||||
const buildParameter = await CreateParameters(overrides);
|
const buildParameter = await CreateParameters(overrides);
|
||||||
expect(buildParameter.projectPath).toEqual(overrides.projectPath);
|
expect(buildParameter.projectPath).toEqual(overrides.projectPath);
|
||||||
|
|
Loading…
Reference in New Issue