Add intial framework for macos builds. Test install editor

pull/326/head
Andrew Kahr 2022-01-25 20:59:41 -08:00
parent 4e38a84fe7
commit 72384041a8
12 changed files with 140519 additions and 17 deletions

140432
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,8 @@
"base-64": "^1.0.0",
"kubernetes-client": "^9.0.0",
"nanoid": "^3.1.31",
"semver": "^7.3.5"
"semver": "^7.3.5",
"unity-changeset": "^1.6.0"
},
"devDependencies": {
"@types/jest": "^26.0.15",

View File

@ -1,5 +1,6 @@
import * as core from '@actions/core';
import { Action, BuildParameters, Cache, Docker, ImageTag, Kubernetes, Output, RemoteBuilder } from './model';
import MacBuilder from './model/mac-builder';
import PlatformSetup from './model/platform-setup';
async function run() {
@ -28,8 +29,12 @@ async function run() {
default:
core.info('Building locally');
PlatformSetup.setup(buildParameters);
builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(builtImage, { workspace, ...buildParameters });
if (process.platform === 'darwin') {
MacBuilder.run(actionFolder, workspace, buildParameters);
} else {
builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(builtImage, { workspace, ...buildParameters });
}
break;
}

View File

@ -1,4 +1,4 @@
/* eslint-disable unicorn/prevent-abbreviations */
/* eslint unicorn/prevent-abbreviations: "off" */
// Import these named export into your test file:
export const mockProjectPath = jest.fn().mockResolvedValue('mockProjectPath');

View File

@ -4,11 +4,15 @@ import Action from './action';
describe('Action', () => {
describe('compatibility check', () => {
it('throws for anything other than linux or windows', () => {
if (process.platform !== 'linux' && process.platform !== 'win32') {
expect(() => Action.checkCompatibility()).toThrow();
} else {
expect(() => Action.checkCompatibility()).not.toThrow();
it('throws for anything other than linux, windows, or mac', () => {
switch (process.platform) {
case 'linux':
case 'win32':
case 'darwin':
expect(() => Action.checkCompatibility()).not.toThrow();
break;
default:
expect(() => Action.checkCompatibility()).toThrow();
}
});
});

View File

@ -2,7 +2,7 @@ import path from 'path';
class Action {
static get supportedPlatforms() {
return ['linux', 'win32'];
return ['linux', 'win32', 'darwin'];
}
static get isRunningLocally() {
@ -36,6 +36,8 @@ class Action {
return `${Action.actionFolder}/platforms/ubuntu/Dockerfile`;
case 'win32':
return `${Action.actionFolder}/platforms/windows/Dockerfile`;
case 'darwin':
return 'unused'; //Mac doesn't use a container
default:
throw new Error(`No Dockerfile for currently unsupported platform: ${currentPlatform}`);
}

View File

@ -0,0 +1,12 @@
import { BuildParameters } from '.';
class MacBuilder {
public static async run(actionFolder, workspace, buildParameters: BuildParameters) {
//make linter happy
if (actionFolder !== undefined && workspace !== undefined && buildParameters !== undefined) {
return;
}
}
}
export default MacBuilder;

View File

@ -1,5 +1,5 @@
import { BuildParameters } from '.';
import SetupWindows from './platform-setup/setup-windows';
import { SetupWindows, SetupMac } from './platform-setup/';
import ValidateWindows from './platform-validation/validate-windows';
class PlatformSetup {
@ -9,6 +9,9 @@ class PlatformSetup {
ValidateWindows.validate(buildParameters);
SetupWindows.setup(buildParameters);
break;
case 'darwin':
SetupMac.setup(buildParameters);
break;
//Add other baseOS's here
}
}

View File

@ -0,0 +1,4 @@
import SetupWindows from './setup-windows';
import SetupMac from './setup-mac';
export { SetupWindows, SetupMac };

View File

@ -0,0 +1,35 @@
import { exec } from '@actions/exec';
import fs from 'fs';
import { BuildParameters } from '..';
import { getUnityChangeset } from 'unity-changeset';
class SetupMac {
static unityHubPath = '/Applications/Unity\\ Hub.app/Contents/MacOS/Unity\\ Hub';
public static async setup(buildParameters: BuildParameters) {
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.version}/Unity.app/Contents/MacOS/Unity`;
if (!fs.existsSync(unityEditorPath)) {
await SetupMac.installUnityHub();
await SetupMac.installUnity(buildParameters);
}
}
private static async installUnityHub(silent = false) {
const command = 'brew install unity-hub';
if (!fs.existsSync(this.unityHubPath)) {
await exec(command, undefined, { silent });
}
}
private static async installUnity(buildParameters: BuildParameters, silent = false) {
const changeset = await getUnityChangeset(buildParameters.version).changeset;
const command = `${this.unityHubPath} -- --headless install
--version ${buildParameters.version}
--changeset ${changeset}
--module mac-il2cpp
--childModules`;
await exec(command, undefined, { silent });
}
}
export default SetupMac;

View File

@ -1464,6 +1464,11 @@ buffer@4.9.2:
ieee754 "^1.1.4"
isarray "^1.0.0"
cac@^6.6.1:
version "6.7.12"
resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.12.tgz#6fb5ea2ff50bd01490dbda497f4ae75a99415193"
integrity sha512-rM7E2ygtMkJqD9c7WnFU6fruFcN3xe4FM5yUmgxhZzIKJk4uHl9U/fhwdajGFQbQuv43FAUo1Fe8gX/oIKDeSA==
cache-base@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz"
@ -5539,6 +5544,15 @@ union-value@^1.0.0:
is-extendable "^0.1.1"
set-value "^2.0.1"
unity-changeset@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/unity-changeset/-/unity-changeset-1.6.0.tgz#b2a3cab1350b10669cb53341ce562f3b93f38ddf"
integrity sha512-ke90Zhr2C5q2SPvinDKTr1dwgAPI0R6kxcO7gHPgQXntbx/Ag8hR0xLwd9K6UR2ykGFmDnUVjdbWfYlkhX8tFQ==
dependencies:
cac "^6.6.1"
jsdom "^16.4.0"
node-fetch "^2.6.1"
universal-user-agent@^4.0.0:
version "4.0.1"
resolved "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz"