chore: debug build process for windows
parent
16c49480b5
commit
0379bceff3
|
|
@ -1,9 +1,8 @@
|
||||||
import { exec, OutputMode } from 'https://deno.land/x/exec@0.0.5/mod.ts';
|
import { exec, OutputMode } from 'https://deno.land/x/exec@0.0.5/mod.ts';
|
||||||
import { CommandInterface } from '../command-interface.ts';
|
import { CommandInterface } from '../command-interface.ts';
|
||||||
import { Options } from '../../../config/options.ts';
|
import { Options } from '../../../config/options.ts';
|
||||||
import { Action, Cache, CloudRunner, Docker, ImageTag, Input, Output } from '../../../model/index.ts';
|
import { Action, Cache, Docker, ImageTag, Input, Output } from '../../../model/index.ts';
|
||||||
import PlatformSetup from '../../../model/platform-setup.ts';
|
import PlatformSetup from '../../../model/platform-setup.ts';
|
||||||
import { core, process } from '../../../dependencies.ts';
|
|
||||||
import MacBuilder from '../../../model/mac-builder.ts';
|
import MacBuilder from '../../../model/mac-builder.ts';
|
||||||
import Parameters from '../../../model/parameters.ts';
|
import Parameters from '../../../model/parameters.ts';
|
||||||
|
|
||||||
|
|
@ -19,31 +18,28 @@ export class BuildCommand implements CommandInterface {
|
||||||
public async execute(options: Options): Promise<boolean> {
|
public async execute(options: Options): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const { workspace, actionFolder } = Action;
|
const { workspace, actionFolder } = Action;
|
||||||
const { buildParameters } = options;
|
const { parameters, env } = options;
|
||||||
|
|
||||||
Action.checkCompatibility();
|
Action.checkCompatibility();
|
||||||
Cache.verify();
|
Cache.verify();
|
||||||
|
|
||||||
const baseImage = new ImageTag(buildParameters);
|
const baseImage = new ImageTag(parameters);
|
||||||
log.debug('baseImage', baseImage);
|
log.debug('baseImage', baseImage);
|
||||||
|
|
||||||
if (buildParameters.cloudRunnerCluster !== 'local') {
|
await PlatformSetup.setup(parameters, actionFolder);
|
||||||
await CloudRunner.run(buildParameters, baseImage.toString());
|
log.info('Platform setup done.');
|
||||||
|
log.info('OS:', env.getOS());
|
||||||
|
if (env.getOS() === 'darwin') {
|
||||||
|
MacBuilder.run(actionFolder, workspace, parameters);
|
||||||
} else {
|
} else {
|
||||||
log.info('Building locally');
|
await Docker.run(baseImage, { workspace, actionFolder, ...parameters });
|
||||||
await PlatformSetup.setup(buildParameters, actionFolder);
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
MacBuilder.run(actionFolder, workspace, buildParameters);
|
|
||||||
} else {
|
|
||||||
await Docker.run(baseImage, { workspace, actionFolder, ...buildParameters });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set output
|
// Set output
|
||||||
await Output.setBuildVersion(buildParameters.buildVersion);
|
await Output.setBuildVersion(parameters.buildVersion);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
core.setFailed((error as Error).message);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await exec('docker run -it unityci/editor:2020.3.15f2-base-1 /bin/bash -c "echo test"', {
|
const result = await exec('docker run -it unityci/editor:2020.3.15f2-base-1 /bin/bash -c "echo test"', {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ export class BuildRemoteCommand implements CommandInterface {
|
||||||
return status.success;
|
return status.success;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
core.setFailed((error as Error).message);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { configureLogger, Verbosity } from './core/logger/index.ts';
|
import './dependencies.ts';
|
||||||
|
import { configureLogger } from './core/logger/index.ts';
|
||||||
import { Options } from './config/options.ts';
|
import { Options } from './config/options.ts';
|
||||||
import { CommandFactory } from './commands/command-factory.ts';
|
import { CommandFactory } from './commands/command-factory.ts';
|
||||||
import { ArgumentsParser } from './core/cli/arguments-parser.ts';
|
import { ArgumentsParser } from './core/cli/arguments-parser.ts';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Parameters } from '../index.ts';
|
import { Parameters } from '../../../model/index.ts';
|
||||||
import { fsSync as fs, exec, getUnityChangeSet } from '../../dependencies.ts';
|
import { fsSync as fs, exec, getUnityChangeSet } from '../../../dependencies.ts';
|
||||||
|
|
||||||
class SetupMac {
|
class SetupMac {
|
||||||
static unityHubPath = `"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"`;
|
static unityHubPath = `"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"`;
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { fsSync as fs, exec } from '../../dependencies.ts';
|
import { fsSync as fs, exec } from '../../../dependencies.ts';
|
||||||
import { Parameters } from '../index.ts';
|
import { Parameters } from '../../../model/index.ts';
|
||||||
|
|
||||||
class SetupWindows {
|
class SetupWindows {
|
||||||
public static async setup(buildParameters: Parameters) {
|
public static async setup(buildParameters: Parameters) {
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
import { fsSync as fs } from '../../dependencies.ts';
|
import { fsSync as fs } from '../../../dependencies.ts';
|
||||||
import { Parameters } from '../index.ts';
|
import { Parameters } from '../../../model/index.ts';
|
||||||
|
|
||||||
class ValidateWindows {
|
class ValidateWindows {
|
||||||
public static validate(buildParameters: Parameters) {
|
public static validate(buildParameters: Parameters) {
|
||||||
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform);
|
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform);
|
||||||
if (!(Deno.env.get('UNITY_EMAIL') && Deno.env.get('UNITY_PASSWORD'))) {
|
if (!(Deno.env.get('UNITY_EMAIL') && Deno.env.get('UNITY_PASSWORD'))) {
|
||||||
throw new Error(`Unity email and password must be set for Windows based builds to
|
throw new Error(String.dedent`
|
||||||
authenticate the license. Make sure to set them inside UNITY_EMAIL
|
Unity email and password must be set for Windows based builds to authenticate the license.
|
||||||
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
|
|
||||||
|
Make sure to set them inside UNITY_EMAIL and UNITY_PASSWORD in Github Secrets and pass them into the environment.
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,9 +37,11 @@ class ValidateWindows {
|
||||||
// Check for Windows 10 SDK on runner
|
// Check for Windows 10 SDK on runner
|
||||||
const windows10SDKPathExists = fs.existsSync('C:/Program Files (x86)/Windows Kits');
|
const windows10SDKPathExists = fs.existsSync('C:/Program Files (x86)/Windows Kits');
|
||||||
if (!windows10SDKPathExists) {
|
if (!windows10SDKPathExists) {
|
||||||
throw new Error(`Windows 10 SDK not found in default location. Make sure
|
throw new Error(String.dedent`
|
||||||
the runner has a Windows 10 SDK installed in the default
|
Windows 10 SDK not found in default location. Make sure this machine has a Windows 10 SDK installed.
|
||||||
location.`);
|
|
||||||
|
Download here: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,9 +51,13 @@ class ValidateWindows {
|
||||||
const visualStudioDataPathExists = fs.existsSync('C:/ProgramData/Microsoft/VisualStudio');
|
const visualStudioDataPathExists = fs.existsSync('C:/ProgramData/Microsoft/VisualStudio');
|
||||||
|
|
||||||
if (!visualStudioInstallPathExists || !visualStudioDataPathExists) {
|
if (!visualStudioInstallPathExists || !visualStudioDataPathExists) {
|
||||||
throw new Error(`Visual Studio not found at the default location.
|
throw new Error(String.dedent`
|
||||||
Make sure the runner has Visual Studio installed in the
|
Visual Studio not found at the default location.
|
||||||
default location`);
|
|
||||||
|
Make sure the runner has Visual Studio installed in the default location
|
||||||
|
|
||||||
|
Download here: https://visualstudio.microsoft.com/downloads/
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,12 +5,15 @@ import CloudRunner from '../cloud-runner.ts';
|
||||||
export class CloudRunnerError {
|
export class CloudRunnerError {
|
||||||
public static async handleException(error: unknown) {
|
public static async handleException(error: unknown) {
|
||||||
CloudRunnerLogger.error(JSON.stringify(error, undefined, 4));
|
CloudRunnerLogger.error(JSON.stringify(error, undefined, 4));
|
||||||
core.setFailed('Cloud Runner failed');
|
log.error('Cloud runner failed');
|
||||||
|
|
||||||
await CloudRunner.Provider.cleanup(
|
await CloudRunner.Provider.cleanup(
|
||||||
CloudRunner.buildParameters.buildGuid,
|
CloudRunner.buildParameters.buildGuid,
|
||||||
CloudRunner.buildParameters,
|
CloudRunner.buildParameters,
|
||||||
CloudRunner.buildParameters.branch,
|
CloudRunner.buildParameters.branch,
|
||||||
CloudRunner.defaultSecrets,
|
CloudRunner.defaultSecrets,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ class AWSTaskRunner {
|
||||||
const tasksDescription = await AWSTaskRunner.describeTasks(ECS, cluster, taskArn);
|
const tasksDescription = await AWSTaskRunner.describeTasks(ECS, cluster, taskArn);
|
||||||
CloudRunnerLogger.log(`Cloud runner job has ended ${tasksDescription.containers?.[0].lastStatus}`);
|
CloudRunnerLogger.log(`Cloud runner job has ended ${tasksDescription.containers?.[0].lastStatus}`);
|
||||||
|
|
||||||
core.setFailed(error);
|
|
||||||
log.error(error);
|
log.error(error);
|
||||||
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { exec } from '../../../dependencies.ts';
|
|
||||||
import { RemoteClientLogger } from '../remote-client/remote-client-logger.ts';
|
import { RemoteClientLogger } from '../remote-client/remote-client-logger.ts';
|
||||||
|
import { spawn } from 'https://deno.land/std@0.152.0/node/child_process.ts';
|
||||||
|
|
||||||
export class CloudRunnerSystem {
|
export class CloudRunnerSystem {
|
||||||
public static async Run(command: string, suppressError = false, suppressLogs = false) {
|
public static async Run(command: string, suppressError = false, suppressLogs = false) {
|
||||||
|
|
@ -11,7 +11,9 @@ export class CloudRunnerSystem {
|
||||||
|
|
||||||
return await new Promise<string>((promise, throwError) => {
|
return await new Promise<string>((promise, throwError) => {
|
||||||
let output = '';
|
let output = '';
|
||||||
const child = exec(command, (error, stdout, stderr) => {
|
|
||||||
|
// Todo - find Deno variant of child_process or rewrite this method to use execSync
|
||||||
|
const child = spawn(command, (error, stdout, stderr) => {
|
||||||
if (!suppressError && error) {
|
if (!suppressError && error) {
|
||||||
RemoteClientLogger.log(error.toString());
|
RemoteClientLogger.log(error.toString());
|
||||||
throwError(error);
|
throwError(error);
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ export class FollowLogStreamService {
|
||||||
core.setOutput('build-result', 'success');
|
core.setOutput('build-result', 'success');
|
||||||
} else if (message.includes('Build fail')) {
|
} else if (message.includes('Build fail')) {
|
||||||
core.setOutput('build-result', 'failed');
|
core.setOutput('build-result', 'failed');
|
||||||
core.setFailed('unity build failed');
|
log.error('build-result: failed');
|
||||||
log.error('BUILD FAILED!');
|
Deno.exit(1);
|
||||||
} else if (CloudRunner.buildParameters.cloudRunnerIntegrationTests && message.includes(': Listening for Jobs')) {
|
} else if (CloudRunner.buildParameters.cloudRunnerIntegrationTests && message.includes(': Listening for Jobs')) {
|
||||||
core.setOutput('cloud runner stop watching', 'true');
|
core.setOutput('cloud runner stop watching', 'true');
|
||||||
shouldReadLogs = false;
|
shouldReadLogs = false;
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,8 @@ class Input {
|
||||||
return this.getInput('awsBaseStackName') || 'game-ci';
|
return this.getInput('awsBaseStackName') || 'game-ci';
|
||||||
}
|
}
|
||||||
|
|
||||||
public get cloudRunnerCluster() {
|
// Todo - move to parameters
|
||||||
|
public static get cloudRunnerCluster() {
|
||||||
if (Cli.isCliMode) {
|
if (Cli.isCliMode) {
|
||||||
return this.getInput('cloudRunnerCluster') || 'aws';
|
return this.getInput('cloudRunnerCluster') || 'aws';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class Parameters {
|
||||||
);
|
);
|
||||||
log.debug('buildFile:', buildFile);
|
log.debug('buildFile:', buildFile);
|
||||||
const editorVersion = UnityVersioning.determineUnityVersion(this.input.projectPath, this.input.unityVersion);
|
const editorVersion = UnityVersioning.determineUnityVersion(this.input.projectPath, this.input.unityVersion);
|
||||||
log.debug('editorVersion:', editorVersion);
|
log.info('Detected editorVersion', editorVersion);
|
||||||
const buildVersion = await Versioning.determineBuildVersion(
|
const buildVersion = await Versioning.determineBuildVersion(
|
||||||
this.input.versioningStrategy,
|
this.input.versioningStrategy,
|
||||||
this.input.specifiedVersion,
|
this.input.specifiedVersion,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Parameters } from './index.ts';
|
import { Parameters } from './index.ts';
|
||||||
import { SetupMac, SetupWindows } from './platform-setup/index.ts';
|
import { SetupMac, SetupWindows } from '../logic/unity/platform-setup/index.ts';
|
||||||
import ValidateWindows from './platform-validation/validate-windows.ts';
|
import ValidateWindows from '../logic/unity/platform-validation/validate-windows.ts';
|
||||||
|
|
||||||
class PlatformSetup {
|
class PlatformSetup {
|
||||||
static async setup(buildParameters: Parameters, actionFolder: string) {
|
static async setup(buildParameters: Parameters, actionFolder: string) {
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,6 @@ export const core = {
|
||||||
console.error(error, error.stack);
|
console.error(error, error.stack);
|
||||||
},
|
},
|
||||||
|
|
||||||
setFailed: (failure) => {
|
|
||||||
console.error('setFailed:', failure);
|
|
||||||
Deno.exit(1);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Adapted from: https://github.com/actions/toolkit/blob/9b7bcb1567c9b7f134eb3c2d6bbf409a5106a956/packages/core/src/core.ts#L128
|
// Adapted from: https://github.com/actions/toolkit/blob/9b7bcb1567c9b7f134eb3c2d6bbf409a5106a956/packages/core/src/core.ts#L128
|
||||||
getInput: (name, options) => {
|
getInput: (name, options) => {
|
||||||
const variable = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
const variable = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue