Adding useHostNetwork option

pull/63/head
Collin Dauphinee 2020-04-01 13:24:13 -07:00 committed by Webber Takken
parent f02586c1c9
commit a4e8475a2f
5 changed files with 24 additions and 1 deletions

View File

@ -231,6 +231,18 @@ In this folder a folder will be created for every test mode.
_**required:** `false`_ _**required:** `false`_
_**default:** `artifacts`_ _**default:** `artifacts`_
#### useHostNetwork
Initializes Docker using the host network.
This is useful if Unity needs to access a local server that was started as part of your workflow.
Options are: "true", "false"
_**required:** `false`_
_**default:** `false`_
#### customParameters #### customParameters
Custom parameters to configure the test runner. Custom parameters to configure the test runner.

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,7 @@ async function action() {
projectPath, projectPath,
testMode, testMode,
artifactsPath, artifactsPath,
useHostNetwork,
customParameters, customParameters,
} = Input.getFromUser(); } = Input.getFromUser();
const baseImage = ImageTag.createForBase(unityVersion); const baseImage = ImageTag.createForBase(unityVersion);
@ -24,6 +25,7 @@ async function action() {
projectPath, projectPath,
testMode, testMode,
artifactsPath, artifactsPath,
useHostNetwork,
customParameters, customParameters,
}); });

View File

@ -24,6 +24,7 @@ class Docker {
projectPath, projectPath,
testMode, testMode,
artifactsPath, artifactsPath,
useHostNetwork,
customParameters, customParameters,
} = parameters; } = parameters;
@ -60,6 +61,7 @@ class Docker {
--volume "/home/runner/work/_temp/_github_home":"/github/home" \ --volume "/home/runner/work/_temp/_github_home":"/github/home" \
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \ --volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
--volume "${workspace}":"/github/workspace" \ --volume "${workspace}":"/github/workspace" \
${useHostNetwork ? '--net=host' : ''} \
${image}`; ${image}`;
await exec(command, null, { silent }); await exec(command, null, { silent });

View File

@ -18,6 +18,7 @@ class Input {
const testMode = getInput('testMode') || 'all'; const testMode = getInput('testMode') || 'all';
const rawProjectPath = getInput('projectPath') || '.'; const rawProjectPath = getInput('projectPath') || '.';
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts'; const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
const customParameters = getInput('customParameters') || ''; const customParameters = getInput('customParameters') || '';
// Validate input // Validate input
@ -33,9 +34,14 @@ class Input {
throw new Error(`Invalid projectPath "${rawProjectPath}"`); throw new Error(`Invalid projectPath "${rawProjectPath}"`);
} }
if (rawUseHostNetwork !== 'true' && rawUseHostNetwork !== 'false') {
throw new Error(`Invalid useHostNetwork "${rawUseHostNetwork}"`);
}
// Sanitise input // Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, ''); const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, ''); const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true';
// Return sanitised input // Return sanitised input
return { return {
@ -43,6 +49,7 @@ class Input {
projectPath, projectPath,
testMode, testMode,
artifactsPath, artifactsPath,
useHostNetwork,
customParameters, customParameters,
}; };
} }