diff --git a/action.yml b/action.yml index 9db67e8b..d1a94a97 100644 --- a/action.yml +++ b/action.yml @@ -2,6 +2,10 @@ name: 'Unity - Builder' author: Webber Takken description: 'Build Unity projects for different platforms.' inputs: + targetPlatform: + required: true + default: '' + description: 'Platform that the build should target.' unityVersion: required: false default: 'auto' @@ -10,10 +14,6 @@ inputs: required: false default: '' description: 'Specific docker image that should be used for building the project' - targetPlatform: - required: false - default: '' - description: 'Platform that the build should target.' projectPath: required: false default: '' @@ -22,18 +22,6 @@ inputs: required: false default: '' description: 'Name of the build.' - postBuildSteps: - required: false - default: '' - description: 'run a post build job in yaml format with the keys image, secrets (name, value object array), command string' - preBuildSteps: - required: false - default: '' - description: 'Run a pre build job after the repository setup but before the build job (in yaml format with the keys image, secrets (name, value object array), command line string)' - customJob: - required: false - default: '' - description: 'Run a custom job instead of the standard build automation for cloud runner (in yaml format with the keys image, secrets (name, value object array), command line string)' buildsPath: required: false default: '' @@ -42,38 +30,10 @@ inputs: required: false default: '' description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.' - cloudRunnerCluster: - default: 'local' + customParameters: required: false - description: 'Either local, k8s or aws can be used to run builds on a remote cluster. Additional parameters must be configured.' - awsStackName: - default: 'game-ci' - required: false - description: 'The Cloud Formation stack name that must be setup before using this option.' - kubeConfig: default: '' - required: false - description: 'Supply a base64 encoded kubernetes config to run builds on kubernetes and stream logs until completion.' - kubeVolume: - default: '' - required: false - description: 'Supply a Persistent Volume Claim name to use for the Unity build.' - cloudRunnerMemory: - default: '750M' - required: false - description: 'Amount of memory to assign the remote build container' - cloudRunnerCpu: - default: '1.0' - required: false - description: 'Amount of CPU time to assign the remote build container' - kubeVolumeSize: - default: '5Gi' - required: false - description: 'Amount of disc space to assign the Kubernetes Persistent Volume' - githubToken: - default: '' - required: false - description: 'GitHub token for cloning, only needed when kubeconfig is used.' + description: 'Custom parameters to configure the build.' versioning: required: false default: 'Semantic' @@ -114,14 +74,6 @@ inputs: required: false default: '' description: 'The android target API level.' - customParameters: - required: false - default: '' - description: > - Custom parameters to configure the build. - - Parameters must start with a hyphen (-) and may be followed by a value (without hyphen). - Parameters without a value will be considered booleans (with a value of true). sshAgent: required: false default: '' @@ -129,8 +81,7 @@ inputs: gitPrivateToken: required: false default: '' - description: > - Github private token to pull from github + description: 'Github private token to pull from github' chownFilesTo: required: false default: '' @@ -138,12 +89,51 @@ inputs: allowDirtyBuild: required: false default: '' - description: > - Allows the branch of the build to be dirty, and still generate the build. - - Note that it is generally bad practice to modify your branch - in a CI Pipeline. However there are exceptions where this might - be needed. (use with care). + description: 'Allows the branch of the build to be dirty, and still generate the build.' + postBuildSteps: + required: false + default: '' + description: 'run a post build job in yaml format with the keys image, secrets (name, value object array), command string' + preBuildSteps: + required: false + default: '' + description: 'Run a pre build job after the repository setup but before the build job (in yaml format with the keys image, secrets (name, value object array), command line string)' + customJob: + required: false + default: '' + description: 'Run a custom job instead of the standard build automation for cloud runner (in yaml format with the keys image, secrets (name, value object array), command line string)' + awsBaseStackName: + default: 'game-ci' + required: false + description: 'The Cloud Formation stack name that must be setup before using this option.' + cloudRunnerCluster: + default: 'local' + required: false + description: 'Either local, k8s or aws can be used to run builds on a remote cluster. Additional parameters must be configured.' + cloudRunnerCpu: + default: '1.0' + required: false + description: 'Amount of CPU time to assign the remote build container' + cloudRunnerMemory: + default: '750M' + required: false + description: 'Amount of memory to assign the remote build container' + githubToken: + default: '' + required: false + description: 'GitHub token for cloning, only needed when kubeconfig is used.' + kubeConfig: + default: '' + required: false + description: 'Supply a base64 encoded kubernetes config to run builds on kubernetes and stream logs until completion.' + kubeVolume: + default: '' + required: false + description: 'Supply a Persistent Volume Claim name to use for the Unity build.' + kubeVolumeSize: + default: '5Gi' + required: false + description: 'Amount of disc space to assign the Kubernetes Persistent Volume' outputs: volume: description: 'The Persistent Volume (PV) where the build artifacts have been stored by Kubernetes' diff --git a/dist/index.js b/dist/index.js index fbbe3e0c..1c745567 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index f5d2d06e..8120b8ac 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/dist/xhr-sync-worker.js b/dist/xhr-sync-worker.js new file mode 100644 index 00000000..f6389cfd --- /dev/null +++ b/dist/xhr-sync-worker.js @@ -0,0 +1,60 @@ +"use strict"; +/* eslint-disable no-process-exit */ +const util = require("util"); +const { JSDOM } = require("../../../.."); +const { READY_STATES } = require("./xhr-utils"); +const idlUtils = require("../generated/utils"); +const tough = require("tough-cookie"); + +const dom = new JSDOM(); +const xhr = new dom.window.XMLHttpRequest(); +const xhrImpl = idlUtils.implForWrapper(xhr); + +const chunks = []; + +process.stdin.on("data", chunk => { + chunks.push(chunk); +}); + +process.stdin.on("end", () => { + const buffer = Buffer.concat(chunks); + + const flag = JSON.parse(buffer.toString()); + if (flag.body && flag.body.type === "Buffer" && flag.body.data) { + flag.body = Buffer.from(flag.body.data); + } + if (flag.cookieJar) { + flag.cookieJar = tough.CookieJar.fromJSON(flag.cookieJar); + } + + flag.synchronous = false; + Object.assign(xhrImpl.flag, flag); + const { properties } = xhrImpl; + xhrImpl.readyState = READY_STATES.OPENED; + try { + xhr.addEventListener("loadend", () => { + if (properties.error) { + properties.error = properties.error.stack || util.inspect(properties.error); + } + process.stdout.write(JSON.stringify({ + responseURL: xhrImpl.responseURL, + status: xhrImpl.status, + statusText: xhrImpl.statusText, + properties + }), () => { + process.exit(0); + }); + }, false); + xhr.send(flag.body); + } catch (error) { + properties.error += error.stack || util.inspect(error); + process.stdout.write(JSON.stringify({ + responseURL: xhrImpl.responseURL, + status: xhrImpl.status, + statusText: xhrImpl.statusText, + properties + }), () => { + process.exit(0); + }); + } +}); diff --git a/src/model/input.ts b/src/model/input.ts index 0150d46d..105c5e60 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -69,6 +69,10 @@ class Input { return Input.getInput('GITHUB_RUN_NUMBER') || '0'; } + static get targetPlatform() { + return Input.getInput('targetPlatform') || Platform.default; + } + static get unityVersion() { return Input.getInput('unityVersion') || 'auto'; } @@ -77,10 +81,6 @@ class Input { return Input.getInput('customImage'); } - static get targetPlatform() { - return Input.getInput('targetPlatform') || Platform.default; - } - static get projectPath() { const input = Input.getInput('projectPath'); const rawProjectPath = input @@ -104,6 +104,10 @@ class Input { return Input.getInput('buildMethod') || ''; // processed in docker file } + static get customParameters() { + return Input.getInput('customParameters') || ''; + } + static get versioningStrategy() { return Input.getInput('versioning') || 'Semantic'; } @@ -146,24 +150,10 @@ class Input { return core.getInput('androidTargetSdkVersion') || ''; } - static get allowDirtyBuild() { - const input = Input.getInput('allowDirtyBuild') || false; - - return input === 'true'; - } - - static get customParameters() { - return Input.getInput('customParameters') || ''; - } - static get sshAgent() { return Input.getInput('sshAgent') || ''; } - static async githubToken() { - return Input.getInput('githubToken') || (await GithubCliReader.GetGitHubAuthToken()) || ''; - } - static async gitPrivateToken() { return core.getInput('gitPrivateToken') || (await Input.githubToken()); } @@ -172,6 +162,12 @@ class Input { return Input.getInput('chownFilesTo') || ''; } + static get allowDirtyBuild() { + const input = Input.getInput('allowDirtyBuild') || false; + + return input === 'true'; + } + static get postBuildSteps() { return Input.getInput('postBuildSteps') || ''; } @@ -184,34 +180,38 @@ class Input { return Input.getInput('customJob') || ''; } - static get cloudRunnerCluster() { - return Input.getInput('cloudRunnerCluster') || ''; - } - static get awsBaseStackName() { return Input.getInput('awsBaseStackName') || 'game-ci'; } - static get kubeConfig() { - return Input.getInput('kubeConfig') || ''; - } - - static get cloudRunnerMemory() { - return Input.getInput('cloudRunnerMemory') || '750M'; + static get cloudRunnerCluster() { + return Input.getInput('cloudRunnerCluster') || 'local'; } static get cloudRunnerCpu() { return Input.getInput('cloudRunnerCpu') || '1.0'; } - static get kubeVolumeSize() { - return Input.getInput('kubeVolumeSize') || '5Gi'; + static get cloudRunnerMemory() { + return Input.getInput('cloudRunnerMemory') || '750M'; + } + + static async githubToken() { + return Input.getInput('githubToken') || (await GithubCliReader.GetGitHubAuthToken()) || ''; + } + + static get kubeConfig() { + return Input.getInput('kubeConfig') || ''; } static get kubeVolume() { return Input.getInput('kubeVolume') || ''; } + static get kubeVolumeSize() { + return Input.getInput('kubeVolumeSize') || '5Gi'; + } + public static ToEnvVarFormat(input: string) { return input .replace(/([A-Z])/g, ' $1')