feat(core): add log lines grouping for GH Actions (#21357)
This commit is contained in:
parent
6e4bf8cbf2
commit
7739ce013b
@ -223,8 +223,7 @@ export async function createRunOneDynamicOutputRenderer({
|
|||||||
|
|
||||||
lifeCycle.printTaskTerminalOutput = (task, cacheStatus, terminalOutput) => {
|
lifeCycle.printTaskTerminalOutput = (task, cacheStatus, terminalOutput) => {
|
||||||
if (task.target.project === initiatingProject) {
|
if (task.target.project === initiatingProject) {
|
||||||
output.logCommand(task.id, cacheStatus);
|
output.logCommandOutput(task.id, cacheStatus, terminalOutput);
|
||||||
process.stdout.write(terminalOutput);
|
|
||||||
} else {
|
} else {
|
||||||
tasksToTerminalOutputs[task.id] = terminalOutput;
|
tasksToTerminalOutputs[task.id] = terminalOutput;
|
||||||
}
|
}
|
||||||
@ -254,8 +253,11 @@ export async function createRunOneDynamicOutputRenderer({
|
|||||||
clearRenderInterval();
|
clearRenderInterval();
|
||||||
renderDependentTargets(false);
|
renderDependentTargets(false);
|
||||||
output.addVerticalSeparator('red');
|
output.addVerticalSeparator('red');
|
||||||
output.logCommand(t.task.id, t.status);
|
output.logCommandOutput(
|
||||||
process.stdout.write(tasksToTerminalOutputs[t.task.id]);
|
t.task.id,
|
||||||
|
t.status,
|
||||||
|
tasksToTerminalOutputs[t.task.id]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,8 +15,7 @@ export class EmptyTerminalOutputLifeCycle implements LifeCycle {
|
|||||||
cacheStatus === 'skipped'
|
cacheStatus === 'skipped'
|
||||||
) {
|
) {
|
||||||
const args = getPrintableCommandArgsForTask(task);
|
const args = getPrintableCommandArgsForTask(task);
|
||||||
output.logCommand(args.join(' '), cacheStatus);
|
output.logCommandOutput(args.join(' '), cacheStatus, terminalOutput);
|
||||||
process.stdout.write(terminalOutput);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,6 @@ export class InvokeRunnerTerminalOutputLifeCycle implements LifeCycle {
|
|||||||
terminalOutput: string
|
terminalOutput: string
|
||||||
) {
|
) {
|
||||||
const args = getPrintableCommandArgsForTask(task);
|
const args = getPrintableCommandArgsForTask(task);
|
||||||
output.logCommand(args.join(' '), cacheStatus);
|
output.logCommandOutput(args.join(' '), cacheStatus, terminalOutput);
|
||||||
process.stdout.write(terminalOutput);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,6 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle {
|
|||||||
terminalOutput: string
|
terminalOutput: string
|
||||||
) {
|
) {
|
||||||
const args = getPrintableCommandArgsForTask(task);
|
const args = getPrintableCommandArgsForTask(task);
|
||||||
output.logCommand(args.join(' '), cacheStatus);
|
output.logCommandOutput(args.join(' '), cacheStatus, terminalOutput);
|
||||||
process.stdout.write(terminalOutput);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,8 +116,7 @@ export class StaticRunOneTerminalOutputLifeCycle implements LifeCycle {
|
|||||||
task.target.project === this.initiatingProject
|
task.target.project === this.initiatingProject
|
||||||
) {
|
) {
|
||||||
const args = getPrintableCommandArgsForTask(task);
|
const args = getPrintableCommandArgsForTask(task);
|
||||||
output.logCommand(args.join(' '), status);
|
output.logCommandOutput(args.join(' '), status, terminalOutput);
|
||||||
process.stdout.write(terminalOutput);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,9 @@ import * as readline from 'readline';
|
|||||||
import { isCI } from './is-ci';
|
import { isCI } from './is-ci';
|
||||||
import { TaskStatus } from '../tasks-runner/tasks-runner';
|
import { TaskStatus } from '../tasks-runner/tasks-runner';
|
||||||
|
|
||||||
|
const GH_GROUP_PREFIX = '::group::';
|
||||||
|
const GH_GROUP_SUFFIX = '::endgroup::';
|
||||||
|
|
||||||
export interface CLIErrorMessageConfig {
|
export interface CLIErrorMessageConfig {
|
||||||
title: string;
|
title: string;
|
||||||
bodyLines?: string[];
|
bodyLines?: string[];
|
||||||
@ -228,15 +231,54 @@ class CLIOutput {
|
|||||||
|
|
||||||
logCommand(message: string, taskStatus?: TaskStatus) {
|
logCommand(message: string, taskStatus?: TaskStatus) {
|
||||||
this.addNewline();
|
this.addNewline();
|
||||||
const commandOutput =
|
this.writeToStdOut(this.getCommandWithStatus(message, taskStatus));
|
||||||
chalk.dim('> ') + this.formatCommand(this.normalizeMessage(message));
|
this.addNewline();
|
||||||
const commandOutputWithStatus = this.addTaskStatus(
|
this.addNewline();
|
||||||
taskStatus,
|
}
|
||||||
commandOutput
|
|
||||||
|
logCommandOutput(message: string, taskStatus: TaskStatus, output: string) {
|
||||||
|
let commandOutputWithStatus = this.getCommandWithStatus(
|
||||||
|
message,
|
||||||
|
taskStatus
|
||||||
);
|
);
|
||||||
|
if (process.env.GITHUB_ACTIONS) {
|
||||||
|
const icon = this.getStatusIcon(taskStatus);
|
||||||
|
commandOutputWithStatus = `${GH_GROUP_PREFIX}${icon} ${commandOutputWithStatus}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addNewline();
|
||||||
this.writeToStdOut(commandOutputWithStatus);
|
this.writeToStdOut(commandOutputWithStatus);
|
||||||
this.addNewline();
|
this.addNewline();
|
||||||
this.addNewline();
|
this.addNewline();
|
||||||
|
this.writeToStdOut(output);
|
||||||
|
|
||||||
|
if (process.env.GITHUB_ACTIONS) {
|
||||||
|
this.writeToStdOut(GH_GROUP_SUFFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getCommandWithStatus(
|
||||||
|
message: string,
|
||||||
|
taskStatus: TaskStatus
|
||||||
|
): string {
|
||||||
|
const commandOutput =
|
||||||
|
chalk.dim('> ') + this.formatCommand(this.normalizeMessage(message));
|
||||||
|
return this.addTaskStatus(taskStatus, commandOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getStatusIcon(taskStatus: TaskStatus) {
|
||||||
|
switch (taskStatus) {
|
||||||
|
case 'success':
|
||||||
|
return '✔️';
|
||||||
|
case 'failure':
|
||||||
|
return '❌';
|
||||||
|
case 'skipped':
|
||||||
|
case 'local-cache-kept-existing':
|
||||||
|
return '⏩';
|
||||||
|
case 'local-cache':
|
||||||
|
case 'remote-cache':
|
||||||
|
return '🔁';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private normalizeMessage(message: string) {
|
private normalizeMessage(message: string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user