mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-10 07:53:52 -07:00
f0aca9e727
- Add `test` / `t` command mirroring unity-test-runner (EditMode, PlayMode, All, code coverage, test filters) - Add `o` short alias for `orchestrate` command - Extract shared option builders (project, docker, android, orchestrator) to eliminate duplication across build/test/orchestrate - Make `build` local-only — remove --provider-strategy (use `orchestrate` for remote builds) - Absorb `cache` command into `status` (--cache-dir flag) — remove standalone cache command that was half-implemented - Fix `list-worfklow` typo in internal CLI → `list-workflow` - Add test-related fields to CliArguments input mapper - Update all unit and integration tests (64 passing) Command structure is now: game-ci build Local build (Docker/macOS) game-ci test / t Run Unity tests game-ci orchestrate / o Remote build (AWS/K8s/etc) game-ci activate License validation game-ci status Project info + cache status game-ci version Version info game-ci update Self-update Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
118 lines
4.4 KiB
TypeScript
118 lines
4.4 KiB
TypeScript
import type { CommandModule } from 'yargs';
|
|
import * as core from '@actions/core';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import UnityVersioning from '../../model/unity-versioning';
|
|
|
|
const statusCommand: CommandModule = {
|
|
command: 'status',
|
|
describe: 'Show project info, environment, and cache status',
|
|
builder: (yargs) => {
|
|
return yargs
|
|
.option('project-path', {
|
|
alias: 'projectPath',
|
|
type: 'string',
|
|
description: 'Path to the Unity project',
|
|
default: '.',
|
|
})
|
|
.option('cache-dir', {
|
|
alias: 'cacheDir',
|
|
type: 'string',
|
|
description: 'Path to an additional cache directory to inspect',
|
|
default: '',
|
|
});
|
|
},
|
|
handler: async (cliArguments) => {
|
|
const projectPath = (cliArguments.projectPath as string) || '.';
|
|
const cacheDirectory = cliArguments.cacheDir as string;
|
|
|
|
core.info('game-ci Workspace Status');
|
|
core.info('========================\n');
|
|
|
|
// Project detection
|
|
const projectVersionPath = path.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt');
|
|
const hasProject = fs.existsSync(projectVersionPath);
|
|
|
|
core.info(`Project Path: ${path.resolve(projectPath)}`);
|
|
core.info(`Unity Project Found: ${hasProject ? 'Yes' : 'No'}`);
|
|
|
|
if (hasProject) {
|
|
try {
|
|
const unityVersion = UnityVersioning.determineUnityVersion(projectPath, 'auto');
|
|
core.info(`Unity Version: ${unityVersion}`);
|
|
} catch {
|
|
core.info(`Unity Version: Unable to detect`);
|
|
}
|
|
|
|
// Library cache status
|
|
const libraryPath = path.join(projectPath, 'Library');
|
|
if (fs.existsSync(libraryPath)) {
|
|
const stats = fs.statSync(libraryPath);
|
|
core.info(`Library Cache: Present (modified ${stats.mtime.toISOString()})`);
|
|
|
|
const keyDirectories = ['PackageCache', 'ScriptAssemblies', 'ShaderCache', 'Bee'];
|
|
for (const directory of keyDirectories) {
|
|
const directoryPath = path.join(libraryPath, directory);
|
|
if (fs.existsSync(directoryPath)) {
|
|
const directoryStats = fs.statSync(directoryPath);
|
|
core.info(` ${directory}/: exists (modified ${directoryStats.mtime.toISOString()})`);
|
|
}
|
|
}
|
|
} else {
|
|
core.info(`Library Cache: Not present (clean build required)`);
|
|
}
|
|
|
|
// Cache archive detection
|
|
if (cacheDirectory && fs.existsSync(cacheDirectory)) {
|
|
core.info(`\nCache Archives (${cacheDirectory}):`);
|
|
const cacheFiles = fs.readdirSync(cacheDirectory).filter((f) => f.endsWith('.tar') || f.endsWith('.tar.lz4'));
|
|
if (cacheFiles.length > 0) {
|
|
for (const file of cacheFiles) {
|
|
const filePath = path.join(cacheDirectory, file);
|
|
const fileStats = fs.statSync(filePath);
|
|
const sizeMegabytes = (fileStats.size / (1024 * 1024)).toFixed(1);
|
|
core.info(` - ${file} (${sizeMegabytes} MB, ${fileStats.mtime.toISOString()})`);
|
|
}
|
|
} else {
|
|
core.info(' No cache archives found.');
|
|
}
|
|
}
|
|
|
|
// Build output detection
|
|
const buildsPath = path.join(projectPath, '..', 'build');
|
|
if (fs.existsSync(buildsPath)) {
|
|
const builds = fs.readdirSync(buildsPath);
|
|
if (builds.length > 0) {
|
|
core.info(`\nBuild Outputs (${buildsPath}):`);
|
|
for (const build of builds) {
|
|
const buildPath = path.join(buildsPath, build);
|
|
const buildStats = fs.statSync(buildPath);
|
|
core.info(` - ${build} (${buildStats.isDirectory() ? 'dir' : 'file'}, ${buildStats.mtime.toISOString()})`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Environment
|
|
core.info('\nEnvironment:');
|
|
core.info(` Platform: ${process.platform}`);
|
|
core.info(` Node.js: ${process.version}`);
|
|
core.info(` UNITY_SERIAL: ${process.env.UNITY_SERIAL ? 'Set' : 'Not set'}`);
|
|
core.info(` UNITY_LICENSE: ${process.env.UNITY_LICENSE ? 'Set' : 'Not set'}`);
|
|
core.info(` UNITY_EMAIL: ${process.env.UNITY_EMAIL ? 'Set' : 'Not set'}`);
|
|
core.info(` UNITY_PASSWORD: ${process.env.UNITY_PASSWORD ? 'Set' : 'Not set'}`);
|
|
|
|
// Docker availability
|
|
core.info(`\nDocker: Checking...`);
|
|
try {
|
|
const { execSync } = await import('node:child_process');
|
|
const dockerVersion = execSync('docker --version', { encoding: 'utf8' }).trim();
|
|
core.info(` ${dockerVersion}`);
|
|
} catch {
|
|
core.info(` Docker not found or not accessible`);
|
|
}
|
|
},
|
|
};
|
|
|
|
export default statusCommand;
|