Skip to content

Commit 02687a3

Browse files
unity-cli@v1.7.2 (#60)
- prevent utp table from rendering in ci builds
1 parent e60a691 commit 02687a3

File tree

6 files changed

+60
-57
lines changed

6 files changed

+60
-57
lines changed

.github/workflows/build-options.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"macos-latest"
66
],
77
"unity-version": [
8+
"4.7.2",
9+
"5.6.7f1 (e80cc3114ac1)",
10+
"2017.4.40f1",
11+
"2018",
12+
"2018.4",
813
"2019.x",
914
"2020.*",
1015
"2021.3.x",

.github/workflows/unity-build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
contents: read
2424
env:
2525
UNITY_PROJECT_PATH: '' # Set from create-project step
26-
RUN_BUILD: '' # Set to true if the build pipeline package can be installed and used
2726
steps:
2827
- name: Free Disk Space
2928
if: ${{ matrix.os == 'ubuntu-latest' && (matrix.unity-version != '2018' && matrix.unity-version != '2017.4.40f1') }}
@@ -83,6 +82,7 @@ jobs:
8382
unity-cli create-project --name "Unity Project" --unity-editor "${UNITY_EDITOR_PATH}" --json
8483
- name: Verify UNITY_PROJECT_PATH variable
8584
if: ${{ matrix.unity-version != 'none' }}
85+
id: verify-project-path
8686
shell: bash
8787
run: |
8888
if [ -z "${UNITY_PROJECT_PATH}" ]; then
@@ -97,16 +97,16 @@ jobs:
9797
if [ -z "$minor" ]; then
9898
minor=0
9999
fi
100-
# numeric comparison: enable build for major > 2019 or major == 2019 and minor >= 4
101-
if [ "$major" -gt 2019 ] || { [ "$major" -eq 2019 ] && [ "$minor" -ge 4 ]; }; then
100+
# numeric comparison: enable build for major >= 2019
101+
if [ "$major" -ge 2019 ]; then
102102
echo "Proceeding with build for Unity version $version"
103-
echo "RUN_BUILD=true" >> $GITHUB_ENV
103+
echo "RUN_BUILD=true" >> $GITHUB_OUTPUT
104104
else
105105
echo "Skipping build: Unity version $version does not support the build pipeline package (requires 2019.4+)"
106106
fi
107107
- name: Install OpenUPM and build pipeline package
108108
shell: bash
109-
if: ${{ env.RUN_BUILD == 'true' }}
109+
if: ${{ steps.verify-project-path.outputs.RUN_BUILD == 'true' }}
110110
run: |
111111
npm install -g openupm-cli
112112
cd "${UNITY_PROJECT_PATH}"
@@ -120,7 +120,7 @@ jobs:
120120
# ensure android dependencies are installed
121121
unity-cli setup-unity -p "${UNITY_PROJECT_PATH}" -m android
122122
- name: Build Project
123-
if: ${{ env.RUN_BUILD == 'true' }}
123+
if: ${{ steps.verify-project-path.outputs.RUN_BUILD == 'true' }}
124124
timeout-minutes: 60
125125
shell: bash
126126
run: |

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rage-against-the-pixel/unity-cli",
3-
"version": "1.7.1",
3+
"version": "1.7.2",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ program.command('run')
421421
.option('--unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, --unity-project or the UNITY_EDITOR_PATH environment variable must be set.')
422422
.option('--unity-project <unityProject>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable will be used, otherwise no project will be specified.')
423423
.option('--log-name <logName>', 'The name of the log file.')
424-
.option('--log-level <logLevel>', 'Set the logging level (debug, info, minimal, warning, error).')
424+
.option('--log-level <logLevel>', 'Set the logging level (debug, info, minimal, warning, error). Default is info.')
425425
.option('--verbose', 'Enable verbose logging. Deprecated, use --log-level instead.')
426426
.allowUnknownOption(true)
427427
.argument('<args...>', 'Arguments to pass to the Unity Editor executable.')

src/unity-logging.ts

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ActionTelemetryAccumulator {
9595
private totalErrorCount = 0;
9696
private playerBuildInfoSteps: PlayerBuildInfoStepSummary[] = [];
9797

98-
record(action: UTPBase): boolean {
98+
public record(action: UTPBase): boolean {
9999
if (action.phase === Phase.Begin) {
100100
this.pendingActions.set(this.getActionKey(action), action);
101101
return true;
@@ -133,7 +133,7 @@ class ActionTelemetryAccumulator {
133133
return false;
134134
}
135135

136-
recordPlayerBuildInfo(info: UTPPlayerBuildInfo): boolean {
136+
public recordPlayerBuildInfo(info: UTPPlayerBuildInfo): boolean {
137137
if (!Array.isArray(info.steps) || info.steps.length === 0) {
138138
return false;
139139
}
@@ -162,7 +162,7 @@ class ActionTelemetryAccumulator {
162162
return true;
163163
}
164164

165-
snapshot(): ActionTableSnapshot | undefined {
165+
public snapshot(): ActionTableSnapshot | undefined {
166166
if (this.completedActions.length === 0 && this.pendingActions.size === 0 && this.playerBuildInfoSteps.length === 0) {
167167
return undefined;
168168
}
@@ -902,14 +902,13 @@ function formatMemoryLeakTable(memLeaks: UTPMemoryLeak): string {
902902

903903
function buildUtpLogPath(logPath: string): string {
904904
const parsed = path.parse(logPath);
905-
const utpFileName = `utp-${parsed.name}.json`;
905+
const utpFileName = `${parsed.name}-utp-json.log`;
906906
return parsed.dir ? path.join(parsed.dir, utpFileName) : utpFileName;
907907
}
908908

909909
async function writeUtpTelemetryLog(filePath: string, entries: UTP[], logger: Logger): Promise<void> {
910910
try {
911-
const content = `${JSON.stringify(entries, null, 2)}\n`;
912-
await fs.promises.writeFile(filePath, content, 'utf8');
911+
await fs.promises.writeFile(filePath, `${JSON.stringify(entries)}\n`, 'utf8');
913912
} catch (error) {
914913
logger.warn(`Failed to write UTP telemetry log (${filePath}): ${error}`);
915914
}
@@ -940,21 +939,52 @@ export function TailLogFile(logPath: string, projectPath: string | undefined): L
940939
};
941940

942941
const flushTelemetryLog = async (): Promise<void> => {
943-
if (telemetryFlushed) {
944-
return;
945-
}
942+
if (telemetryFlushed) { return; }
946943
telemetryFlushed = true;
947944
await writeUtpTelemetryLog(utpLogPath, telemetry, logger);
948945
};
949946

950-
const writeStdout = (content: string, restoreTable: boolean = true): void => {
947+
const writeStdoutThenTableContent = (content: string, restoreTable: boolean = true): void => {
951948
actionTableRenderer.prepareForContent();
952949
process.stdout.write(content);
953950
if (restoreTable) {
954951
renderActionTable();
955952
}
956953
};
957954

955+
function printUTP(utp: UTP): void {
956+
// switch utp types, fallback to json if we don't have a toString() implementation or a type implementation
957+
switch (utp.type) {
958+
case 'Action': {
959+
const actionEntry = utp as UTPBase;
960+
const tableChanged = actionAccumulator.record(actionEntry);
961+
962+
if (tableChanged) {
963+
renderActionTable();
964+
}
965+
966+
break;
967+
}
968+
case 'MemoryLeaks':
969+
logger.debug(formatMemoryLeakTable(utp as UTPMemoryLeak));
970+
break;
971+
case 'PlayerBuildInfo': {
972+
const infoEntry = utp as UTPPlayerBuildInfo;
973+
const changed = actionAccumulator.recordPlayerBuildInfo(infoEntry);
974+
975+
if (changed) {
976+
renderActionTable();
977+
}
978+
979+
break;
980+
}
981+
default:
982+
// Print raw JSON for unhandled UTP types
983+
writeStdoutThenTableContent(`${JSON.stringify(utp)}\n`);
984+
break;
985+
}
986+
}
987+
958988
async function readNewLogContent(): Promise<void> {
959989
try {
960990
if (!fs.existsSync(logPath)) { return; }
@@ -990,10 +1020,7 @@ export function TailLogFile(logPath: string, projectPath: string | undefined): L
9901020
const jsonPart = line.substring('##utp:'.length).trim();
9911021
try {
9921022
const sanitizedJson = sanitizeTelemetryJson(jsonPart);
993-
994-
if (!sanitizedJson) {
995-
continue;
996-
}
1023+
if (!sanitizedJson) { continue; }
9971024

9981025
const utpJson = JSON.parse(sanitizedJson);
9991026
const utp = utpJson as UTP;
@@ -1030,44 +1057,15 @@ export function TailLogFile(logPath: string, projectPath: string | undefined): L
10301057
}
10311058
}
10321059
}
1033-
} else {
1034-
// switch utp types, fallback to json if we don't have a toString() implementation or a type implementation
1035-
switch (utp.type) {
1036-
case 'Action': {
1037-
const actionEntry = utp as UTPBase;
1038-
const tableChanged = actionAccumulator.record(actionEntry);
1039-
1040-
if (tableChanged) {
1041-
renderActionTable();
1042-
}
1043-
1044-
break;
1045-
}
1046-
case 'MemoryLeaks':
1047-
logger.debug(formatMemoryLeakTable(utp as UTPMemoryLeak));
1048-
break;
1049-
case 'PlayerBuildInfo': {
1050-
const infoEntry = utp as UTPPlayerBuildInfo;
1051-
const changed = actionAccumulator.recordPlayerBuildInfo(infoEntry);
1052-
1053-
if (changed) {
1054-
renderActionTable();
1055-
}
1056-
1057-
break;
1058-
}
1059-
default:
1060-
// Print raw JSON for unhandled UTP types
1061-
writeStdout(`${jsonPart}\n`);
1062-
break;
1063-
}
1060+
} else if (Logger.instance.logLevel === LogLevel.UTP) {
1061+
printUTP(utp);
10641062
}
10651063
} catch (error) {
10661064
logger.warn(`Failed to parse telemetry JSON: ${error} -- raw: ${jsonPart}`);
10671065
}
10681066
} else {
10691067
if (Logger.instance.logLevel !== LogLevel.UTP) {
1070-
writeStdout(`${line}\n`);
1068+
process.stdout.write(`${line}\n`);
10711069
}
10721070
}
10731071
}
@@ -1098,7 +1096,7 @@ export function TailLogFile(logPath: string, projectPath: string | undefined): L
10981096

10991097
try {
11001098
// write a final newline to separate log output
1101-
writeStdout('\n');
1099+
process.stdout.write('\n');
11021100
} catch (error: any) {
11031101
if (error.code !== 'EPIPE') {
11041102
logger.warn(`Error while writing log tail: ${error}`);

0 commit comments

Comments
 (0)