Fix handling of user manually selecting verbose logging
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
156
src/act.ts
156
src/act.ts
@@ -443,14 +443,16 @@ export class Act {
|
|||||||
try {
|
try {
|
||||||
const parsedMessage = JSON.parse(line);
|
const parsedMessage = JSON.parse(line);
|
||||||
|
|
||||||
// Filter all debug and trace messages except for skipped jobs and steps
|
let updateHistory: boolean = true;
|
||||||
if (parsedMessage.level && ['debug', 'trace'].includes(parsedMessage.level) && parsedMessage.jobResult !== 'skipped' && parsedMessage.stepResult !== 'skipped') {
|
// 1. Filter all debug and trace messages except for skipped jobs and steps
|
||||||
continue;
|
// 2. Filter all skipped pre and post stage steps
|
||||||
}
|
if ((parsedMessage.level && ['debug', 'trace'].includes(parsedMessage.level) && parsedMessage.jobResult !== 'skipped' && parsedMessage.stepResult !== 'skipped') ||
|
||||||
|
(parsedMessage.stepResult === 'skipped' && parsedMessage.stage !== 'Main')) {
|
||||||
// Filter all skipped pre and post stage steps
|
if (userOptions.includes(Option.Verbose)) {
|
||||||
if ((parsedMessage.jobResult === 'skipped' || parsedMessage.stepResult === 'skipped') && parsedMessage.stage !== 'Main') {
|
updateHistory = false;
|
||||||
continue;
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend job name to message
|
// Prepend job name to message
|
||||||
@@ -460,84 +462,86 @@ export class Act {
|
|||||||
message = line;
|
message = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update job status in workspace history
|
if (updateHistory) {
|
||||||
if (parsedMessage.jobID) {
|
// Update job status in workspace history
|
||||||
let jobName: string = parsedMessage.jobID;
|
if (parsedMessage.jobID) {
|
||||||
try {
|
let jobName: string = parsedMessage.jobID;
|
||||||
if (parsedMessage.jobID in commandArgs.workflow.yaml.jobs && commandArgs.workflow.yaml.jobs[parsedMessage.jobID].name) {
|
try {
|
||||||
// Use the name set for the job by the user
|
if (parsedMessage.jobID in commandArgs.workflow.yaml.jobs && commandArgs.workflow.yaml.jobs[parsedMessage.jobID].name) {
|
||||||
jobName = commandArgs.workflow.yaml.jobs[parsedMessage.jobID].name;
|
// Use the name set for the job by the user
|
||||||
}
|
jobName = commandArgs.workflow.yaml.jobs[parsedMessage.jobID].name;
|
||||||
} catch (error: any) { }
|
|
||||||
|
|
||||||
// Update name if it is a matrix
|
|
||||||
if (parsedMessage.matrix && Object.keys(parsedMessage.matrix).length > 0) {
|
|
||||||
const matrixValues = Object.values(parsedMessage.matrix).join(", ");
|
|
||||||
jobName = `${jobName} (${matrixValues})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
let jobIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!
|
|
||||||
.findIndex(job => job.name === jobName);
|
|
||||||
if (jobIndex < 0) {
|
|
||||||
// Add new job with setup step
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!.push({
|
|
||||||
name: jobName,
|
|
||||||
status: HistoryStatus.Running,
|
|
||||||
date: {
|
|
||||||
start: dateString
|
|
||||||
},
|
|
||||||
steps: []
|
|
||||||
});
|
|
||||||
jobIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update step status in workspace history
|
|
||||||
if (parsedMessage.stepID) {
|
|
||||||
let stepName: string;
|
|
||||||
const stepId: string = parsedMessage.stepID[0];
|
|
||||||
if (parsedMessage.stage !== 'Main') {
|
|
||||||
stepName = `${parsedMessage.stage} ${parsedMessage.step}`;
|
|
||||||
} else {
|
|
||||||
stepName = parsedMessage.step;
|
|
||||||
|
|
||||||
// TODO: This forcefully sets any pre step to success. To be fixed with https://github.com/nektos/act/issues/2551
|
|
||||||
const preStepName = `Pre ${parsedMessage.step}`;
|
|
||||||
let preStepIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!
|
|
||||||
.findIndex(step => step.id === stepId && step.name === preStepName);
|
|
||||||
if (preStepIndex > -1 && this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![preStepIndex].status === HistoryStatus.Running) {
|
|
||||||
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![preStepIndex].status = HistoryStatus.Success;
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![preStepIndex].date.end = dateString;
|
|
||||||
}
|
}
|
||||||
|
} catch (error: any) { }
|
||||||
|
|
||||||
|
// Update name if it is a matrix
|
||||||
|
if (parsedMessage.matrix && Object.keys(parsedMessage.matrix).length > 0) {
|
||||||
|
const matrixValues = Object.values(parsedMessage.matrix).join(", ");
|
||||||
|
jobName = `${jobName} (${matrixValues})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let stepIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!
|
let jobIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!
|
||||||
.findIndex(step => step.id === stepId && step.name === stepName);
|
.findIndex(job => job.name === jobName);
|
||||||
if (stepIndex < 0) {
|
if (jobIndex < 0) {
|
||||||
// Add new step
|
// Add new job with setup step
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!.push({
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!.push({
|
||||||
id: stepId,
|
name: jobName,
|
||||||
name: stepName,
|
|
||||||
status: HistoryStatus.Running,
|
status: HistoryStatus.Running,
|
||||||
date: {
|
date: {
|
||||||
start: dateString
|
start: dateString
|
||||||
}
|
},
|
||||||
|
steps: []
|
||||||
});
|
});
|
||||||
stepIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!.length - 1;
|
jobIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedMessage.stepResult) {
|
// Update step status in workspace history
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].status =
|
if (parsedMessage.stepID) {
|
||||||
HistoryManager.stepResultToHistoryStatus(parsedMessage.stepResult);
|
let stepName: string;
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].date.end = dateString;
|
const stepId: string = parsedMessage.stepID[0];
|
||||||
}
|
if (parsedMessage.stage !== 'Main') {
|
||||||
}
|
stepName = `${parsedMessage.stage} ${parsedMessage.step}`;
|
||||||
|
} else {
|
||||||
|
stepName = parsedMessage.step;
|
||||||
|
|
||||||
if (parsedMessage.jobResult) {
|
// TODO: This forcefully sets any pre step to success. To be fixed with https://github.com/nektos/act/issues/2551
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].status =
|
const preStepName = `Pre ${parsedMessage.step}`;
|
||||||
HistoryManager.stepResultToHistoryStatus(parsedMessage.jobResult);
|
let preStepIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end =
|
.findIndex(step => step.id === stepId && step.name === preStepName);
|
||||||
dateString;
|
if (preStepIndex > -1 && this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![preStepIndex].status === HistoryStatus.Running) {
|
||||||
|
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![preStepIndex].status = HistoryStatus.Success;
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![preStepIndex].date.end = dateString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let stepIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!
|
||||||
|
.findIndex(step => step.id === stepId && step.name === stepName);
|
||||||
|
if (stepIndex < 0) {
|
||||||
|
// Add new step
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!.push({
|
||||||
|
id: stepId,
|
||||||
|
name: stepName,
|
||||||
|
status: HistoryStatus.Running,
|
||||||
|
date: {
|
||||||
|
start: dateString
|
||||||
|
}
|
||||||
|
});
|
||||||
|
stepIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedMessage.stepResult) {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].status =
|
||||||
|
HistoryManager.stepResultToHistoryStatus(parsedMessage.stepResult);
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].date.end = dateString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedMessage.jobResult) {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].status =
|
||||||
|
HistoryManager.stepResultToHistoryStatus(parsedMessage.jobResult);
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end =
|
||||||
|
dateString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user