Merge pull request #95 from SanjulaGanepola/feature/step-and-job-level-output
Add support for job and step level execution status
This commit is contained in:
28
package.json
28
package.json
@@ -240,6 +240,11 @@
|
|||||||
"enablement": "viewItem =~ /^githubLocalActions.history_(Success|Failed|Cancelled).*/",
|
"enablement": "viewItem =~ /^githubLocalActions.history_(Success|Failed|Cancelled).*/",
|
||||||
"icon": "$(close)"
|
"icon": "$(close)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.focusTask",
|
||||||
|
"title": "Focus Task"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.refreshSettings",
|
"command": "githubLocalActions.refreshSettings",
|
||||||
@@ -436,6 +441,10 @@
|
|||||||
"command": "githubLocalActions.remove",
|
"command": "githubLocalActions.remove",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.focusTask",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.refreshSettings",
|
"command": "githubLocalActions.refreshSettings",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
@@ -640,6 +649,11 @@
|
|||||||
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
||||||
"group": "inline@3"
|
"group": "inline@3"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.focusTask",
|
||||||
|
"when": "view == history && viewItem =~ /^githubLocalActions.history.*/",
|
||||||
|
"group": "0_focus@0"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.createSecretFile",
|
"command": "githubLocalActions.createSecretFile",
|
||||||
"when": "view == settings && viewItem =~ /^githubLocalActions.secrets.*/",
|
"when": "view == settings && viewItem =~ /^githubLocalActions.secrets.*/",
|
||||||
@@ -745,7 +759,7 @@
|
|||||||
"colors": [
|
"colors": [
|
||||||
{
|
{
|
||||||
"id": "GitHubLocalActions.green",
|
"id": "GitHubLocalActions.green",
|
||||||
"description": "Color for green in GitHub Local Actions extension",
|
"description": "Color for green in the GitHub Local Actions extension",
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"dark": "#89d185",
|
"dark": "#89d185",
|
||||||
"light": "#89d185"
|
"light": "#89d185"
|
||||||
@@ -753,15 +767,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "GitHubLocalActions.yellow",
|
"id": "GitHubLocalActions.yellow",
|
||||||
"description": "Color for yellow in GitHub Local Actions extension",
|
"description": "Color for yellow in the GitHub Local Actions extension",
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"dark": "#cca700",
|
"dark": "#cca700",
|
||||||
"light": "#cca700"
|
"light": "#cca700"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "GitHubLocalActions.purple",
|
||||||
|
"description": "Color for purple in the GitHub Local Actions extension",
|
||||||
|
"defaults": {
|
||||||
|
"dark": "#d6bcfa",
|
||||||
|
"light": "#d6bcfa"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "GitHubLocalActions.red",
|
"id": "GitHubLocalActions.red",
|
||||||
"description": "Color for red in GitHub Local Actions extension",
|
"description": "Color for red in the GitHub Local Actions extension",
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"dark": "#f48771",
|
"dark": "#f48771",
|
||||||
"light": "#f48771"
|
"light": "#f48771"
|
||||||
|
|||||||
295
src/act.ts
295
src/act.ts
@@ -114,7 +114,8 @@ export enum Option {
|
|||||||
|
|
||||||
export interface CommandArgs {
|
export interface CommandArgs {
|
||||||
path: string,
|
path: string,
|
||||||
options: string,
|
workflow: Workflow,
|
||||||
|
options: string[],
|
||||||
name: string,
|
name: string,
|
||||||
extraHeader: { key: string, value: string }[]
|
extraHeader: { key: string, value: string }[]
|
||||||
}
|
}
|
||||||
@@ -214,7 +215,7 @@ export class Act {
|
|||||||
if (taskDefinition.type === 'GitHub Local Actions') {
|
if (taskDefinition.type === 'GitHub Local Actions') {
|
||||||
this.runningTaskCount--;
|
this.runningTaskCount--;
|
||||||
|
|
||||||
if (this.refreshInterval && this.runningTaskCount == 0) {
|
if (this.refreshInterval && this.runningTaskCount === 0) {
|
||||||
clearInterval(this.refreshInterval);
|
clearInterval(this.refreshInterval);
|
||||||
this.refreshInterval = undefined;
|
this.refreshInterval = undefined;
|
||||||
}
|
}
|
||||||
@@ -251,18 +252,23 @@ export class Act {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async runAllWorkflows(workspaceFolder: WorkspaceFolder) {
|
async runAllWorkflows(workspaceFolder: WorkspaceFolder) {
|
||||||
return await this.runCommand({
|
const workflows = await this.workflowsManager.getWorkflows(workspaceFolder);
|
||||||
path: workspaceFolder.uri.fsPath,
|
if (workflows.length > 0) {
|
||||||
options: ``,
|
for (const workflow of workflows) {
|
||||||
name: workspaceFolder.name,
|
await this.runWorkflow(workspaceFolder, workflow);
|
||||||
extraHeader: []
|
}
|
||||||
});
|
} else {
|
||||||
|
window.showErrorMessage('No workflows found.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async runWorkflow(workspaceFolder: WorkspaceFolder, workflow: Workflow) {
|
async runWorkflow(workspaceFolder: WorkspaceFolder, workflow: Workflow) {
|
||||||
return await this.runCommand({
|
return await this.runCommand({
|
||||||
path: workspaceFolder.uri.fsPath,
|
path: workspaceFolder.uri.fsPath,
|
||||||
options: `${Option.Workflows} ".github/workflows/${path.parse(workflow.uri.fsPath).base}"`,
|
workflow: workflow,
|
||||||
|
options: [
|
||||||
|
`${Option.Workflows} ".github/workflows/${path.parse(workflow.uri.fsPath).base}"`
|
||||||
|
],
|
||||||
name: workflow.name,
|
name: workflow.name,
|
||||||
extraHeader: [
|
extraHeader: [
|
||||||
{ key: 'Workflow', value: workflow.name }
|
{ key: 'Workflow', value: workflow.name }
|
||||||
@@ -273,7 +279,11 @@ export class Act {
|
|||||||
async runJob(workspaceFolder: WorkspaceFolder, workflow: Workflow, job: Job) {
|
async runJob(workspaceFolder: WorkspaceFolder, workflow: Workflow, job: Job) {
|
||||||
return await this.runCommand({
|
return await this.runCommand({
|
||||||
path: workspaceFolder.uri.fsPath,
|
path: workspaceFolder.uri.fsPath,
|
||||||
options: `${Option.Workflows} ".github/workflows/${path.parse(workflow.uri.fsPath).base}" ${Option.Job} "${job.id}"`,
|
workflow: workflow,
|
||||||
|
options: [
|
||||||
|
`${Option.Workflows} ".github/workflows/${path.parse(workflow.uri.fsPath).base}"`,
|
||||||
|
`${Option.Job} "${job.id}"`
|
||||||
|
],
|
||||||
name: `${workflow.name}/${job.name}`,
|
name: `${workflow.name}/${job.name}`,
|
||||||
extraHeader: [
|
extraHeader: [
|
||||||
{ key: 'Workflow', value: workflow.name },
|
{ key: 'Workflow', value: workflow.name },
|
||||||
@@ -283,14 +293,23 @@ export class Act {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async runEvent(workspaceFolder: WorkspaceFolder, event: Event) {
|
async runEvent(workspaceFolder: WorkspaceFolder, event: Event) {
|
||||||
return await this.runCommand({
|
let eventExists: boolean = false;
|
||||||
path: workspaceFolder.uri.fsPath,
|
|
||||||
options: event,
|
const workflows = await this.workflowsManager.getWorkflows(workspaceFolder);
|
||||||
name: event,
|
if (workflows.length > 0) {
|
||||||
extraHeader: [
|
for (const workflow of workflows) {
|
||||||
{ key: 'Event', value: event }
|
if (event in workflow.yaml.on) {
|
||||||
]
|
eventExists = true;
|
||||||
});
|
await this.runWorkflow(workspaceFolder, workflow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!eventExists) {
|
||||||
|
window.showErrorMessage(`No workflows triggered by the ${event} event.`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.showErrorMessage('No workflows found.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async runCommand(commandArgs: CommandArgs) {
|
async runCommand(commandArgs: CommandArgs) {
|
||||||
@@ -315,7 +334,7 @@ export class Act {
|
|||||||
// Initialize history for workspace
|
// Initialize history for workspace
|
||||||
if (!this.historyManager.workspaceHistory[commandArgs.path]) {
|
if (!this.historyManager.workspaceHistory[commandArgs.path]) {
|
||||||
this.historyManager.workspaceHistory[commandArgs.path] = [];
|
this.historyManager.workspaceHistory[commandArgs.path] = [];
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
await this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process task count suffix
|
// Process task count suffix
|
||||||
@@ -343,17 +362,21 @@ export class Act {
|
|||||||
// Build command with settings
|
// Build command with settings
|
||||||
const actCommand = Act.getActCommand();
|
const actCommand = Act.getActCommand();
|
||||||
const settings = await this.settingsManager.getSettings(workspaceFolder, true);
|
const settings = await this.settingsManager.getSettings(workspaceFolder, true);
|
||||||
const command =
|
|
||||||
`${actCommand} ${commandArgs.options}` +
|
const userOptions: string[] = [
|
||||||
(settings.secrets.length > 0 ? ` ${Option.Secret} ${settings.secrets.map(secret => secret.key).join(` ${Option.Secret} `)}` : ``) +
|
...settings.secrets.map(secret => `${Option.Secret} ${secret.key}`),
|
||||||
(settings.secretFiles.length > 0 ? ` ${Option.SecretFile} "${settings.secretFiles[0].path}"` : ` ${Option.SecretFile} ""`) +
|
(settings.secretFiles.length > 0 ? `${Option.SecretFile} "${settings.secretFiles[0].path}"` : `${Option.SecretFile} ""`),
|
||||||
(settings.variables.length > 0 ? ` ${Option.Var} ${settings.variables.map(variable => `${variable.key}=${variable.value}`).join(` ${Option.Var} `)}` : ``) +
|
...settings.variables.map(variable => `${Option.Var} ${variable.key}=${variable.value}`),
|
||||||
(settings.variableFiles.length > 0 ? ` ${Option.VarFile} "${settings.variableFiles[0].path}"` : ` ${Option.VarFile} ""`) +
|
(settings.variableFiles.length > 0 ? `${Option.VarFile} "${settings.variableFiles[0].path}"` : `${Option.VarFile} ""`),
|
||||||
(settings.inputs.length > 0 ? ` ${Option.Input} ${settings.inputs.map(input => `${input.key}=${input.value}`).join(` ${Option.Input} `)}` : ``) +
|
...settings.inputs.map(input => `${Option.Input} ${input.key}=${input.value}`),
|
||||||
(settings.inputFiles.length > 0 ? ` ${Option.InputFile} "${settings.inputFiles[0].path}"` : ` ${Option.InputFile} ""`) +
|
(settings.inputFiles.length > 0 ? `${Option.InputFile} "${settings.inputFiles[0].path}"` : `${Option.InputFile} ""`),
|
||||||
(settings.runners.length > 0 ? ` ${Option.Platform} ${settings.runners.map(runner => `${runner.key}=${runner.value}`).join(` ${Option.Platform} `)}` : ``) +
|
...settings.runners.map(runner => `${Option.Platform} ${runner.key}=${runner.value}`),
|
||||||
(settings.payloadFiles.length > 0 ? ` ${Option.EventPath} "${settings.payloadFiles[0].path}"` : ` ${Option.EventPath} ""`) +
|
(settings.payloadFiles.length > 0 ? `${Option.EventPath} "${settings.payloadFiles[0].path}"` : `${Option.EventPath} ""`),
|
||||||
(settings.options.map(option => option.path ? ` --${option.name} ${option.path}` : ` --${option.name}`).join(''));
|
...settings.options.map(option => option.path ? `--${option.name} ${option.path}` : `--${option.name}`)
|
||||||
|
];
|
||||||
|
|
||||||
|
const command = `${actCommand} ${Option.Json} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;
|
||||||
|
const displayCommand = `${actCommand} ${commandArgs.options.join(' ')} ${userOptions.join(' ')}`;
|
||||||
|
|
||||||
// Execute task
|
// Execute task
|
||||||
const taskExecution = await tasks.executeTask({
|
const taskExecution = await tasks.executeTask({
|
||||||
@@ -383,22 +406,6 @@ export class Act {
|
|||||||
runOptions: {},
|
runOptions: {},
|
||||||
group: TaskGroup.Build,
|
group: TaskGroup.Build,
|
||||||
execution: new CustomExecution(async (resolvedDefinition: TaskDefinition): Promise<Pseudoterminal> => {
|
execution: new CustomExecution(async (resolvedDefinition: TaskDefinition): Promise<Pseudoterminal> => {
|
||||||
// Add new entry to workspace history
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.path].push({
|
|
||||||
index: historyIndex,
|
|
||||||
count: count,
|
|
||||||
name: `${commandArgs.name}`,
|
|
||||||
status: HistoryStatus.Running,
|
|
||||||
date: {
|
|
||||||
start: start.toString()
|
|
||||||
},
|
|
||||||
taskExecution: taskExecution,
|
|
||||||
commandArgs: commandArgs,
|
|
||||||
logPath: logPath
|
|
||||||
});
|
|
||||||
historyTreeDataProvider.refresh();
|
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
|
||||||
|
|
||||||
const writeEmitter = new EventEmitter<string>();
|
const writeEmitter = new EventEmitter<string>();
|
||||||
const closeEmitter = new EventEmitter<number>();
|
const closeEmitter = new EventEmitter<number>();
|
||||||
|
|
||||||
@@ -413,16 +420,150 @@ export class Act {
|
|||||||
|
|
||||||
// Append data to log file
|
// Append data to log file
|
||||||
await fs.appendFile(logPath, data);
|
await fs.appendFile(logPath, data);
|
||||||
} catch (error) { }
|
} catch (error: any) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleIO = (data: any) => {
|
const handleIO = () => {
|
||||||
const lines: string[] = data.toString().split('\n').filter((line: string) => line != '');
|
let lastline: string = "";
|
||||||
for (const line of lines) {
|
return async (data: any) => {
|
||||||
writeEmitter.fire(`${line.trimEnd()}\r\n`);
|
let xdata: string = data.toString();
|
||||||
|
let lines: string[] = xdata.split('\n').filter((line: string) => line !== '');
|
||||||
|
if (lastline?.length > 0) {
|
||||||
|
lines[0] = lastline + lines[0];
|
||||||
|
lastline = "";
|
||||||
|
}
|
||||||
|
if (!xdata.endsWith("\n")) {
|
||||||
|
lastline = lines.pop() || "";
|
||||||
|
}
|
||||||
|
for await (const line of lines) {
|
||||||
|
const dateString = new Date().toString();
|
||||||
|
|
||||||
|
let message: string;
|
||||||
|
try {
|
||||||
|
const parsedMessage = JSON.parse(line);
|
||||||
|
if (typeof parsedMessage.msg === 'string') {
|
||||||
|
message = `${parsedMessage.job ? `[${parsedMessage.job}] ` : ``}${parsedMessage.msg}`;
|
||||||
|
} else {
|
||||||
|
message = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update job and step 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) {
|
||||||
|
jobName = commandArgs.workflow.yaml.jobs[parsedMessage.jobID].name;
|
||||||
|
}
|
||||||
|
} catch (error: any) { }
|
||||||
|
|
||||||
|
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: [
|
||||||
|
// TODO: Add setup job step. To be fixed with https://github.com/nektos/act/issues/2551
|
||||||
|
// {
|
||||||
|
// id: "--setup-job", // Special id for setup job
|
||||||
|
// name: 'Setup Job',
|
||||||
|
// status: HistoryStatus.Running,
|
||||||
|
// date: {
|
||||||
|
// start: dateString
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
jobIndex = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs!.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add complete job step. To be fixed with https://github.com/nektos/act/issues/2551
|
||||||
|
// const isCompleteJobStep = this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps!.length > 1;
|
||||||
|
// if (parsedMessage.stepID || isCompleteJobStep) {
|
||||||
|
// let stepName: string;
|
||||||
|
// let stepId: string;
|
||||||
|
// if (!parsedMessage.stepID && isCompleteJobStep) {
|
||||||
|
// stepName = 'Complete Job';
|
||||||
|
// stepId = "--complete-job"; // Special Id for complete job
|
||||||
|
// } else {
|
||||||
|
// stepName = parsedMessage.stage !== 'Main' ? `${parsedMessage.stage} ${parsedMessage.step}` : parsedMessage.step;
|
||||||
|
// stepId = parsedMessage.stepID[0];
|
||||||
|
// }
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add setup job status check. To be fixed with https://github.com/nektos/act/issues/2551
|
||||||
|
// if (this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![0].status === HistoryStatus.Running) {
|
||||||
|
// // TODO: This forcefully sets the setup job step to success. To be fixed with https://github.com/nektos/act/issues/2551
|
||||||
|
// this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![0].status = HistoryStatus.Success;
|
||||||
|
// this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![0].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 =
|
||||||
|
parsedMessage.stepResult === 'success' ? HistoryStatus.Success : HistoryStatus.Failed;
|
||||||
|
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 =
|
||||||
|
parsedMessage.jobResult === 'success' ? HistoryStatus.Success : HistoryStatus.Failed;
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end =
|
||||||
|
dateString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
message = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userOptions.includes(Option.Json)) {
|
||||||
|
message = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeEmitter.fire(`${message.trimEnd()}\r\n`);
|
||||||
|
historyTreeDataProvider.refresh();
|
||||||
|
}
|
||||||
|
await this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let shell = env.shell;
|
let shell = env.shell;
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case Platform.windows:
|
case Platform.windows:
|
||||||
@@ -452,11 +593,31 @@ export class Act {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
exec.stdout.on('data', handleIO);
|
exec.stdout.on('data', handleIO());
|
||||||
exec.stderr.on('data', handleIO);
|
exec.stderr.on('data', handleIO());
|
||||||
exec.on('exit', (code, signal) => {
|
exec.on('exit', async (code, signal) => {
|
||||||
|
const dateString = new Date().toString();
|
||||||
|
|
||||||
// Set execution status and end time in workspace history
|
// Set execution status and end time in workspace history
|
||||||
if (this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status === HistoryStatus.Running) {
|
if (this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status === HistoryStatus.Running) {
|
||||||
|
const jobAndStepStatus = (!code && code !== 0) ? HistoryStatus.Cancelled : HistoryStatus.Unknown;
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs?.forEach((job, jobIndex) => {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps?.forEach((step, stepIndex) => {
|
||||||
|
if (step.status === HistoryStatus.Running) {
|
||||||
|
// Update status of all running steps
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].status = jobAndStepStatus;
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].steps![stepIndex].date.end = dateString;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (job.status === HistoryStatus.Running) {
|
||||||
|
// Update status of all running jobs
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].status = jobAndStepStatus;
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].jobs![jobIndex].date.end = dateString;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update history status
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Success;
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Success;
|
||||||
} else if (!code) {
|
} else if (!code) {
|
||||||
@@ -465,9 +626,9 @@ export class Act {
|
|||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Failed;
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].status = HistoryStatus.Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].date.end = new Date().toString();
|
this.historyManager.workspaceHistory[commandArgs.path][historyIndex].date.end = dateString;
|
||||||
historyTreeDataProvider.refresh();
|
historyTreeDataProvider.refresh();
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
await this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
|
|
||||||
if (signal === 'SIGINT') {
|
if (signal === 'SIGINT') {
|
||||||
writeEmitter.fire(`\r\nTask interrupted.\r\n`);
|
writeEmitter.fire(`\r\nTask interrupted.\r\n`);
|
||||||
@@ -485,7 +646,7 @@ export class Act {
|
|||||||
onDidWrite: writeEmitter.event,
|
onDidWrite: writeEmitter.event,
|
||||||
onDidClose: closeEmitter.event,
|
onDidClose: closeEmitter.event,
|
||||||
open: async (initialDimensions: TerminalDimensions | undefined): Promise<void> => {
|
open: async (initialDimensions: TerminalDimensions | undefined): Promise<void> => {
|
||||||
writeEmitter.fire(`${command}\r\n\r\n`);
|
writeEmitter.fire(`${displayCommand}\r\n\r\n`);
|
||||||
},
|
},
|
||||||
handleInput: (data: string) => {
|
handleInput: (data: string) => {
|
||||||
if (data === '\x03') {
|
if (data === '\x03') {
|
||||||
@@ -494,7 +655,7 @@ export class Act {
|
|||||||
exec.stdin.destroy();
|
exec.stdin.destroy();
|
||||||
exec.stderr.destroy();
|
exec.stderr.destroy();
|
||||||
} else {
|
} else {
|
||||||
exec.stdin.write(data === '\r' ? '\r\n' : data)
|
exec.stdin.write(data === '\r' ? '\r\n' : data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
close: () => {
|
close: () => {
|
||||||
@@ -506,7 +667,23 @@ export class Act {
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
|
||||||
|
// Add new entry to workspace history
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.path].push({
|
||||||
|
index: historyIndex,
|
||||||
|
count: count,
|
||||||
|
name: `${commandArgs.name}`,
|
||||||
|
status: HistoryStatus.Running,
|
||||||
|
date: {
|
||||||
|
start: start.toString()
|
||||||
|
},
|
||||||
|
taskExecution: taskExecution,
|
||||||
|
commandArgs: commandArgs,
|
||||||
|
logPath: logPath,
|
||||||
|
jobs: []
|
||||||
|
});
|
||||||
|
historyTreeDataProvider.refresh();
|
||||||
|
await this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
async install(packageManager: string) {
|
async install(packageManager: string) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TaskExecution, Uri, window, workspace, WorkspaceFolder } from "vscode";
|
import { TaskExecution, ThemeColor, ThemeIcon, Uri, window, workspace, WorkspaceFolder } from "vscode";
|
||||||
import { CommandArgs } from "./act";
|
import { CommandArgs } from "./act";
|
||||||
import { act, historyTreeDataProvider } from "./extension";
|
import { act, historyTreeDataProvider } from "./extension";
|
||||||
import { StorageKey, StorageManager } from "./storageManager";
|
import { StorageKey, StorageManager } from "./storageManager";
|
||||||
@@ -12,16 +12,38 @@ export interface History {
|
|||||||
start: string,
|
start: string,
|
||||||
end?: string,
|
end?: string,
|
||||||
},
|
},
|
||||||
taskExecution?: TaskExecution,
|
|
||||||
commandArgs: CommandArgs,
|
commandArgs: CommandArgs,
|
||||||
logPath: string
|
logPath: string,
|
||||||
|
taskExecution?: TaskExecution,
|
||||||
|
jobs?: Job[],
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Job {
|
||||||
|
name: string,
|
||||||
|
status: HistoryStatus,
|
||||||
|
date: {
|
||||||
|
start: string,
|
||||||
|
end?: string,
|
||||||
|
},
|
||||||
|
steps?: Step[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Step {
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
status: HistoryStatus,
|
||||||
|
date: {
|
||||||
|
start: string,
|
||||||
|
end?: string,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum HistoryStatus {
|
export enum HistoryStatus {
|
||||||
Running = 'Running',
|
Running = 'Running',
|
||||||
Success = 'Success',
|
Success = 'Success',
|
||||||
Failed = 'Failed',
|
Failed = 'Failed',
|
||||||
Cancelled = 'Cancelled'
|
Cancelled = 'Cancelled',
|
||||||
|
Unknown = 'Unknown'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HistoryManager {
|
export class HistoryManager {
|
||||||
@@ -33,6 +55,21 @@ export class HistoryManager {
|
|||||||
const workspaceHistory = this.storageManager.get<{ [path: string]: History[] }>(StorageKey.WorkspaceHistory) || {};
|
const workspaceHistory = this.storageManager.get<{ [path: string]: History[] }>(StorageKey.WorkspaceHistory) || {};
|
||||||
for (const [path, historyLogs] of Object.entries(workspaceHistory)) {
|
for (const [path, historyLogs] of Object.entries(workspaceHistory)) {
|
||||||
workspaceHistory[path] = historyLogs.map(history => {
|
workspaceHistory[path] = historyLogs.map(history => {
|
||||||
|
history.jobs?.forEach((job, jobIndex) => {
|
||||||
|
history.jobs![jobIndex].steps?.forEach((step, stepIndex) => {
|
||||||
|
// Update status of all running steps
|
||||||
|
if (step.status === HistoryStatus.Running) {
|
||||||
|
history.jobs![jobIndex].steps![stepIndex].status = HistoryStatus.Cancelled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update status of all running jobs
|
||||||
|
if (job.status === HistoryStatus.Running) {
|
||||||
|
history.jobs![jobIndex].status = HistoryStatus.Cancelled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update history status
|
||||||
if (history.status === HistoryStatus.Running) {
|
if (history.status === HistoryStatus.Running) {
|
||||||
history.status = HistoryStatus.Cancelled;
|
history.status = HistoryStatus.Cancelled;
|
||||||
}
|
}
|
||||||
@@ -53,7 +90,7 @@ export class HistoryManager {
|
|||||||
|
|
||||||
this.workspaceHistory[workspaceFolder.uri.fsPath] = [];
|
this.workspaceHistory[workspaceFolder.uri.fsPath] = [];
|
||||||
historyTreeDataProvider.refresh();
|
historyTreeDataProvider.refresh();
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.workspaceHistory);
|
await this.storageManager.update(StorageKey.WorkspaceHistory, this.workspaceHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
async viewOutput(history: History) {
|
async viewOutput(history: History) {
|
||||||
@@ -77,11 +114,26 @@ export class HistoryManager {
|
|||||||
const historyIndex = this.workspaceHistory[history.commandArgs.path].findIndex(workspaceHistory => workspaceHistory.index === history.index);
|
const historyIndex = this.workspaceHistory[history.commandArgs.path].findIndex(workspaceHistory => workspaceHistory.index === history.index);
|
||||||
if (historyIndex > -1) {
|
if (historyIndex > -1) {
|
||||||
this.workspaceHistory[history.commandArgs.path].splice(historyIndex, 1);
|
this.workspaceHistory[history.commandArgs.path].splice(historyIndex, 1);
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.workspaceHistory);
|
await this.storageManager.update(StorageKey.WorkspaceHistory, this.workspaceHistory);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await workspace.fs.delete(Uri.file(history.logPath));
|
await workspace.fs.delete(Uri.file(history.logPath));
|
||||||
} catch (error: any) { }
|
} catch (error: any) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static statusToIcon(status: HistoryStatus) {
|
||||||
|
switch (status) {
|
||||||
|
case HistoryStatus.Running:
|
||||||
|
return new ThemeIcon('loading~spin');
|
||||||
|
case HistoryStatus.Success:
|
||||||
|
return new ThemeIcon('pass', new ThemeColor('GitHubLocalActions.green'));
|
||||||
|
case HistoryStatus.Failed:
|
||||||
|
return new ThemeIcon('error', new ThemeColor('GitHubLocalActions.red'));
|
||||||
|
case HistoryStatus.Cancelled:
|
||||||
|
return new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow'));
|
||||||
|
case HistoryStatus.Unknown:
|
||||||
|
return new ThemeIcon('question', new ThemeColor('GitHubLocalActions.purple'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ export interface Settings {
|
|||||||
runners: Setting[];
|
runners: Setting[];
|
||||||
payloadFiles: CustomSetting[];
|
payloadFiles: CustomSetting[];
|
||||||
options: CustomSetting[];
|
options: CustomSetting[];
|
||||||
environments: Setting[];
|
// environments: Setting[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Setting {
|
export interface Setting {
|
||||||
@@ -74,7 +74,7 @@ export class SettingsManager {
|
|||||||
const runners = (await this.getSetting(workspaceFolder, SettingsManager.runnersRegExp, StorageKey.Runners, false, Visibility.show)).filter(runner => !isUserSelected || (runner.selected && runner.value));
|
const runners = (await this.getSetting(workspaceFolder, SettingsManager.runnersRegExp, StorageKey.Runners, false, Visibility.show)).filter(runner => !isUserSelected || (runner.selected && runner.value));
|
||||||
const payloadFiles = (await this.getCustomSettings(workspaceFolder, StorageKey.PayloadFiles)).filter(payloadFile => !isUserSelected || payloadFile.selected);
|
const payloadFiles = (await this.getCustomSettings(workspaceFolder, StorageKey.PayloadFiles)).filter(payloadFile => !isUserSelected || payloadFile.selected);
|
||||||
const options = (await this.getCustomSettings(workspaceFolder, StorageKey.Options)).filter(option => !isUserSelected || (option.selected && (option.path || option.notEditable)));
|
const options = (await this.getCustomSettings(workspaceFolder, StorageKey.Options)).filter(option => !isUserSelected || (option.selected && (option.path || option.notEditable)));
|
||||||
const environments = await this.getEnvironments(workspaceFolder);
|
// const environments = await this.getEnvironments(workspaceFolder);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
secrets: secrets,
|
secrets: secrets,
|
||||||
@@ -86,7 +86,7 @@ export class SettingsManager {
|
|||||||
runners: runners,
|
runners: runners,
|
||||||
payloadFiles: payloadFiles,
|
payloadFiles: payloadFiles,
|
||||||
options: options,
|
options: options,
|
||||||
environments: environments
|
// environments: environments
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ export class SettingsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
existingSettings[workspaceFolder.uri.fsPath] = settings;
|
existingSettings[workspaceFolder.uri.fsPath] = settings;
|
||||||
this.storageManager.update(storageKey, existingSettings);
|
await this.storageManager.update(storageKey, existingSettings);
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
import { TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||||
import { History, HistoryStatus } from "../../historyManager";
|
import { History, HistoryManager, HistoryStatus } from "../../historyManager";
|
||||||
import { Utils } from "../../utils";
|
import { Utils } from "../../utils";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
import JobTreeItem from "./job";
|
||||||
|
|
||||||
export default class HistoryTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
export default class HistoryTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
static contextValue = 'githubLocalActions.history';
|
static contextValue = 'githubLocalActions.history';
|
||||||
history: History;
|
history: History;
|
||||||
|
|
||||||
constructor(public workspaceFolder: WorkspaceFolder, history: History) {
|
constructor(public workspaceFolder: WorkspaceFolder, history: History) {
|
||||||
super(`${history.name} #${history.count}`, TreeItemCollapsibleState.None);
|
super(`${history.name} #${history.count}`, TreeItemCollapsibleState.Collapsed);
|
||||||
this.history = history;
|
this.history = history;
|
||||||
|
|
||||||
let endTime: string | undefined;
|
let endTime: string | undefined;
|
||||||
@@ -24,20 +25,7 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
|
|
||||||
this.description = totalDuration;
|
this.description = totalDuration;
|
||||||
this.contextValue = `${HistoryTreeItem.contextValue}_${history.status}`;
|
this.contextValue = `${HistoryTreeItem.contextValue}_${history.status}`;
|
||||||
switch (history.status) {
|
this.iconPath = HistoryManager.statusToIcon(history.status);
|
||||||
case HistoryStatus.Running:
|
|
||||||
this.iconPath = new ThemeIcon('loading~spin');
|
|
||||||
break;
|
|
||||||
case HistoryStatus.Success:
|
|
||||||
this.iconPath = new ThemeIcon('pass', new ThemeColor('GitHubLocalActions.green'));
|
|
||||||
break;
|
|
||||||
case HistoryStatus.Failed:
|
|
||||||
this.iconPath = new ThemeIcon('error', new ThemeColor('GitHubLocalActions.red'));
|
|
||||||
break;
|
|
||||||
case HistoryStatus.Cancelled:
|
|
||||||
this.iconPath = new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow'));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.tooltip = `Name: ${history.name} #${history.count}\n` +
|
this.tooltip = `Name: ${history.name} #${history.count}\n` +
|
||||||
`${history.commandArgs.extraHeader.map(header => `${header.key}: ${header.value}`).join('\n')}\n` +
|
`${history.commandArgs.extraHeader.map(header => `${header.key}: ${header.value}`).join('\n')}\n` +
|
||||||
`Path: ${history.commandArgs.path}\n` +
|
`Path: ${history.commandArgs.path}\n` +
|
||||||
@@ -46,14 +34,9 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
|
|||||||
`Started: ${Utils.getDateString(history.date.start)}\n` +
|
`Started: ${Utils.getDateString(history.date.start)}\n` +
|
||||||
`Ended: ${endTime ? Utils.getDateString(endTime) : 'N/A'}\n` +
|
`Ended: ${endTime ? Utils.getDateString(endTime) : 'N/A'}\n` +
|
||||||
`Total Duration: ${totalDuration ? totalDuration : 'N/A'}`;
|
`Total Duration: ${totalDuration ? totalDuration : 'N/A'}`;
|
||||||
this.command = {
|
|
||||||
title: 'Focus Task',
|
|
||||||
command: 'githubLocalActions.focusTask',
|
|
||||||
arguments: [this]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
return [];
|
return this.history.jobs?.map(job => new JobTreeItem(this.workspaceFolder, job)) || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,15 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
|
|||||||
for (const terminal of terminals) {
|
for (const terminal of terminals) {
|
||||||
if (terminal.creationOptions.name === `${historyTreeItem.history.name} #${historyTreeItem.history.count}`) {
|
if (terminal.creationOptions.name === `${historyTreeItem.history.name} #${historyTreeItem.history.count}`) {
|
||||||
terminal.show();
|
terminal.show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.showErrorMessage(`${historyTreeItem.history.name} #${historyTreeItem.history.count} task is no longer open.`, 'View Output').then(async value => {
|
||||||
|
if (value === 'View Output') {
|
||||||
|
await commands.executeCommand('githubLocalActions.viewOutput', historyTreeItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
commands.registerCommand('githubLocalActions.viewOutput', async (historyTreeItem: HistoryTreeItem) => {
|
commands.registerCommand('githubLocalActions.viewOutput', async (historyTreeItem: HistoryTreeItem) => {
|
||||||
await act.historyManager.viewOutput(historyTreeItem.history);
|
await act.historyManager.viewOutput(historyTreeItem.history);
|
||||||
|
|||||||
38
src/views/history/job.ts
Normal file
38
src/views/history/job.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||||
|
import { HistoryManager, HistoryStatus, Job } from "../../historyManager";
|
||||||
|
import { Utils } from "../../utils";
|
||||||
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
import StepTreeItem from "./step";
|
||||||
|
|
||||||
|
export default class JobTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
|
static contextValue = 'githubLocalActions.job';
|
||||||
|
job: Job;
|
||||||
|
|
||||||
|
constructor(public workspaceFolder: WorkspaceFolder, job: Job) {
|
||||||
|
super(job.name, TreeItemCollapsibleState.Expanded);
|
||||||
|
this.job = job;
|
||||||
|
|
||||||
|
let endTime: string | undefined;
|
||||||
|
let totalDuration: string | undefined;
|
||||||
|
if (job.date.end) {
|
||||||
|
endTime = job.date.end;
|
||||||
|
totalDuration = Utils.getTimeDuration(job.date.start, endTime);
|
||||||
|
} else if (job.status === HistoryStatus.Running) {
|
||||||
|
endTime = new Date().toString();
|
||||||
|
totalDuration = Utils.getTimeDuration(job.date.start, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.description = totalDuration;
|
||||||
|
this.contextValue = `${JobTreeItem.contextValue}_${job.status}`;
|
||||||
|
this.iconPath = HistoryManager.statusToIcon(job.status);
|
||||||
|
this.tooltip = `Name: ${job.name}\n` +
|
||||||
|
`Status: ${job.status}\n` +
|
||||||
|
`Started: ${Utils.getDateString(job.date.start)}\n` +
|
||||||
|
`Ended: ${endTime ? Utils.getDateString(endTime) : 'N/A'}\n` +
|
||||||
|
`Total Duration: ${totalDuration ? totalDuration : 'N/A'}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
return this.job.steps?.map(step => new StepTreeItem(this.workspaceFolder, step)) || [];
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/views/history/step.ts
Normal file
37
src/views/history/step.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||||
|
import { HistoryManager, HistoryStatus, Step } from "../../historyManager";
|
||||||
|
import { Utils } from "../../utils";
|
||||||
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
|
|
||||||
|
export default class StepTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||||
|
static contextValue = 'githubLocalActions.step';
|
||||||
|
step: Step;
|
||||||
|
|
||||||
|
constructor(public workspaceFolder: WorkspaceFolder, step: Step) {
|
||||||
|
super(step.name, TreeItemCollapsibleState.None);
|
||||||
|
this.step = step;
|
||||||
|
|
||||||
|
let endTime: string | undefined;
|
||||||
|
let totalDuration: string | undefined;
|
||||||
|
if (step.date.end) {
|
||||||
|
endTime = step.date.end;
|
||||||
|
totalDuration = Utils.getTimeDuration(step.date.start, endTime);
|
||||||
|
} else if (step.status === HistoryStatus.Running) {
|
||||||
|
endTime = new Date().toString();
|
||||||
|
totalDuration = Utils.getTimeDuration(step.date.start, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.description = totalDuration;
|
||||||
|
this.contextValue = `${StepTreeItem.contextValue}_${step.status}`;
|
||||||
|
this.iconPath = HistoryManager.statusToIcon(step.status);
|
||||||
|
this.tooltip = `Name: ${step.name}\n` +
|
||||||
|
`Status: ${step.status}\n` +
|
||||||
|
`Started: ${Utils.getDateString(step.date.start)}\n` +
|
||||||
|
`Ended: ${endTime ? Utils.getDateString(endTime) : 'N/A'}\n` +
|
||||||
|
`Total Duration: ${totalDuration ? totalDuration : 'N/A'}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -307,9 +307,9 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
];
|
];
|
||||||
|
|
||||||
options.forEach((option, index) => {
|
options.forEach((option, index) => {
|
||||||
options[index].label = options[index].label.slice(2)
|
options[index].label = options[index].label.slice(2);
|
||||||
options[index].iconPath = new ThemeIcon('symbol-property');
|
options[index].iconPath = new ThemeIcon('symbol-property');
|
||||||
})
|
});
|
||||||
|
|
||||||
const settings = await act.settingsManager.getSettings(optionsTreeItem.workspaceFolder, false);
|
const settings = await act.settingsManager.getSettings(optionsTreeItem.workspaceFolder, false);
|
||||||
const optionNames = settings.options.map(option => option.name);
|
const optionNames = settings.options.map(option => option.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user