mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-02-03 18:29:07 +08:00
Feature/add support for licensing server (#196)
* First take on adding support for sending in unity licensing server url on linux * Forgot to build dist * Moved services-config parsing to typescript * Need to set licensing server env variable for activate.sh * Forgot unused docker mount directory /resources
This commit is contained in:
@@ -20,6 +20,7 @@ export async function run() {
|
||||
githubToken,
|
||||
checkName,
|
||||
chownFilesTo,
|
||||
unityLicensingServer,
|
||||
} = Input.getFromUser();
|
||||
const baseImage = new ImageTag({ editorVersion, customImage });
|
||||
const runnerContext = Action.runnerContext();
|
||||
@@ -39,6 +40,7 @@ export async function run() {
|
||||
gitPrivateToken,
|
||||
githubToken,
|
||||
chownFilesTo,
|
||||
unityLicensingServer,
|
||||
...runnerContext,
|
||||
});
|
||||
} finally {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { existsSync, mkdirSync, readFileSync, rmSync } from 'fs';
|
||||
import LicensingServerSetup from './licensing-server-setup';
|
||||
import type { RunnerContext } from './action';
|
||||
import { exec } from '@actions/exec';
|
||||
import path from 'path';
|
||||
@@ -30,6 +31,11 @@ const Docker = {
|
||||
|
||||
async run(image, parameters, silent = false) {
|
||||
let runCommand = '';
|
||||
|
||||
if (parameters.unityLicensingServer !== '') {
|
||||
LicensingServerSetup.Setup(parameters.unityLicensingServer, parameters.actionFolder);
|
||||
}
|
||||
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
runCommand = this.getLinuxCommand(image, parameters);
|
||||
@@ -60,6 +66,7 @@ const Docker = {
|
||||
githubToken,
|
||||
runnerTemporaryPath,
|
||||
chownFilesTo,
|
||||
unityLicensingServer,
|
||||
} = parameters;
|
||||
|
||||
const githubHome = path.join(runnerTemporaryPath, '_github_home');
|
||||
@@ -80,6 +87,7 @@ const Docker = {
|
||||
--env UNITY_EMAIL \
|
||||
--env UNITY_PASSWORD \
|
||||
--env UNITY_SERIAL \
|
||||
--env UNITY_LICENSING_SERVER="${unityLicensingServer}" \
|
||||
--env UNITY_VERSION="${editorVersion}" \
|
||||
--env PROJECT_PATH="${projectPath}" \
|
||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||
@@ -110,6 +118,7 @@ const Docker = {
|
||||
--volume "${workspace}:/github/workspace:z" \
|
||||
--volume "${actionFolder}/steps:/steps:z" \
|
||||
--volume "${actionFolder}/entrypoint.sh:/entrypoint.sh:z" \
|
||||
--volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \
|
||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||
${
|
||||
sshAgent ? `--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro` : ''
|
||||
@@ -136,6 +145,7 @@ const Docker = {
|
||||
githubToken,
|
||||
runnerTemporaryPath,
|
||||
chownFilesTo,
|
||||
unityLicensingServer,
|
||||
} = parameters;
|
||||
|
||||
const githubHome = path.join(runnerTemporaryPath, '_github_home');
|
||||
@@ -156,6 +166,7 @@ const Docker = {
|
||||
--env UNITY_EMAIL \
|
||||
--env UNITY_PASSWORD \
|
||||
--env UNITY_SERIAL \
|
||||
--env UNITY_LICENSING_SERVER="${unityLicensingServer}" \
|
||||
--env UNITY_VERSION="${editorVersion}" \
|
||||
--env PROJECT_PATH="${projectPath}" \
|
||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||
|
||||
@@ -17,6 +17,7 @@ const Input = {
|
||||
const unityVersion = getInput('unityVersion') || 'auto';
|
||||
const customImage = getInput('customImage') || '';
|
||||
const rawProjectPath = getInput('projectPath') || '.';
|
||||
const unityLicensingServer = getInput('unityLicensingServer') || '';
|
||||
const customParameters = getInput('customParameters') || '';
|
||||
const testMode = (getInput('testMode') || 'all').toLowerCase();
|
||||
const coverageOptions = getInput('coverageOptions') || '';
|
||||
@@ -67,6 +68,7 @@ const Input = {
|
||||
githubToken,
|
||||
checkName,
|
||||
chownFilesTo,
|
||||
unityLicensingServer,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
20
src/model/licensing-server-setup.ts
Normal file
20
src/model/licensing-server-setup.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as core from '@actions/core';
|
||||
import fs from 'fs';
|
||||
|
||||
class LicensingServerSetup {
|
||||
public static Setup(unityLicensingServer, actionFolder: string) {
|
||||
const servicesConfigPath = `${actionFolder}/unity-config/services-config.json`;
|
||||
const servicesConfigPathTemplate = `${servicesConfigPath}.template`;
|
||||
if (!fs.existsSync(servicesConfigPathTemplate)) {
|
||||
core.error(`Missing services config ${servicesConfigPathTemplate}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString();
|
||||
servicesConfig = servicesConfig.replace('%URL%', unityLicensingServer);
|
||||
fs.writeFileSync(servicesConfigPath, servicesConfig);
|
||||
}
|
||||
}
|
||||
|
||||
export default LicensingServerSetup;
|
||||
Reference in New Issue
Block a user