mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-02-02 06:39:05 +08:00
Compare commits
2 Commits
v4.6.0
...
codex/crea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c6f03998d | ||
|
|
ebb637d57e |
@@ -194,6 +194,10 @@ inputs:
|
|||||||
description:
|
description:
|
||||||
'[CloudRunner] Either local, k8s or aws can be used to run builds on a remote cluster. Additional parameters must
|
'[CloudRunner] Either local, k8s or aws can be used to run builds on a remote cluster. Additional parameters must
|
||||||
be configured.'
|
be configured.'
|
||||||
|
providerPackage:
|
||||||
|
default: ''
|
||||||
|
required: false
|
||||||
|
description: '[CloudRunner] Override the provider package name used to load the provider'
|
||||||
containerCpu:
|
containerCpu:
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -56,23 +56,14 @@ namespace UnityBuilderAction
|
|||||||
// of either `UnityEditor.BuildPlayerOptions` or `UnityEditor.BuildPlayerWithProfileOptions`
|
// of either `UnityEditor.BuildPlayerOptions` or `UnityEditor.BuildPlayerWithProfileOptions`
|
||||||
dynamic buildPlayerOptions;
|
dynamic buildPlayerOptions;
|
||||||
|
|
||||||
if (options.TryGetValue("activeBuildProfile", out var buildProfilePath)) {
|
if (options["customBuildProfile"] != "") {
|
||||||
if (string.IsNullOrEmpty(buildProfilePath)) {
|
|
||||||
throw new Exception("`-activeBuildProfile` is set but with an empty value; this shouldn't happen");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_6000_0_OR_NEWER
|
#if UNITY_6000_0_OR_NEWER
|
||||||
// Load build profile from Assets folder
|
// Load build profile from Assets folder
|
||||||
var buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(buildProfilePath)
|
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]);
|
||||||
?? throw new Exception("Build profile file not found at path: " + buildProfilePath);
|
|
||||||
|
|
||||||
#if !BUILD_PROFILE_LOADED
|
// Set it as active
|
||||||
throw new Exception("Build profile's define symbol not present before script execution; shouldn't happen");
|
BuildProfile.SetActiveBuildProfile(buildProfile);
|
||||||
#endif // BUILD_PROFILE_LOADED
|
|
||||||
|
|
||||||
// no need to set active profile, as already set by `-activeBuildProfile` CLI argument
|
|
||||||
// BuildProfile.SetActiveBuildProfile(buildProfile);
|
|
||||||
Debug.Log($"build profile: {buildProfile.name}");
|
|
||||||
|
|
||||||
// Define BuildPlayerWithProfileOptions
|
// Define BuildPlayerWithProfileOptions
|
||||||
buildPlayerOptions = new BuildPlayerWithProfileOptions {
|
buildPlayerOptions = new BuildPlayerWithProfileOptions {
|
||||||
@@ -80,16 +71,12 @@ namespace UnityBuilderAction
|
|||||||
locationPathName = options["customBuildPath"],
|
locationPathName = options["customBuildPath"],
|
||||||
options = buildOptions,
|
options = buildOptions,
|
||||||
};
|
};
|
||||||
#else // UNITY_6000_0_OR_NEWER
|
#else
|
||||||
throw new Exception("Build profiles are not supported by this version of Unity (" + Application.unityVersion +")");
|
throw new Exception("Build profiles are not supported by this version of Unity (" + Application.unityVersion +")");
|
||||||
#endif // UNITY_6000_0_OR_NEWER
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
#if BUILD_PROFILE_LOADED
|
|
||||||
throw new Exception("Build profile's define symbol present; shouldn't happen");
|
|
||||||
#endif // BUILD_PROFILE_LOADED
|
|
||||||
|
|
||||||
// Gather values from project
|
// Gather values from project
|
||||||
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
||||||
|
|
||||||
|
|||||||
@@ -21,19 +21,6 @@ namespace UnityBuilderAction.Input
|
|||||||
EditorApplication.Exit(110);
|
EditorApplication.Exit(110);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_6000_0_OR_NEWER
|
|
||||||
var buildProfileSupport = true;
|
|
||||||
#else
|
|
||||||
var buildProfileSupport = false;
|
|
||||||
#endif // UNITY_6000_0_OR_NEWER
|
|
||||||
|
|
||||||
string buildProfile;
|
|
||||||
if (buildProfileSupport && validatedOptions.TryGetValue("activeBuildProfile", out buildProfile)) {
|
|
||||||
if (validatedOptions.ContainsKey("buildTarget")) {
|
|
||||||
Console.WriteLine("Extra argument -buildTarget");
|
|
||||||
EditorApplication.Exit(122);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
string buildTarget;
|
string buildTarget;
|
||||||
if (!validatedOptions.TryGetValue("buildTarget", out buildTarget)) {
|
if (!validatedOptions.TryGetValue("buildTarget", out buildTarget)) {
|
||||||
Console.WriteLine("Missing argument -buildTarget");
|
Console.WriteLine("Missing argument -buildTarget");
|
||||||
@@ -44,7 +31,6 @@ namespace UnityBuilderAction.Input
|
|||||||
Console.WriteLine(buildTarget + " is not a defined " + typeof(BuildTarget).Name);
|
Console.WriteLine(buildTarget + " is not a defined " + typeof(BuildTarget).Name);
|
||||||
EditorApplication.Exit(121);
|
EditorApplication.Exit(121);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
string customBuildPath;
|
string customBuildPath;
|
||||||
if (!validatedOptions.TryGetValue("customBuildPath", out customBuildPath)) {
|
if (!validatedOptions.TryGetValue("customBuildPath", out customBuildPath)) {
|
||||||
|
|||||||
85
dist/index.js
generated
vendored
85
dist/index.js
generated
vendored
@@ -327,6 +327,7 @@ class BuildParameters {
|
|||||||
containerRegistryRepository: input_1.default.containerRegistryRepository,
|
containerRegistryRepository: input_1.default.containerRegistryRepository,
|
||||||
containerRegistryImageVersion: input_1.default.containerRegistryImageVersion,
|
containerRegistryImageVersion: input_1.default.containerRegistryImageVersion,
|
||||||
providerStrategy: cloud_runner_options_1.default.providerStrategy,
|
providerStrategy: cloud_runner_options_1.default.providerStrategy,
|
||||||
|
providerPackage: cloud_runner_options_1.default.providerPackage,
|
||||||
buildPlatform: cloud_runner_options_1.default.buildPlatform,
|
buildPlatform: cloud_runner_options_1.default.buildPlatform,
|
||||||
kubeConfig: cloud_runner_options_1.default.kubeConfig,
|
kubeConfig: cloud_runner_options_1.default.kubeConfig,
|
||||||
containerMemory: cloud_runner_options_1.default.containerMemory,
|
containerMemory: cloud_runner_options_1.default.containerMemory,
|
||||||
@@ -751,6 +752,7 @@ const core = __importStar(__nccwpck_require__(42186));
|
|||||||
const test_1 = __importDefault(__nccwpck_require__(63007));
|
const test_1 = __importDefault(__nccwpck_require__(63007));
|
||||||
const local_1 = __importDefault(__nccwpck_require__(66575));
|
const local_1 = __importDefault(__nccwpck_require__(66575));
|
||||||
const docker_1 = __importDefault(__nccwpck_require__(42802));
|
const docker_1 = __importDefault(__nccwpck_require__(42802));
|
||||||
|
const provider_loader_1 = __importDefault(__nccwpck_require__(45788));
|
||||||
const github_1 = __importDefault(__nccwpck_require__(83654));
|
const github_1 = __importDefault(__nccwpck_require__(83654));
|
||||||
const shared_workspace_locking_1 = __importDefault(__nccwpck_require__(71372));
|
const shared_workspace_locking_1 = __importDefault(__nccwpck_require__(71372));
|
||||||
const follow_log_stream_service_1 = __nccwpck_require__(40266);
|
const follow_log_stream_service_1 = __nccwpck_require__(40266);
|
||||||
@@ -769,7 +771,7 @@ class CloudRunner {
|
|||||||
if (CloudRunner.buildParameters.githubCheckId === ``) {
|
if (CloudRunner.buildParameters.githubCheckId === ``) {
|
||||||
CloudRunner.buildParameters.githubCheckId = await github_1.default.createGitHubCheck(CloudRunner.buildParameters.buildGuid);
|
CloudRunner.buildParameters.githubCheckId = await github_1.default.createGitHubCheck(CloudRunner.buildParameters.buildGuid);
|
||||||
}
|
}
|
||||||
CloudRunner.setupSelectedBuildPlatform();
|
await CloudRunner.setupSelectedBuildPlatform();
|
||||||
CloudRunner.defaultSecrets = task_parameter_serializer_1.TaskParameterSerializer.readDefaultSecrets();
|
CloudRunner.defaultSecrets = task_parameter_serializer_1.TaskParameterSerializer.readDefaultSecrets();
|
||||||
CloudRunner.cloudRunnerEnvironmentVariables =
|
CloudRunner.cloudRunnerEnvironmentVariables =
|
||||||
task_parameter_serializer_1.TaskParameterSerializer.createCloudRunnerEnvironmentVariables(buildParameters);
|
task_parameter_serializer_1.TaskParameterSerializer.createCloudRunnerEnvironmentVariables(buildParameters);
|
||||||
@@ -787,7 +789,7 @@ class CloudRunner {
|
|||||||
}
|
}
|
||||||
follow_log_stream_service_1.FollowLogStreamService.Reset();
|
follow_log_stream_service_1.FollowLogStreamService.Reset();
|
||||||
}
|
}
|
||||||
static setupSelectedBuildPlatform() {
|
static async setupSelectedBuildPlatform() {
|
||||||
cloud_runner_logger_1.default.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.providerStrategy}`);
|
cloud_runner_logger_1.default.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.providerStrategy}`);
|
||||||
switch (CloudRunner.buildParameters.providerStrategy) {
|
switch (CloudRunner.buildParameters.providerStrategy) {
|
||||||
case 'k8s':
|
case 'k8s':
|
||||||
@@ -805,6 +807,10 @@ class CloudRunner {
|
|||||||
case 'local-system':
|
case 'local-system':
|
||||||
CloudRunner.Provider = new local_1.default();
|
CloudRunner.Provider = new local_1.default();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (CloudRunner.buildParameters.providerStrategy !== 'local') {
|
||||||
|
CloudRunner.Provider = await (0, provider_loader_1.default)(CloudRunner.buildParameters.providerPackage, CloudRunner.buildParameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async run(buildParameters, baseImage) {
|
static async run(buildParameters, baseImage) {
|
||||||
@@ -1214,6 +1220,9 @@ class CloudRunnerOptions {
|
|||||||
}
|
}
|
||||||
return provider || 'local';
|
return provider || 'local';
|
||||||
}
|
}
|
||||||
|
static get providerPackage() {
|
||||||
|
return (CloudRunnerOptions.getInput('providerPackage') || `unity-builder-provider-${CloudRunnerOptions.providerStrategy}`);
|
||||||
|
}
|
||||||
static get containerCpu() {
|
static get containerCpu() {
|
||||||
return CloudRunnerOptions.getInput('containerCpu') || `1024`;
|
return CloudRunnerOptions.getInput('containerCpu') || `1024`;
|
||||||
}
|
}
|
||||||
@@ -4214,6 +4223,78 @@ class LocalCloudRunner {
|
|||||||
exports["default"] = LocalCloudRunner;
|
exports["default"] = LocalCloudRunner;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 45788:
|
||||||
|
/***/ (function(__unused_webpack_module, exports) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
/**
|
||||||
|
* Dynamically load a provider package by name.
|
||||||
|
* @param providerName Name of the provider package to load
|
||||||
|
* @param buildParameters Build parameters passed to the provider constructor
|
||||||
|
* @throws Error when the provider cannot be loaded or does not implement ProviderInterface
|
||||||
|
*/
|
||||||
|
async function loadProvider(providerName, buildParameters) {
|
||||||
|
let importedModule;
|
||||||
|
try {
|
||||||
|
importedModule = await Promise.resolve().then(() => __importStar(require(providerName)));
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
throw new Error(`Failed to load provider package '${providerName}': ${error.message}`);
|
||||||
|
}
|
||||||
|
const Provider = importedModule.default || importedModule;
|
||||||
|
let instance;
|
||||||
|
try {
|
||||||
|
instance = new Provider(buildParameters);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
throw new Error(`Failed to instantiate provider '${providerName}': ${error.message}`);
|
||||||
|
}
|
||||||
|
const requiredMethods = [
|
||||||
|
'cleanupWorkflow',
|
||||||
|
'setupWorkflow',
|
||||||
|
'runTaskInWorkflow',
|
||||||
|
'garbageCollect',
|
||||||
|
'listResources',
|
||||||
|
'listWorkflow',
|
||||||
|
'watchWorkflow',
|
||||||
|
];
|
||||||
|
for (const method of requiredMethods) {
|
||||||
|
if (typeof instance[method] !== 'function') {
|
||||||
|
throw new Error(`Provider package '${providerName}' does not implement ProviderInterface. Missing method '${method}'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
exports["default"] = loadProvider;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 63007:
|
/***/ 63007:
|
||||||
|
|||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3
dist/platforms/mac/steps/build.sh
vendored
3
dist/platforms/mac/steps/build.sh
vendored
@@ -153,11 +153,10 @@ echo ""
|
|||||||
-password "$UNITY_PASSWORD" \
|
-password "$UNITY_PASSWORD" \
|
||||||
-customBuildName "$BUILD_NAME" \
|
-customBuildName "$BUILD_NAME" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
$( [ -z "$BUILD_PROFILE" ] && echo "-buildTarget $BUILD_TARGET") \
|
-buildTarget "$BUILD_TARGET" \
|
||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-customBuildProfile "$BUILD_PROFILE" \
|
-customBuildProfile "$BUILD_PROFILE" \
|
||||||
${BUILD_PROFILE:+-activeBuildProfile} ${BUILD_PROFILE:+"$BUILD_PROFILE"} \
|
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
-buildVersion "$VERSION" \
|
-buildVersion "$VERSION" \
|
||||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||||
|
|||||||
3
dist/platforms/ubuntu/steps/build.sh
vendored
3
dist/platforms/ubuntu/steps/build.sh
vendored
@@ -125,11 +125,10 @@ unity-editor \
|
|||||||
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
|
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
|
||||||
-customBuildName "$BUILD_NAME" \
|
-customBuildName "$BUILD_NAME" \
|
||||||
-projectPath "$UNITY_PROJECT_PATH" \
|
-projectPath "$UNITY_PROJECT_PATH" \
|
||||||
$( [ -z "$BUILD_PROFILE" ] && echo "-buildTarget $BUILD_TARGET" ) \
|
-buildTarget "$BUILD_TARGET" \
|
||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-customBuildProfile "$BUILD_PROFILE" \
|
-customBuildProfile "$BUILD_PROFILE" \
|
||||||
${BUILD_PROFILE:+-activeBuildProfile} ${BUILD_PROFILE:+"$BUILD_PROFILE"} \
|
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
-buildVersion "$VERSION" \
|
-buildVersion "$VERSION" \
|
||||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||||
|
|||||||
8
dist/platforms/windows/build.ps1
vendored
8
dist/platforms/windows/build.ps1
vendored
@@ -166,6 +166,7 @@ $unityArgs = @(
|
|||||||
"-customBuildName", "`"$Env:BUILD_NAME`"",
|
"-customBuildName", "`"$Env:BUILD_NAME`"",
|
||||||
"-projectPath", "`"$Env:UNITY_PROJECT_PATH`"",
|
"-projectPath", "`"$Env:UNITY_PROJECT_PATH`"",
|
||||||
"-executeMethod", "`"$Env:BUILD_METHOD`"",
|
"-executeMethod", "`"$Env:BUILD_METHOD`"",
|
||||||
|
"-buildTarget", "`"$Env:BUILD_TARGET`"",
|
||||||
"-customBuildTarget", "`"$Env:BUILD_TARGET`"",
|
"-customBuildTarget", "`"$Env:BUILD_TARGET`"",
|
||||||
"-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"",
|
"-customBuildPath", "`"$Env:CUSTOM_BUILD_PATH`"",
|
||||||
"-customBuildProfile", "`"$Env:BUILD_PROFILE`"",
|
"-customBuildProfile", "`"$Env:BUILD_PROFILE`"",
|
||||||
@@ -180,13 +181,6 @@ $unityArgs = @(
|
|||||||
"-logfile", "-"
|
"-logfile", "-"
|
||||||
) + $customParametersArray
|
) + $customParametersArray
|
||||||
|
|
||||||
if (-not $Env:BUILD_PROFILE) {
|
|
||||||
$unityArgs += @("-buildTarget", $Env:BUILD_TARGET)
|
|
||||||
}
|
|
||||||
if ($Env:BUILD_PROFILE) {
|
|
||||||
$unityArgs += @("-activeBuildProfile", $Env:BUILD_PROFILE)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove null items as that will fail the Start-Process call
|
# Remove null items as that will fail the Start-Process call
|
||||||
$unityArgs = $unityArgs | Where-Object { $_ -ne $null }
|
$unityArgs = $unityArgs | Where-Object { $_ -ne $null }
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class BuildParameters {
|
|||||||
public sshAgent!: string;
|
public sshAgent!: string;
|
||||||
public sshPublicKeysDirectoryPath!: string;
|
public sshPublicKeysDirectoryPath!: string;
|
||||||
public providerStrategy!: string;
|
public providerStrategy!: string;
|
||||||
|
public providerPackage!: string;
|
||||||
public gitPrivateToken!: string;
|
public gitPrivateToken!: string;
|
||||||
public awsStackName!: string;
|
public awsStackName!: string;
|
||||||
public kubeConfig!: string;
|
public kubeConfig!: string;
|
||||||
@@ -183,6 +184,7 @@ class BuildParameters {
|
|||||||
containerRegistryRepository: Input.containerRegistryRepository,
|
containerRegistryRepository: Input.containerRegistryRepository,
|
||||||
containerRegistryImageVersion: Input.containerRegistryImageVersion,
|
containerRegistryImageVersion: Input.containerRegistryImageVersion,
|
||||||
providerStrategy: CloudRunnerOptions.providerStrategy,
|
providerStrategy: CloudRunnerOptions.providerStrategy,
|
||||||
|
providerPackage: CloudRunnerOptions.providerPackage,
|
||||||
buildPlatform: CloudRunnerOptions.buildPlatform,
|
buildPlatform: CloudRunnerOptions.buildPlatform,
|
||||||
kubeConfig: CloudRunnerOptions.kubeConfig,
|
kubeConfig: CloudRunnerOptions.kubeConfig,
|
||||||
containerMemory: CloudRunnerOptions.containerMemory,
|
containerMemory: CloudRunnerOptions.containerMemory,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import CloudRunnerEnvironmentVariable from './options/cloud-runner-environment-v
|
|||||||
import TestCloudRunner from './providers/test';
|
import TestCloudRunner from './providers/test';
|
||||||
import LocalCloudRunner from './providers/local';
|
import LocalCloudRunner from './providers/local';
|
||||||
import LocalDockerCloudRunner from './providers/docker';
|
import LocalDockerCloudRunner from './providers/docker';
|
||||||
|
import loadProvider from './providers/provider-loader';
|
||||||
import GitHub from '../github';
|
import GitHub from '../github';
|
||||||
import SharedWorkspaceLocking from './services/core/shared-workspace-locking';
|
import SharedWorkspaceLocking from './services/core/shared-workspace-locking';
|
||||||
import { FollowLogStreamService } from './services/core/follow-log-stream-service';
|
import { FollowLogStreamService } from './services/core/follow-log-stream-service';
|
||||||
@@ -38,7 +39,7 @@ class CloudRunner {
|
|||||||
if (CloudRunner.buildParameters.githubCheckId === ``) {
|
if (CloudRunner.buildParameters.githubCheckId === ``) {
|
||||||
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(CloudRunner.buildParameters.buildGuid);
|
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(CloudRunner.buildParameters.buildGuid);
|
||||||
}
|
}
|
||||||
CloudRunner.setupSelectedBuildPlatform();
|
await CloudRunner.setupSelectedBuildPlatform();
|
||||||
CloudRunner.defaultSecrets = TaskParameterSerializer.readDefaultSecrets();
|
CloudRunner.defaultSecrets = TaskParameterSerializer.readDefaultSecrets();
|
||||||
CloudRunner.cloudRunnerEnvironmentVariables =
|
CloudRunner.cloudRunnerEnvironmentVariables =
|
||||||
TaskParameterSerializer.createCloudRunnerEnvironmentVariables(buildParameters);
|
TaskParameterSerializer.createCloudRunnerEnvironmentVariables(buildParameters);
|
||||||
@@ -62,7 +63,7 @@ class CloudRunner {
|
|||||||
FollowLogStreamService.Reset();
|
FollowLogStreamService.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static setupSelectedBuildPlatform() {
|
private static async setupSelectedBuildPlatform() {
|
||||||
CloudRunnerLogger.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.providerStrategy}`);
|
CloudRunnerLogger.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.providerStrategy}`);
|
||||||
switch (CloudRunner.buildParameters.providerStrategy) {
|
switch (CloudRunner.buildParameters.providerStrategy) {
|
||||||
case 'k8s':
|
case 'k8s':
|
||||||
@@ -80,6 +81,13 @@ class CloudRunner {
|
|||||||
case 'local-system':
|
case 'local-system':
|
||||||
CloudRunner.Provider = new LocalCloudRunner();
|
CloudRunner.Provider = new LocalCloudRunner();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (CloudRunner.buildParameters.providerStrategy !== 'local') {
|
||||||
|
CloudRunner.Provider = await loadProvider(
|
||||||
|
CloudRunner.buildParameters.providerPackage,
|
||||||
|
CloudRunner.buildParameters,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,12 @@ class CloudRunnerOptions {
|
|||||||
return provider || 'local';
|
return provider || 'local';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get providerPackage(): string {
|
||||||
|
return (
|
||||||
|
CloudRunnerOptions.getInput('providerPackage') || `unity-builder-provider-${CloudRunnerOptions.providerStrategy}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static get containerCpu(): string {
|
static get containerCpu(): string {
|
||||||
return CloudRunnerOptions.getInput('containerCpu') || `1024`;
|
return CloudRunnerOptions.getInput('containerCpu') || `1024`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export default class InvalidProvider {}
|
||||||
19
src/model/cloud-runner/providers/provider-loader.test.ts
Normal file
19
src/model/cloud-runner/providers/provider-loader.test.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import loadProvider from './provider-loader';
|
||||||
|
import { ProviderInterface } from './provider-interface';
|
||||||
|
|
||||||
|
describe('provider-loader', () => {
|
||||||
|
it('loads a provider dynamically', async () => {
|
||||||
|
const provider: ProviderInterface = await loadProvider('./test', {} as any);
|
||||||
|
expect(typeof provider.runTaskInWorkflow).toBe('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws when provider package is missing', async () => {
|
||||||
|
await expect(loadProvider('non-existent-package', {} as any)).rejects.toThrow('non-existent-package');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws when provider does not implement ProviderInterface', async () => {
|
||||||
|
await expect(loadProvider('./fixtures/invalid-provider', {} as any)).rejects.toThrow(
|
||||||
|
'does not implement ProviderInterface',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
48
src/model/cloud-runner/providers/provider-loader.ts
Normal file
48
src/model/cloud-runner/providers/provider-loader.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { ProviderInterface } from './provider-interface';
|
||||||
|
import BuildParameters from '../../build-parameters';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically load a provider package by name.
|
||||||
|
* @param providerName Name of the provider package to load
|
||||||
|
* @param buildParameters Build parameters passed to the provider constructor
|
||||||
|
* @throws Error when the provider cannot be loaded or does not implement ProviderInterface
|
||||||
|
*/
|
||||||
|
export default async function loadProvider(
|
||||||
|
providerName: string,
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
): Promise<ProviderInterface> {
|
||||||
|
let importedModule: any;
|
||||||
|
try {
|
||||||
|
importedModule = await import(providerName);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to load provider package '${providerName}': ${(error as Error).message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Provider = importedModule.default || importedModule;
|
||||||
|
let instance: any;
|
||||||
|
try {
|
||||||
|
instance = new Provider(buildParameters);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Failed to instantiate provider '${providerName}': ${(error as Error).message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const requiredMethods = [
|
||||||
|
'cleanupWorkflow',
|
||||||
|
'setupWorkflow',
|
||||||
|
'runTaskInWorkflow',
|
||||||
|
'garbageCollect',
|
||||||
|
'listResources',
|
||||||
|
'listWorkflow',
|
||||||
|
'watchWorkflow',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const method of requiredMethods) {
|
||||||
|
if (typeof instance[method] !== 'function') {
|
||||||
|
throw new Error(
|
||||||
|
`Provider package '${providerName}' does not implement ProviderInterface. Missing method '${method}'.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance as ProviderInterface;
|
||||||
|
}
|
||||||
@@ -20,8 +20,7 @@ MonoBehaviour:
|
|||||||
rid: 200022742090383361
|
rid: 200022742090383361
|
||||||
m_OverrideGlobalSceneList: 0
|
m_OverrideGlobalSceneList: 0
|
||||||
m_Scenes: []
|
m_Scenes: []
|
||||||
m_ScriptingDefines:
|
m_ScriptingDefines: []
|
||||||
- BUILD_PROFILE_LOADED
|
|
||||||
m_PlayerSettingsYaml:
|
m_PlayerSettingsYaml:
|
||||||
m_Settings: []
|
m_Settings: []
|
||||||
references:
|
references:
|
||||||
|
|||||||
Reference in New Issue
Block a user