mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-01 06:16:14 -07:00
Compare commits
2 Commits
chore/remo
...
linux-exte
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a38ec6caef | ||
|
|
37ce35f1a5 |
@@ -178,6 +178,11 @@ inputs:
|
||||
default: 'false'
|
||||
required: false
|
||||
description: 'Skip the activation/deactivation of Unity. This assumes Unity is already activated.'
|
||||
linux64RemoveExecutableExtension:
|
||||
default: 'false'
|
||||
required: false
|
||||
description:
|
||||
'When building for StandaloneLinux64, remove the default file extension of `.x86_64`. Set to true to restore the extensionless behavior from v4.'
|
||||
|
||||
outputs:
|
||||
volume:
|
||||
|
||||
@@ -36,8 +36,11 @@
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"commander": "^9.0.0",
|
||||
"commander-ts": "^0.2.0",
|
||||
"md5": "^2.3.0",
|
||||
"nanoid": "^3.3.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"semver": "^7.5.2",
|
||||
"ts-md5": "^1.3.1",
|
||||
"unity-changeset": "^3.1.0",
|
||||
|
||||
@@ -66,6 +66,12 @@ vi.mock('./model', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('./model/cli/cli', () => ({
|
||||
Cli: {
|
||||
InitCliMode: vi.fn().mockReturnValue(false),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('./model/mac-builder', () => ({
|
||||
__esModule: true,
|
||||
default: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as core from '@actions/core';
|
||||
import { Action, BuildParameters, Cache, Docker, ImageTag, Output } from './model';
|
||||
import { Cli } from './model/cli/cli';
|
||||
import MacBuilder from './model/mac-builder';
|
||||
import PlatformSetup from './model/platform-setup';
|
||||
import { Plugin, loadPlugin } from './model/plugin';
|
||||
@@ -8,6 +9,11 @@ import { Plugin, loadPlugin } from './model/plugin';
|
||||
// vitest's module re-loading (which changed in vitest 4).
|
||||
export async function runMain() {
|
||||
try {
|
||||
if (Cli.InitCliMode()) {
|
||||
await Cli.RunCli();
|
||||
|
||||
return;
|
||||
}
|
||||
Action.checkCompatibility();
|
||||
Cache.verify();
|
||||
|
||||
|
||||
@@ -117,18 +117,21 @@ describe('BuildParameters', () => {
|
||||
});
|
||||
|
||||
test.each`
|
||||
targetPlatform | expectedExtension | androidExportType
|
||||
${Platform.types.Android} | ${'.apk'} | ${'androidPackage'}
|
||||
${Platform.types.Android} | ${'.aab'} | ${'androidAppBundle'}
|
||||
${Platform.types.Android} | ${''} | ${'androidStudioProject'}
|
||||
${Platform.types.StandaloneWindows} | ${'.exe'} | ${'n/a'}
|
||||
${Platform.types.StandaloneWindows64} | ${'.exe'} | ${'n/a'}
|
||||
targetPlatform | expectedExtension | androidExportType | linux64RemoveExecutableExtension
|
||||
${Platform.types.Android} | ${'.apk'} | ${'androidPackage'} | ${false}
|
||||
${Platform.types.Android} | ${'.aab'} | ${'androidAppBundle'} | ${true}
|
||||
${Platform.types.Android} | ${''} | ${'androidStudioProject'} | ${false}
|
||||
${Platform.types.StandaloneWindows} | ${'.exe'} | ${'n/a'} | ${true}
|
||||
${Platform.types.StandaloneWindows64} | ${'.exe'} | ${'n/a'} | ${false}
|
||||
${Platform.types.StandaloneLinux64} | ${'.x86_64'} | ${'n/a'} | ${false}
|
||||
${Platform.types.StandaloneLinux64} | ${''} | ${'n/a'} | ${true}
|
||||
`(
|
||||
'appends $expectedExtension for $targetPlatform with androidExportType $androidExportType',
|
||||
async ({ targetPlatform, expectedExtension, androidExportType }) => {
|
||||
'appends $expectedExtension for $targetPlatform with linux64RemoveExecutableExtension=$linux64RemoveExecutableExtension',
|
||||
async ({ targetPlatform, expectedExtension, androidExportType, linux64RemoveExecutableExtension }) => {
|
||||
vi.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform);
|
||||
vi.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform);
|
||||
vi.spyOn(Input, 'androidExportType', 'get').mockReturnValue(androidExportType);
|
||||
vi.spyOn(Input, 'linux64RemoveExecutableExtension', 'get').mockReturnValue(linux64RemoveExecutableExtension);
|
||||
await expect(BuildParameters.create()).resolves.toEqual(
|
||||
expect.objectContaining({ buildFile: `${targetPlatform}${expectedExtension}` }),
|
||||
);
|
||||
|
||||
@@ -73,6 +73,7 @@ class BuildParameters {
|
||||
Input.buildName,
|
||||
Input.targetPlatform,
|
||||
Input.androidExportType,
|
||||
Input.linux64RemoveExecutableExtension,
|
||||
);
|
||||
const editorVersion = UnityVersioning.determineUnityVersion(
|
||||
Input.projectPath,
|
||||
@@ -188,7 +189,12 @@ class BuildParameters {
|
||||
};
|
||||
}
|
||||
|
||||
static parseBuildFile(filename: string, platform: string, androidExportType: string): string {
|
||||
static parseBuildFile(
|
||||
filename: string,
|
||||
platform: string,
|
||||
androidExportType: string,
|
||||
linux64RemoveExecutableExtension: boolean,
|
||||
): string {
|
||||
if (Platform.isWindows(platform)) {
|
||||
return `${filename}.exe`;
|
||||
}
|
||||
@@ -208,6 +214,10 @@ class BuildParameters {
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === Platform.types.StandaloneLinux64 && !linux64RemoveExecutableExtension) {
|
||||
return `${filename}.x86_64`;
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
45
src/model/cli/cli-functions-repository.ts
Normal file
45
src/model/cli/cli-functions-repository.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
export class CliFunctionsRepository {
|
||||
private static targets: any[] = [];
|
||||
public static PushCliFunction(
|
||||
target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor,
|
||||
key: string,
|
||||
description: string,
|
||||
) {
|
||||
CliFunctionsRepository.targets.push({
|
||||
target,
|
||||
propertyKey,
|
||||
descriptor,
|
||||
key,
|
||||
description,
|
||||
});
|
||||
}
|
||||
|
||||
public static GetCliFunctions(key: any) {
|
||||
const results = CliFunctionsRepository.targets.find((x) => x.key === key);
|
||||
if (results === undefined || results.length === 0) {
|
||||
throw new Error(`no CLI mode found for ${key}`);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public static GetAllCliModes() {
|
||||
return CliFunctionsRepository.targets.map((x) => {
|
||||
return {
|
||||
key: x.key,
|
||||
description: x.description,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
public static PushCliFunctionSource(cliFunction: any) {}
|
||||
}
|
||||
|
||||
export function CliFunction(key: string, description: string) {
|
||||
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
|
||||
CliFunctionsRepository.PushCliFunction(target, propertyKey, descriptor, key, description);
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
import { Command } from 'commander-ts';
|
||||
import { Input } from '..';
|
||||
import * as core from '@actions/core';
|
||||
import { ActionYamlReader } from '../input-readers/action-yaml';
|
||||
import { CliFunction, CliFunctionsRepository } from './cli-functions-repository';
|
||||
import { OptionValues } from 'commander';
|
||||
import { InputKey } from '../input';
|
||||
|
||||
export class Cli {
|
||||
public static options: Record<string, any> | undefined;
|
||||
public static options: OptionValues | undefined;
|
||||
static get isCliMode() {
|
||||
return Cli.options !== undefined && Cli.options.mode !== undefined && Cli.options.mode !== '';
|
||||
}
|
||||
@@ -13,4 +21,80 @@ export class Cli {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static InitCliMode() {
|
||||
const program = new Command();
|
||||
program.version('0.0.1');
|
||||
|
||||
const actionYamlReader: ActionYamlReader = new ActionYamlReader();
|
||||
const properties = Object.getOwnPropertyNames(Input).filter(
|
||||
(p) => p !== 'length' && p !== 'prototype' && p !== 'name',
|
||||
);
|
||||
for (const element of properties) {
|
||||
program.option(`--${element} <${element}>`, actionYamlReader.GetActionYamlValue(element));
|
||||
}
|
||||
program.option(
|
||||
'-m, --mode <mode>',
|
||||
CliFunctionsRepository.GetAllCliModes()
|
||||
.map((x) => `${x.key} (${x.description})`)
|
||||
.join(` | `),
|
||||
);
|
||||
program.option(
|
||||
'--populateOverride <populateOverride>',
|
||||
'should use override query to pull input false by default',
|
||||
);
|
||||
program.option('--cachePushFrom <cachePushFrom>', 'cache push from source folder');
|
||||
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
|
||||
program.option('--artifactName <artifactName>', 'caching artifact name');
|
||||
program.option('--select <select>', 'select a particular resource');
|
||||
program.option('--logFile <logFile>', 'output to log file (log stream only)');
|
||||
program.option('--profilePath <profilePath>', 'path to submodule profile YAML');
|
||||
program.option('--variantPath <variantPath>', 'path to submodule variant YAML');
|
||||
program.option('--agentPath <agentPath>', 'path to custom LFS transfer agent');
|
||||
program.option('--agentArgs <agentArgs>', 'arguments for custom LFS transfer agent');
|
||||
program.option(
|
||||
'--storagePaths <storagePaths>',
|
||||
'semicolon-separated storage paths for LFS agent',
|
||||
);
|
||||
program.parse(process.argv);
|
||||
Cli.options = program.opts();
|
||||
|
||||
return Cli.isCliMode;
|
||||
}
|
||||
|
||||
static async RunCli(): Promise<void> {
|
||||
const results = CliFunctionsRepository.GetCliFunctions(Cli.options?.mode);
|
||||
if (!results) {
|
||||
throw new Error(
|
||||
`Unknown CLI mode: ${Cli.options?.mode}. Orchestrator CLI features require @game-ci/orchestrator.`,
|
||||
);
|
||||
}
|
||||
core.info(`Entrypoint: ${results.key}`);
|
||||
Cli.options!.versioning = 'None';
|
||||
|
||||
return await results.target[results.propertyKey](Cli.options);
|
||||
}
|
||||
|
||||
@CliFunction(`print-input`, `prints all input`)
|
||||
private static logInput() {
|
||||
core.info(`\n`);
|
||||
core.info(`INPUT:`);
|
||||
const properties = Object.getOwnPropertyNames(Input).filter(
|
||||
(p) => p !== 'length' && p !== 'prototype' && p !== 'name',
|
||||
);
|
||||
for (const element of properties) {
|
||||
if (
|
||||
element in Input &&
|
||||
Input[element as InputKey] !== undefined &&
|
||||
Input[element as InputKey] !== '' &&
|
||||
typeof Input[element as InputKey] !== `function` &&
|
||||
element !== 'length' &&
|
||||
element !== 'cliOptions' &&
|
||||
element !== 'prototype'
|
||||
) {
|
||||
core.info(`${element} ${Input[element as InputKey]}`);
|
||||
}
|
||||
}
|
||||
core.info(`\n`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,4 +353,22 @@ describe('Input', () => {
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('linux64RemoveExecutableExtension', () => {
|
||||
it('returns the default value', () => {
|
||||
expect(Input.linux64RemoveExecutableExtension).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it('returns true when string true is passed', () => {
|
||||
const spy = vi.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.linux64RemoveExecutableExtension).toStrictEqual(true);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('returns false when string false is passed', () => {
|
||||
const spy = vi.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.linux64RemoveExecutableExtension).toStrictEqual(false);
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -284,6 +284,12 @@ class Input {
|
||||
return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
|
||||
}
|
||||
|
||||
static get linux64RemoveExecutableExtension(): boolean {
|
||||
const input = Input.getInput('linux64RemoveExecutableExtension') ?? 'false';
|
||||
|
||||
return input === 'true';
|
||||
}
|
||||
|
||||
public static ToEnvVarFormat(input: string) {
|
||||
if (input.toUpperCase() === input) {
|
||||
return input;
|
||||
|
||||
28
yarn.lock
28
yarn.lock
@@ -2302,6 +2302,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"commander-ts@npm:^0.2.0":
|
||||
version: 0.2.0
|
||||
resolution: "commander-ts@npm:0.2.0"
|
||||
dependencies:
|
||||
commander: "npm:^7.2.0"
|
||||
peerDependencies:
|
||||
reflect-metadata: ^0.1.13
|
||||
checksum: 10/b57582d0eb98e7bce0a05bfe7c44b8ed01a0f77a05358ec9d35ef6406ac6b3031590fa49e1bff58649ae511bb18a576b01151cb94de9c12c7f0be7f865ca494f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"commander@npm:^10.0.1":
|
||||
version: 10.0.1
|
||||
resolution: "commander@npm:10.0.1"
|
||||
@@ -2330,6 +2341,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"commander@npm:^9.0.0":
|
||||
version: 9.5.0
|
||||
resolution: "commander@npm:9.5.0"
|
||||
checksum: 10/41c49b3d0f94a1fbeb0463c85b13f15aa15a9e0b4d5e10a49c0a1d58d4489b549d62262b052ae0aa6cfda53299bee487bfe337825df15e342114dde543f82906
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"common-path-prefix@npm:^3.0.0":
|
||||
version: 3.0.0
|
||||
resolution: "common-path-prefix@npm:3.0.0"
|
||||
@@ -4196,6 +4214,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"reflect-metadata@npm:^0.1.13":
|
||||
version: 0.1.14
|
||||
resolution: "reflect-metadata@npm:0.1.14"
|
||||
checksum: 10/fcab9c17ec3b9fea0e2f748c2129aceb57c24af6d8d13842b8a77c8c79dde727d7456ce293e76e8d7b267d1dbf93eea4c5b3c9101299a789a075824f2e40f1ee
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"regexp-tree@npm:^0.1.27":
|
||||
version: 0.1.27
|
||||
resolution: "regexp-tree@npm:0.1.27"
|
||||
@@ -4791,6 +4816,8 @@ __metadata:
|
||||
"@typescript/native-preview": "npm:^7.0.0-dev.20260505.1"
|
||||
"@vercel/ncc": "npm:^0.36.1"
|
||||
"@vitest/coverage-istanbul": "npm:^4.1.5"
|
||||
commander: "npm:^9.0.0"
|
||||
commander-ts: "npm:^0.2.0"
|
||||
cross-env: "npm:^7.0.3"
|
||||
eslint: "npm:^10.3.0"
|
||||
eslint-plugin-unicorn: "npm:^64.0.0"
|
||||
@@ -4802,6 +4829,7 @@ __metadata:
|
||||
node-fetch: "npm:2"
|
||||
oxfmt: "npm:^0.48.0"
|
||||
oxlint: "npm:^1.63.0"
|
||||
reflect-metadata: "npm:^0.1.13"
|
||||
semver: "npm:^7.5.2"
|
||||
ts-md5: "npm:^1.3.1"
|
||||
ts-node: "npm:10.8.1"
|
||||
|
||||
Reference in New Issue
Block a user