refactor: route orchestrator through plugin loader

Replace 8 direct orchestrator service imports with a thin plugin loader.
- loadOrchestrator(): loads remote build orchestration
- loadEnterpriseServices(): loads enterprise features for local builds

All functionality is preserved; only the import mechanism changes.
This is the first step toward making orchestrator an optional dependency.

Includes comprehensive integration tests for enterprise feature wiring
that verify gating logic, call ordering, and provider strategy routing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
frostebite
2026-03-10 01:04:01 +00:00
parent 20b01e1325
commit d34f77c043
5 changed files with 401 additions and 147 deletions
Generated Vendored
+81 -41
View File
@@ -134,9 +134,10 @@ async function runMain() {
// Child workspace isolation - restore cached workspace before any other setup
let childWorkspaceConfig;
if (buildParameters.childWorkspacesEnabled && buildParameters.childWorkspaceName) {
const ChildWorkspaceService = await enterprise?.loadChildWorkspaceService();
const cacheRoot = buildParameters.childWorkspaceCacheRoot ||
node_path_1.default.join(buildParameters.runnerTempPath || process.env.RUNNER_TEMP || '', 'game-ci-workspaces');
childWorkspaceConfig = enterprise?.ChildWorkspaceService.buildConfig({
childWorkspaceConfig = ChildWorkspaceService?.buildConfig({
childWorkspacesEnabled: buildParameters.childWorkspacesEnabled,
childWorkspaceName: buildParameters.childWorkspaceName,
childWorkspaceCacheRoot: cacheRoot,
@@ -144,45 +145,51 @@ async function runMain() {
childWorkspaceSeparateLibrary: buildParameters.childWorkspaceSeparateLibrary,
});
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
const restored = enterprise?.ChildWorkspaceService.initializeWorkspace(projectFullPath, childWorkspaceConfig);
const restored = ChildWorkspaceService?.initializeWorkspace(projectFullPath, childWorkspaceConfig);
core.info(`Child workspace "${buildParameters.childWorkspaceName}": ${restored ? 'restored from cache' : 'starting fresh'}`);
// Log workspace size for resource tracking
const size = enterprise?.ChildWorkspaceService.getWorkspaceSize(projectFullPath);
const size = ChildWorkspaceService?.getWorkspaceSize(projectFullPath);
core.info(`Child workspace size after restore: ${size}`);
}
// Submodule profile initialization
if (buildParameters.submoduleProfilePath) {
core.info('Initializing submodules from profile...');
const plan = await enterprise?.SubmoduleProfileService.createInitPlan(buildParameters.submoduleProfilePath, buildParameters.submoduleVariantPath, workspace);
const SubmoduleProfileService = await enterprise?.loadSubmoduleProfileService();
const plan = await SubmoduleProfileService?.createInitPlan(buildParameters.submoduleProfilePath, buildParameters.submoduleVariantPath, workspace);
if (plan) {
await enterprise?.SubmoduleProfileService.execute(plan, workspace, buildParameters.submoduleToken || buildParameters.gitPrivateToken);
await SubmoduleProfileService?.execute(plan, workspace, buildParameters.submoduleToken || buildParameters.gitPrivateToken);
}
}
// Configure custom LFS transfer agent
if (buildParameters.lfsTransferAgent) {
core.info('Configuring custom LFS transfer agent...');
await enterprise?.LfsAgentService.configure(buildParameters.lfsTransferAgent, buildParameters.lfsTransferAgentArgs, buildParameters.lfsStoragePaths ? buildParameters.lfsStoragePaths.split(';') : [], workspace);
const LfsAgentService = await enterprise?.loadLfsAgentService();
await LfsAgentService?.configure(buildParameters.lfsTransferAgent, buildParameters.lfsTransferAgentArgs, buildParameters.lfsStoragePaths ? buildParameters.lfsStoragePaths.split(';') : [], workspace);
}
// Local build caching - restore
let cacheRoot = '';
let cacheKey = '';
// eslint-disable-next-line no-undef
let LocalCacheService;
if (buildParameters.localCacheEnabled) {
cacheRoot = enterprise?.LocalCacheService.resolveCacheRoot(buildParameters) || '';
LocalCacheService = await enterprise?.loadLocalCacheService();
cacheRoot = LocalCacheService?.resolveCacheRoot(buildParameters) || '';
cacheKey =
enterprise?.LocalCacheService.generateCacheKey(buildParameters.targetPlatform, buildParameters.editorVersion, buildParameters.branch || '') || '';
LocalCacheService?.generateCacheKey(buildParameters.targetPlatform, buildParameters.editorVersion, buildParameters.branch || '') || '';
if (buildParameters.localCacheLfs) {
await enterprise?.LocalCacheService.restoreLfsCache(workspace, cacheRoot, cacheKey);
await LocalCacheService?.restoreLfsCache(workspace, cacheRoot, cacheKey);
}
if (buildParameters.localCacheLibrary) {
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
await enterprise?.LocalCacheService.restoreLibraryCache(projectFullPath, cacheRoot, cacheKey);
await LocalCacheService?.restoreLibraryCache(projectFullPath, cacheRoot, cacheKey);
}
}
// Git hooks — opt-in only. When disabled (default), do not touch hooks at all.
if (buildParameters.gitHooksEnabled) {
await enterprise?.GitHooksService.installHooks(workspace);
const GitHooksService = await enterprise?.loadGitHooksService();
await GitHooksService?.installHooks(workspace);
if (buildParameters.gitHooksSkipList) {
const environment = enterprise?.GitHooksService.configureSkipList(buildParameters.gitHooksSkipList.split(','));
const environment = GitHooksService?.configureSkipList(buildParameters.gitHooksSkipList.split(','));
if (environment) {
Object.assign(process.env, environment);
}
@@ -204,21 +211,22 @@ async function runMain() {
...buildParameters,
});
// Local build caching - save
if (buildParameters.localCacheEnabled) {
if (buildParameters.localCacheEnabled && LocalCacheService) {
if (buildParameters.localCacheLibrary) {
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
await enterprise?.LocalCacheService.saveLibraryCache(projectFullPath, cacheRoot, cacheKey);
await LocalCacheService.saveLibraryCache(projectFullPath, cacheRoot, cacheKey);
}
if (buildParameters.localCacheLfs) {
await enterprise?.LocalCacheService.saveLfsCache(workspace, cacheRoot, cacheKey);
await LocalCacheService.saveLfsCache(workspace, cacheRoot, cacheKey);
}
}
// Child workspace isolation - save workspace for next run
if (childWorkspaceConfig && childWorkspaceConfig.enabled) {
const ChildWorkspaceService = await enterprise?.loadChildWorkspaceService();
const projectFullPath = node_path_1.default.join(workspace, buildParameters.projectPath);
const preSaveSize = enterprise?.ChildWorkspaceService.getWorkspaceSize(projectFullPath);
const preSaveSize = ChildWorkspaceService?.getWorkspaceSize(projectFullPath);
core.info(`Child workspace size before save: ${preSaveSize}`);
enterprise?.ChildWorkspaceService.saveWorkspace(projectFullPath, childWorkspaceConfig);
ChildWorkspaceService?.saveWorkspace(projectFullPath, childWorkspaceConfig);
core.info(`Child workspace "${buildParameters.childWorkspaceName}" saved to cache`);
}
// Revert overlays after job completion if configured
@@ -231,7 +239,6 @@ async function runMain() {
core.warning(`[Sync] Overlay revert failed: ${revertError.message}`);
}
}
exitCode = await runColdBuild(buildParameters, baseImage, workspace, actionFolder);
}
else {
const orchestrator = await (0, orchestrator_plugin_1.loadOrchestrator)();
@@ -2562,6 +2569,10 @@ exports["default"] = MacBuilder;
* After extraction, the orchestrator lives in @game-ci/orchestrator.
* This module provides a thin loader that dynamically imports it,
* falling back gracefully if the package is not installed.
*
* During the extraction transition period, this imports from the local
* source. Once extraction is complete, the import path changes to the
* npm package.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
@@ -2590,45 +2601,74 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.loadEnterpriseServices = exports.loadOrchestrator = void 0;
const core = __importStar(__nccwpck_require__(42186));
/**
* Attempt to load the orchestrator package.
* Returns undefined if @game-ci/orchestrator is not installed.
* Load the orchestrator for remote builds.
* Returns undefined if orchestrator is not available.
*/
async function loadOrchestrator() {
try {
// During extraction: use local source (will become package import)
// During extraction transition: import from local source
// After extraction: import from '@game-ci/orchestrator'
const { default: Orchestrator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(8330)));
return {
run: Orchestrator.run.bind(Orchestrator),
run: async (buildParameters, baseImage) => {
const result = await Orchestrator.run(buildParameters, baseImage);
return {
exitCode: result.BuildSucceeded ? 0 : 1,
BuildSucceeded: result.BuildSucceeded,
};
},
};
}
catch {
// Package not installed
// Orchestrator package not installed
}
}
exports.loadOrchestrator = loadOrchestrator;
/**
* Attempt to load enterprise services for local builds.
* These services (child workspaces, local cache, git hooks, etc.)
* are part of the orchestrator package but also used in local builds.
* Load enterprise services for local builds.
* These services are part of the orchestrator but also used in local builds
* (child workspaces, local cache, git hooks, LFS agents, etc.).
*/
async function loadEnterpriseServices() {
try {
const [{ BuildReliabilityService }, { TestWorkflowService }, { HotRunnerService }, { OutputService }, { OutputTypeRegistry }, { ArtifactUploadHandler }, { IncrementalSyncService },] = await Promise.all([
Promise.resolve().then(() => __importStar(__nccwpck_require__(9842))),
Promise.resolve().then(() => __importStar(__nccwpck_require__(22377))),
Promise.resolve().then(() => __importStar(__nccwpck_require__(74283))),
Promise.resolve().then(() => __importStar(__nccwpck_require__(18795))),
Promise.resolve().then(() => __importStar(__nccwpck_require__(58012))),
Promise.resolve().then(() => __importStar(__nccwpck_require__(49063))),
Promise.resolve().then(() => __importStar(__nccwpck_require__(98729))),
]);
return {
ChildWorkspaceService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(93834))))
.ChildWorkspaceService,
LocalCacheService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(68829)))).LocalCacheService,
SubmoduleProfileService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(88664))))
.SubmoduleProfileService,
LfsAgentService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(85985)))).LfsAgentService,
GitHooksService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(9146)))).GitHooksService,
IncrementalSyncService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(98729)))).IncrementalSyncService,
BuildReliabilityService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(9842)))).BuildReliabilityService,
TestWorkflowService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(22377)))).TestWorkflowService,
HotRunnerService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(74283)))).HotRunnerService,
OutputService: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(18795)))).OutputService,
OutputTypeRegistry: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(58012)))).OutputTypeRegistry,
ArtifactUploadHandler: (await Promise.resolve().then(() => __importStar(__nccwpck_require__(49063))))
.ArtifactUploadHandler,
BuildReliabilityService,
TestWorkflowService,
HotRunnerService,
OutputService,
OutputTypeRegistry,
ArtifactUploadHandler,
IncrementalSyncService,
// Lazy-loaded services (only imported when needed)
async loadChildWorkspaceService() {
const m = await Promise.resolve().then(() => __importStar(__nccwpck_require__(93834)));
return m.ChildWorkspaceService;
},
async loadLocalCacheService() {
const m = await Promise.resolve().then(() => __importStar(__nccwpck_require__(68829)));
return m.LocalCacheService;
},
async loadSubmoduleProfileService() {
const m = await Promise.resolve().then(() => __importStar(__nccwpck_require__(88664)));
return m.SubmoduleProfileService;
},
async loadLfsAgentService() {
const m = await Promise.resolve().then(() => __importStar(__nccwpck_require__(85985)));
return m.LfsAgentService;
},
async loadGitHooksService() {
const m = await Promise.resolve().then(() => __importStar(__nccwpck_require__(9146)));
return m.GitHooksService;
},
};
}
catch (error) {
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long