Add support for skipped job and step status

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-12-10 01:03:04 -05:00
parent d6e7b47c5e
commit 781cc0474f
4 changed files with 41 additions and 12 deletions

View File

@@ -765,6 +765,14 @@
"light": "#89d185" "light": "#89d185"
} }
}, },
{
"id": "GitHubLocalActions.red",
"description": "Color for red in the GitHub Local Actions extension",
"defaults": {
"dark": "#f48771",
"light": "#f48771"
}
},
{ {
"id": "GitHubLocalActions.yellow", "id": "GitHubLocalActions.yellow",
"description": "Color for yellow in the GitHub Local Actions extension", "description": "Color for yellow in the GitHub Local Actions extension",
@@ -773,6 +781,14 @@
"light": "#cca700" "light": "#cca700"
} }
}, },
{
"id": "GitHubLocalActions.grey",
"description": "Color for grey in the GitHub Local Actions extension",
"defaults": {
"dark": "#808080",
"light": "#808080"
}
},
{ {
"id": "GitHubLocalActions.purple", "id": "GitHubLocalActions.purple",
"description": "Color for purple in the GitHub Local Actions extension", "description": "Color for purple in the GitHub Local Actions extension",
@@ -780,14 +796,6 @@
"dark": "#d6bcfa", "dark": "#d6bcfa",
"light": "#d6bcfa" "light": "#d6bcfa"
} }
},
{
"id": "GitHubLocalActions.red",
"description": "Color for red in the GitHub Local Actions extension",
"defaults": {
"dark": "#f48771",
"light": "#f48771"
}
} }
] ]
}, },

View File

@@ -375,7 +375,7 @@ export class Act {
...settings.options.map(option => option.path ? `--${option.name} ${option.path}` : `--${option.name}`) ...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(' ')}`; const displayCommand = `${actCommand} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;
// Execute task // Execute task
@@ -442,6 +442,13 @@ export class Act {
let message: string; let message: string;
try { try {
const parsedMessage = JSON.parse(line); const parsedMessage = JSON.parse(line);
// Filter all debug and trace messages except for skipped jobs and steps
if (parsedMessage.level && ['debug', 'trace'].includes(parsedMessage.level) && parsedMessage.jobResult !== 'skipped' && parsedMessage.stepResult !== 'skipped') {
continue;
}
// Prepend job name to message
if (typeof parsedMessage.msg === 'string') { if (typeof parsedMessage.msg === 'string') {
message = `${parsedMessage.job ? `[${parsedMessage.job}] ` : ``}${parsedMessage.msg}`; message = `${parsedMessage.job ? `[${parsedMessage.job}] ` : ``}${parsedMessage.msg}`;
} else { } else {
@@ -516,14 +523,14 @@ export class Act {
if (parsedMessage.stepResult) { if (parsedMessage.stepResult) {
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].status = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].status =
parsedMessage.stepResult === 'success' ? HistoryStatus.Success : HistoryStatus.Failed; HistoryManager.stepResultToHistoryStatus(parsedMessage.stepResult);
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].date.end = dateString; this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].date.end = dateString;
} }
} }
if (parsedMessage.jobResult) { if (parsedMessage.jobResult) {
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].status = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].status =
parsedMessage.jobResult === 'success' ? HistoryStatus.Success : HistoryStatus.Failed; HistoryManager.stepResultToHistoryStatus(parsedMessage.jobResult);
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end =
dateString; dateString;
} }

View File

@@ -42,6 +42,7 @@ export enum HistoryStatus {
Running = 'Running', Running = 'Running',
Success = 'Success', Success = 'Success',
Failed = 'Failed', Failed = 'Failed',
Skipped = 'Skipped',
Cancelled = 'Cancelled', Cancelled = 'Cancelled',
Unknown = 'Unknown' Unknown = 'Unknown'
} }
@@ -132,8 +133,21 @@ export class HistoryManager {
return new ThemeIcon('error', new ThemeColor('GitHubLocalActions.red')); return new ThemeIcon('error', new ThemeColor('GitHubLocalActions.red'));
case HistoryStatus.Cancelled: case HistoryStatus.Cancelled:
return new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow')); return new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow'));
case HistoryStatus.Skipped:
return new ThemeIcon('issues', new ThemeColor('GitHubLocalActions.grey'));
case HistoryStatus.Unknown: case HistoryStatus.Unknown:
return new ThemeIcon('question', new ThemeColor('GitHubLocalActions.purple')); 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;
}
}
} }

View File

@@ -9,7 +9,7 @@ export default class JobTreeItem extends TreeItem implements GithubLocalActionsT
job: Job; job: Job;
constructor(public workspaceFolder: WorkspaceFolder, 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; this.job = job;
let endTime: string | undefined; let endTime: string | undefined;