pull/729/head
Frostebite 2025-08-28 06:48:50 +01:00
parent e9a60d4ec8
commit 0650d1de5c
10 changed files with 96 additions and 34 deletions

13
dist/index.js generated vendored
View File

@ -805,6 +805,10 @@ class CloudRunner {
case 'local-system':
CloudRunner.Provider = new local_1.default();
break;
case 'local':
default:
CloudRunner.Provider = new local_1.default();
break;
}
}
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));
class RemoteClientLogger {
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`);
}
static log(message) {
@ -4733,6 +4741,11 @@ class RemoteClientLogger {
}
static appendToFile(message) {
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`);
}
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -80,6 +80,10 @@ class CloudRunner {
case 'local-system':
CloudRunner.Provider = new LocalCloudRunner();
break;
case 'local':
default:
CloudRunner.Provider = new LocalCloudRunner();
break;
}
}

View File

@ -6,6 +6,11 @@ import CloudRunnerOptions from '../options/cloud-runner-options';
export class RemoteClientLogger {
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`);
}
@ -29,6 +34,12 @@ export class RemoteClientLogger {
public static appendToFile(message: string) {
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`);
}
}

View File

@ -43,6 +43,7 @@ describe('Cloud Runner Sync Environments', () => {
- name: '${testSecretName}'
value: '${testSecretValue}'
`,
cloudRunnerDebug: true,
});
const baseImage = new ImageTag(buildParameter);
if (baseImage.toString().includes('undefined')) {

View File

@ -94,6 +94,7 @@ commands: echo "test"`;
cacheKey: `test-case-${uuidv4()}`,
containerHookFiles: `my-test-step-pre-build,my-test-step-post-build`,
commandHookFiles: `my-test-hook-pre-build,my-test-hook-post-build`,
cloudRunnerDebug: true,
};
const buildParameter2 = await CreateParameters(overrides);
const baseImage2 = new ImageTag(buildParameter2);

View File

@ -4,7 +4,6 @@ import UnityVersioning from '../../unity-versioning';
import { Cli } from '../../cli/cli';
import CloudRunnerLogger from '../services/core/cloud-runner-logger';
import { v4 as uuidv4 } from 'uuid';
import CloudRunnerOptions from '../options/cloud-runner-options';
import setups from './cloud-runner-suite.test';
import { CloudRunnerSystem } from '../services/core/cloud-runner-system';
import { OptionValues } from 'commander';
@ -19,8 +18,29 @@ async function CreateParameters(overrides: OptionValues | undefined) {
describe('Cloud Runner pre-built S3 steps', () => {
it('Responds', () => {});
it('Simple test to check if file is loaded', () => {
expect(true).toBe(true);
});
setups();
if (CloudRunnerOptions.cloudRunnerDebug && CloudRunnerOptions.providerStrategy !== `local-docker`) {
(() => {
// Check if we're in a CI environment or if AWS CLI is available
const isCI = process.env.GITHUB_ACTIONS === 'true';
let awsAvailable = false;
if (!isCI) {
// Only check AWS CLI locally, skip the test if not available
try {
// Use synchronous check for AWS CLI availability
const { execSync } = require('child_process');
execSync('aws --version', { stdio: 'ignore' });
awsAvailable = true;
} catch {
awsAvailable = false;
}
}
// Only run the test if we're in CI or AWS CLI is available
if (isCI || awsAvailable) {
it('Run build and prebuilt s3 cache pull, cache push and upload build', async () => {
const overrides = {
versioning: 'None',
@ -29,6 +49,7 @@ describe('Cloud Runner pre-built S3 steps', () => {
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);
@ -49,10 +70,18 @@ describe('Cloud Runner pre-built S3 steps', () => {
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);
}
}, 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');
});
}
})();
});

View File

@ -31,6 +31,7 @@ describe('Cloud Runner Caching', () => {
cacheKey: `test-case-${uuidv4()}`,
containerHookFiles: `debug-cache`,
cloudRunnerBranch: `cloud-runner-develop`,
cloudRunnerDebug: true,
};
if (CloudRunnerOptions.providerStrategy === `k8s`) {
overrides.containerHookFiles += `,aws-s3-pull-cache,aws-s3-upload-cache`;

View File

@ -24,6 +24,7 @@ describe('Cloud Runner Retain Workspace', () => {
targetPlatform: 'StandaloneLinux64',
cacheKey: `test-case-${uuidv4()}`,
maxRetainedWorkspaces: 1,
cloudRunnerDebug: true,
};
const buildParameter = await CreateParameters(overrides);
expect(buildParameter.projectPath).toEqual(overrides.projectPath);

View File

@ -34,6 +34,7 @@ describe('Cloud Runner Kubernetes', () => {
cacheKey: `test-case-${uuidv4()}`,
providerStrategy: 'k8s',
buildPlatform: 'linux',
cloudRunnerDebug: true,
};
const buildParameter = await CreateParameters(overrides);
expect(buildParameter.projectPath).toEqual(overrides.projectPath);