Skip to content

Commit 7dc3149

Browse files
authored
Merge pull request #601 from github/debugger
Port the debugger into main
2 parents 4c2cccf + 87c9b28 commit 7dc3149

10 files changed

Lines changed: 957 additions & 4 deletions

File tree

package-lock.json

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"activationEvents": [
2626
"onView:workflows",
2727
"onView:settings",
28+
"onDebugResolve:github-actions-job",
29+
"onCommand:github-actions.debugger.connect",
2830
"workspaceContains:**/.github/workflows/**",
2931
"workspaceContains:**/action.yml",
3032
"workspaceContains:**/action.yaml"
@@ -97,7 +99,19 @@
9799
}
98100
}
99101
},
102+
"debuggers": [
103+
{
104+
"type": "github-actions-job",
105+
"label": "GitHub Actions Job Debugger",
106+
"languages": []
107+
}
108+
],
100109
"commands": [
110+
{
111+
"command": "github-actions.debugger.connect",
112+
"category": "GitHub Actions",
113+
"title": "Debug Running Job…"
114+
},
101115
{
102116
"command": "github-actions.explorer.refresh",
103117
"category": "GitHub Actions",
@@ -521,6 +535,10 @@
521535
{
522536
"command": "github-actions.sign-in",
523537
"when": "false"
538+
},
539+
{
540+
"command": "github-actions.debugger.connect",
541+
"when": "config.github-actions.debugger.enabled && !isWeb"
524542
}
525543
]
526544
}
@@ -544,6 +562,7 @@
544562
"@types/libsodium-wrappers": "^0.7.10",
545563
"@types/uuid": "^3.4.6",
546564
"@types/vscode": "^1.72.0",
565+
"@types/ws": "^8.18.1",
547566
"@typescript-eslint/eslint-plugin": "^5.40.0",
548567
"@typescript-eslint/parser": "^5.40.0",
549568
"@vscode/test-web": "^0.0.69",
@@ -579,7 +598,8 @@
579598
"tunnel": "0.0.6",
580599
"util": "^0.12.1",
581600
"uuid": "^3.3.3",
582-
"vscode-languageclient": "^8.0.2"
601+
"vscode-languageclient": "^8.0.2",
602+
"ws": "^8.20.0"
583603
},
584604
"overrides": {
585605
"browserify-sign": {

src/configuration/configuration.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ import {resetGitHubContext} from "../git/repository";
44

55
const settingsKey = "github-actions";
66
const DEFAULT_GITHUB_API = "https://api.github.com";
7+
const reloadWindowAction = "Reload Window";
8+
const debuggerEnabledSettingsKey = getSettingsKey("debugger.enabled");
9+
10+
let debuggerSettingReloadPromptVisible = false;
711

812
export function initConfiguration(context: vscode.ExtensionContext) {
913
context.subscriptions.push(
1014
vscode.workspace.onDidChangeConfiguration(async e => {
1115
if (e.affectsConfiguration(getSettingsKey("workflows.pinned"))) {
1216
pinnedWorkflowsChangeHandlers.forEach(h => h());
13-
} else if (
17+
}
18+
19+
if (
1420
e.affectsConfiguration(getSettingsKey("use-enterprise")) ||
1521
(useEnterprise() &&
1622
(e.affectsConfiguration("github-enterprise.uri") || e.affectsConfiguration(getSettingsKey("remote-name"))))
@@ -19,6 +25,10 @@ export function initConfiguration(context: vscode.ExtensionContext) {
1925
resetGitHubContext();
2026
await vscode.commands.executeCommand("github-actions.explorer.refresh");
2127
}
28+
29+
if (e.affectsConfiguration(debuggerEnabledSettingsKey)) {
30+
await promptToReloadForDebuggerSettingChange(context);
31+
}
2232
})
2333
);
2434
}
@@ -64,6 +74,10 @@ export function getRemoteName(): string {
6474
return getConfiguration().get<string>(getSettingsKey("remote-name"), "origin");
6575
}
6676

77+
export function isDebuggerEnabled(): boolean {
78+
return getConfiguration().get<boolean>(debuggerEnabledSettingsKey, false);
79+
}
80+
6781
export function useEnterprise(): boolean {
6882
return getConfiguration().get<boolean>(getSettingsKey("use-enterprise"), false);
6983
}
@@ -87,3 +101,35 @@ async function updateLanguageServerApiUrl(context: vscode.ExtensionContext) {
87101

88102
await initLanguageServer(context);
89103
}
104+
105+
async function promptToReloadForDebuggerSettingChange(context: vscode.ExtensionContext) {
106+
if (vscode.env.uiKind !== vscode.UIKind.Desktop) {
107+
return;
108+
}
109+
110+
if (debuggerSettingReloadPromptVisible) {
111+
return;
112+
}
113+
114+
debuggerSettingReloadPromptVisible = true;
115+
116+
try {
117+
if (context.extensionMode !== vscode.ExtensionMode.Production) {
118+
await vscode.window.showInformationMessage(
119+
"Reload VS Code manually to apply the GitHub Actions debugger preview setting change. Automatic reload is disabled in the Extension Development Host."
120+
);
121+
return;
122+
}
123+
124+
const selection = await vscode.window.showInformationMessage(
125+
"Reload VS Code to apply the GitHub Actions debugger preview setting change.",
126+
reloadWindowAction
127+
);
128+
129+
if (selection === reloadWindowAction) {
130+
await vscode.commands.executeCommand("workbench.action.reloadWindow");
131+
}
132+
} finally {
133+
debuggerSettingReloadPromptVisible = false;
134+
}
135+
}

0 commit comments

Comments
 (0)