Skip to content

Commit a931106

Browse files
Crystal Tennlrotschy
andcommitted
wip to be able to open a web page with the specific step
Co-authored-by: Liela Rotschy <lrotschy@github.com>
1 parent 08c7fbf commit a931106

2 files changed

Lines changed: 21 additions & 47 deletions

File tree

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,7 @@
152152
"category": "GitHub Actions",
153153
"title": "View logs",
154154
"when": "viewItem =~ /step/",
155-
"icon": {
156-
"dark": "resources/icons/dark/logs.svg",
157-
"light": "resources/icons/light/logs.svg"
158-
}
155+
"icon": "$(globe)"
159156
},
160157
{
161158
"command": "github-actions.workflow.run.rerun",
Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,32 @@
11
import * as vscode from "vscode";
2+
import {WorkflowJob, WorkflowRun} from "../model";
23
import {GitHubRepoContext} from "../git/repository";
3-
import {updateDecorations} from "../logs/formatProvider";
4-
import {getLogInfo} from "../logs/logInfo";
5-
import {buildLogURI} from "../logs/scheme";
6-
import {WorkflowJob} from "../store/WorkflowJob";
7-
import { WorkflowStep } from "../model";
4+
import {integer} from "vscode-languageclient";
5+
import {WorkflowRunCommandArgs, WorkflowRunNode} from "../treeViews/shared/workflowRunNode";
6+
import {WorkflowJobNode} from "../treeViews/shared/workflowJobNode";
87

9-
export interface OpenWorkflowStepLogsCommandArgs {
10-
gitHubRepoContext: GitHubRepoContext;
11-
job: WorkflowJob;
12-
step: WorkflowStep;
13-
}
8+
// export interface OpenWorkflowStepLogsCommandArgs {
9+
// gitHubRepoContext: GitHubRepoContext;
10+
// job: WorkflowJob;
11+
// run: WorkflowRun;
12+
// }
13+
14+
export type WorkflowStepCommandArgs = Pick<WorkflowJobNode, "job">;
1415

1516
export function registerOpenWorkflowStepLogs(context: vscode.ExtensionContext) {
1617
context.subscriptions.push(
17-
vscode.commands.registerCommand("github-actions.step.logs", async (args: OpenWorkflowStepLogsCommandArgs) => {
18-
const gitHubRepoContext = args.gitHubRepoContext;
19-
const job = args.job;
20-
const step = args.step;
18+
vscode.commands.registerCommand("github-actions.step.logs", async (args: WorkflowStepCommandArgs) => {
19+
const job = args.job.job;
20+
let url = job.html_url ?? "";
21+
const stepName = args.step.name;
2122

22-
const uri = buildLogURI(
23-
`%23${job.job.run_id} - ${job.job.name}`,
24-
gitHubRepoContext.owner,
25-
gitHubRepoContext.name,
26-
job.job.id
27-
);
23+
const index = job.steps && job.steps.findIndex(step => step.name === stepName) + 1;
2824

29-
const doc = await vscode.workspace.openTextDocument(uri);
30-
const editor = await vscode.window.showTextDocument(doc, {
31-
preview: false
32-
});
33-
34-
const logInfo = getLogInfo(uri);
35-
if (!logInfo) {
36-
throw new Error("Could not get log info");
25+
if (url && index) {
26+
url = url + "#step:" + index.toString() + ":1";
3727
}
3828

39-
const section = logInfo.sections.find(s => s.name === step.name);
40-
const startLine = section ? section.start : 0;
41-
const endLine = section ? section.end : 0;
42-
43-
44-
const stepInfo = {
45-
updatedLogLines: logInfo["updatedLogLines"].slice(startLine, endLine),
46-
sections: logInfo["sections"].filter(s => s.name === step.name),
47-
styleFormats: logInfo["styleFormats"].filter(s => s.line >= startLine && s.line <= endLine)
48-
};
49-
50-
51-
// Custom formatting after the editor has been opened
52-
updateDecorations(editor, stepInfo);
29+
await vscode.env.openExternal(vscode.Uri.parse(url));
5330
})
5431
);
55-
}
32+
}

0 commit comments

Comments
 (0)