From 15f43f66896438c2e821f0fd81cba65b161efc8f Mon Sep 17 00:00:00 2001 From: Aaron Trudeau <36064197+trudeaua21@users.noreply.github.com> Date: Sun, 17 Oct 2021 22:40:32 -0400 Subject: [PATCH] add packageMode input --- action.yml | 4 ++++ src/index.js | 2 ++ src/model/docker.js | 2 ++ src/model/input.js | 8 ++++++++ 4 files changed, 16 insertions(+) diff --git a/action.yml b/action.yml index 99e17af..20680c3 100644 --- a/action.yml +++ b/action.yml @@ -40,6 +40,10 @@ inputs: required: false default: 'Test Results' description: 'Name for the check run that is created when a github token is provided.' + packageMode: + required: false + default: false + description: 'Whether the tests are being run for a Unity package. Not needed for packages located within a Unity Project' outputs: artifactsPath: description: 'Path where the artifacts are stored' diff --git a/src/index.js b/src/index.js index 66824c6..66ef360 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,7 @@ async function action() { sshAgent, githubToken, checkName, + packageMode, } = Input.getFromUser(); const baseImage = ImageTag.createForBase({ version: unityVersion, customImage }); @@ -33,6 +34,7 @@ async function action() { useHostNetwork, customParameters, sshAgent, + packageMode, githubToken, }); } finally { diff --git a/src/model/docker.js b/src/model/docker.js index 5621b57..b39ae58 100644 --- a/src/model/docker.js +++ b/src/model/docker.js @@ -27,6 +27,7 @@ class Docker { useHostNetwork, customParameters, sshAgent, + packageMode, githubToken, } = parameters; @@ -43,6 +44,7 @@ class Docker { --env TEST_MODE="${testMode}" \ --env ARTIFACTS_PATH="${artifactsPath}" \ --env CUSTOM_PARAMETERS="${customParameters}" \ + --env PACKAGE_MODE="${packageMode}" \ --env GITHUB_REF \ --env GITHUB_SHA \ --env GITHUB_REPOSITORY \ diff --git a/src/model/input.js b/src/model/input.js index 7e88809..cf4e558 100644 --- a/src/model/input.js +++ b/src/model/input.js @@ -25,6 +25,7 @@ class Input { const sshAgent = getInput('sshAgent') || ''; const githubToken = getInput('githubToken') || ''; const checkName = getInput('checkName') || 'Test Results'; + const rawPackageMode = getInput('packageMode') || 'false'; // Validate input if (!includes(this.testModes, testMode)) { @@ -43,12 +44,18 @@ class Input { throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`); } + if(rawPackageMode !== 'true' && rawPackageMode !== 'false') { + throw new Error(`Invalid packageMode "${rawPackageMode}"`); + } + // Sanitise input const projectPath = rawProjectPath.replace(/\/$/, ''); const artifactsPath = rawArtifactsPath.replace(/\/$/, ''); const useHostNetwork = rawUseHostNetwork === 'true'; const unityVersion = rawUnityVersion === 'auto' ? UnityVersionParser.read(projectPath) : rawUnityVersion; + const packageMode = rawPackageMode === 'true'; + // Return sanitised input return { @@ -62,6 +69,7 @@ class Input { sshAgent, githubToken, checkName, + packageMode, }; } }