Merge pull request #113 from SanjulaGanepola/feature/skip-status
Add support for skipped job and step status
This commit is contained in:
24
package.json
24
package.json
@@ -765,6 +765,14 @@
|
||||
"light": "#89d185"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "GitHubLocalActions.red",
|
||||
"description": "Color for red in the GitHub Local Actions extension",
|
||||
"defaults": {
|
||||
"dark": "#f48771",
|
||||
"light": "#f48771"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "GitHubLocalActions.yellow",
|
||||
"description": "Color for yellow in the GitHub Local Actions extension",
|
||||
@@ -773,6 +781,14 @@
|
||||
"light": "#cca700"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "GitHubLocalActions.grey",
|
||||
"description": "Color for grey in the GitHub Local Actions extension",
|
||||
"defaults": {
|
||||
"dark": "#808080",
|
||||
"light": "#808080"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "GitHubLocalActions.purple",
|
||||
"description": "Color for purple in the GitHub Local Actions extension",
|
||||
@@ -780,14 +796,6 @@
|
||||
"dark": "#d6bcfa",
|
||||
"light": "#d6bcfa"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "GitHubLocalActions.red",
|
||||
"description": "Color for red in the GitHub Local Actions extension",
|
||||
"defaults": {
|
||||
"dark": "#f48771",
|
||||
"light": "#f48771"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
154
src/act.ts
154
src/act.ts
@@ -375,7 +375,7 @@ export class Act {
|
||||
...settings.options.map(option => option.path ? `--${option.name} ${option.path}` : `--${option.name}`)
|
||||
];
|
||||
|
||||
const command = `${actCommand} ${Option.Json} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;
|
||||
const command = `${actCommand} ${Option.Json} ${Option.Verbose} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;
|
||||
const displayCommand = `${actCommand} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;
|
||||
|
||||
// Execute task
|
||||
@@ -442,90 +442,106 @@ export class Act {
|
||||
let message: string;
|
||||
try {
|
||||
const parsedMessage = JSON.parse(line);
|
||||
|
||||
let updateHistory: boolean = true;
|
||||
// 1. Filter all debug and trace messages except for skipped jobs and steps
|
||||
// 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')) {
|
||||
if (userOptions.includes(Option.Verbose)) {
|
||||
updateHistory = false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepend job name to message
|
||||
if (typeof parsedMessage.msg === 'string') {
|
||||
message = `${parsedMessage.job ? `[${parsedMessage.job}] ` : ``}${parsedMessage.msg}`;
|
||||
} else {
|
||||
message = line;
|
||||
}
|
||||
|
||||
// Update job status in workspace history
|
||||
if (parsedMessage.jobID) {
|
||||
let jobName: string = parsedMessage.jobID;
|
||||
try {
|
||||
if (parsedMessage.jobID in commandArgs.workflow.yaml.jobs && 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;
|
||||
if (updateHistory) {
|
||||
// Update job status in workspace history
|
||||
if (parsedMessage.jobID) {
|
||||
let jobName: string = parsedMessage.jobID;
|
||||
try {
|
||||
if (parsedMessage.jobID in commandArgs.workflow.yaml.jobs && 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 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,
|
||||
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: []
|
||||
});
|
||||
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) {
|
||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].status =
|
||||
parsedMessage.stepResult === 'success' ? HistoryStatus.Success : HistoryStatus.Failed;
|
||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].date.end = dateString;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
|
||||
if (parsedMessage.jobResult) {
|
||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].status =
|
||||
parsedMessage.jobResult === 'success' ? HistoryStatus.Success : HistoryStatus.Failed;
|
||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end =
|
||||
dateString;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -42,6 +42,7 @@ export enum HistoryStatus {
|
||||
Running = 'Running',
|
||||
Success = 'Success',
|
||||
Failed = 'Failed',
|
||||
Skipped = 'Skipped',
|
||||
Cancelled = 'Cancelled',
|
||||
Unknown = 'Unknown'
|
||||
}
|
||||
@@ -132,8 +133,21 @@ export class HistoryManager {
|
||||
return new ThemeIcon('error', new ThemeColor('GitHubLocalActions.red'));
|
||||
case HistoryStatus.Cancelled:
|
||||
return new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow'));
|
||||
case HistoryStatus.Skipped:
|
||||
return new ThemeIcon('issues', new ThemeColor('GitHubLocalActions.grey'));
|
||||
case HistoryStatus.Unknown:
|
||||
return new ThemeIcon('question', new ThemeColor('GitHubLocalActions.purple'));
|
||||
}
|
||||
}
|
||||
|
||||
static stepResultToHistoryStatus(stepResult: string) {
|
||||
switch (stepResult) {
|
||||
case 'success':
|
||||
return HistoryStatus.Success;
|
||||
case 'skipped':
|
||||
return HistoryStatus.Skipped;
|
||||
default:
|
||||
return HistoryStatus.Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export default class JobTreeItem extends TreeItem implements GithubLocalActionsT
|
||||
job: Job;
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder, job: Job) {
|
||||
super(job.name, TreeItemCollapsibleState.Expanded);
|
||||
super(job.name, job.status === HistoryStatus.Skipped ? TreeItemCollapsibleState.None : TreeItemCollapsibleState.Expanded);
|
||||
this.job = job;
|
||||
|
||||
let endTime: string | undefined;
|
||||
|
||||
Reference in New Issue
Block a user