Commit e2b69b04 authored by Ivan Mazhukin's avatar Ivan Mazhukin

add parallel run action and systems picker

parent 1f8ce112
...@@ -36,6 +36,7 @@ The same VSIX can be installed from the VS Code command `Extensions: Install fro ...@@ -36,6 +36,7 @@ The same VSIX can be installed from the VS Code command `Extensions: Install fro
## Actions ## Actions
- `Run app on systems`: asks for an app and target systems. - `Run app on systems`: asks for an app and target systems.
- `Run app on systems parallel`: asks for an app and target systems, then passes `--parallel`.
- `Run app preset`: asks for an app and `main`, `russian`, or `all`. - `Run app preset`: asks for an app and `main`, `russian`, or `all`.
- `Run exec command`: asks for a shell command and target systems or preset. - `Run exec command`: asks for a shell command and target systems or preset.
- `./bin/epm play <app>`: runs a local play command outside Docker. - `./bin/epm play <app>`: runs a local play command outside Docker.
......
...@@ -25,7 +25,8 @@ function activate(context) { ...@@ -25,7 +25,8 @@ function activate(context) {
context.subscriptions.push( context.subscriptions.push(
status, status,
vscode.commands.registerCommand('epmDockerTest.runQuick', runQuick), vscode.commands.registerCommand('epmDockerTest.runQuick', runQuick),
vscode.commands.registerCommand('epmDockerTest.runApp', runApp), vscode.commands.registerCommand('epmDockerTest.runApp', () => runApp(false)),
vscode.commands.registerCommand('epmDockerTest.runAppParallel', () => runApp(true)),
vscode.commands.registerCommand('epmDockerTest.runPreset', runPreset), vscode.commands.registerCommand('epmDockerTest.runPreset', runPreset),
vscode.commands.registerCommand('epmDockerTest.runExec', runExec), vscode.commands.registerCommand('epmDockerTest.runExec', runExec),
vscode.commands.registerCommand('epmDockerTest.runLocalPlay', () => runLocalPlay(false)), vscode.commands.registerCommand('epmDockerTest.runLocalPlay', () => runLocalPlay(false)),
...@@ -78,6 +79,7 @@ class ActionsProvider { ...@@ -78,6 +79,7 @@ class ActionsProvider {
const builtIns = [ const builtIns = [
commandItem('Run app on systems', 'epmDockerTest.runApp', undefined, new vscode.ThemeIcon('run')), commandItem('Run app on systems', 'epmDockerTest.runApp', undefined, new vscode.ThemeIcon('run')),
commandItem('Run app on systems parallel', 'epmDockerTest.runAppParallel', undefined, new vscode.ThemeIcon('run-all')),
commandItem('Run app preset', 'epmDockerTest.runPreset', undefined, new vscode.ThemeIcon('list-selection')), commandItem('Run app preset', 'epmDockerTest.runPreset', undefined, new vscode.ThemeIcon('list-selection')),
commandItem('Run exec command', 'epmDockerTest.runExec', undefined, new vscode.ThemeIcon('terminal')), commandItem('Run exec command', 'epmDockerTest.runExec', undefined, new vscode.ThemeIcon('terminal')),
separatorItem('Local EPM'), separatorItem('Local EPM'),
...@@ -113,6 +115,7 @@ function separatorItem(label) { ...@@ -113,6 +115,7 @@ function separatorItem(label) {
async function runQuick() { async function runQuick() {
const choice = await vscode.window.showQuickPick([ const choice = await vscode.window.showQuickPick([
{ label: '$(run) Run app on systems', command: 'epmDockerTest.runApp' }, { label: '$(run) Run app on systems', command: 'epmDockerTest.runApp' },
{ label: '$(run-all) Run app on systems parallel', command: 'epmDockerTest.runAppParallel' },
{ label: '$(list-selection) Run app preset', command: 'epmDockerTest.runPreset' }, { label: '$(list-selection) Run app preset', command: 'epmDockerTest.runPreset' },
{ label: '$(terminal) Run exec command', command: 'epmDockerTest.runExec' }, { label: '$(terminal) Run exec command', command: 'epmDockerTest.runExec' },
{ label: '$(play) Local ./bin/epm play', command: 'epmDockerTest.runLocalPlay' }, { label: '$(play) Local ./bin/epm play', command: 'epmDockerTest.runLocalPlay' },
...@@ -128,9 +131,9 @@ async function runQuick() { ...@@ -128,9 +131,9 @@ async function runQuick() {
} }
} }
async function runApp() { async function runApp(parallel) {
const app = await promptForApp({ const app = await promptForApp({
title: 'EPM Docker Test', title: parallel ? 'EPM Docker Test Parallel' : 'EPM Docker Test',
prompt: 'Application name for epm play', prompt: 'Application name for epm play',
fallbackKey: 'lastApp' fallbackKey: 'lastApp'
}); });
...@@ -138,10 +141,10 @@ async function runApp() { ...@@ -138,10 +141,10 @@ async function runApp() {
return; return;
} }
const systems = await vscode.window.showInputBox({ const systems = await promptForSystems({
title: 'EPM Docker Test', title: parallel ? 'EPM Docker Test Parallel' : 'EPM Docker Test',
prompt: 'Target systems separated by spaces', prompt: 'Target systems separated by spaces',
value: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora')) fallback: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora'))
}); });
if (!systems) { if (!systems) {
return; return;
...@@ -149,7 +152,7 @@ async function runApp() { ...@@ -149,7 +152,7 @@ async function runApp() {
await setWorkspaceState('lastApp', app); await setWorkspaceState('lastApp', app);
await setWorkspaceState('lastSystems', systems); await setWorkspaceState('lastSystems', systems);
await executeTest({ app, systems: splitArgs(systems) }); await executeTest({ app, systems: splitArgs(systems), parallel });
} }
async function runPreset() { async function runPreset() {
...@@ -203,10 +206,10 @@ async function runExec() { ...@@ -203,10 +206,10 @@ async function runExec() {
return; return;
} }
const systems = await vscode.window.showInputBox({ const systems = await promptForSystems({
title: 'EPM Docker Test', title: 'EPM Docker Test',
prompt: 'Target systems separated by spaces', prompt: 'Target systems separated by spaces',
value: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora')) fallback: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora'))
}); });
if (systems) { if (systems) {
await setWorkspaceState('lastSystems', systems); await setWorkspaceState('lastSystems', systems);
...@@ -323,6 +326,64 @@ function promptForInferredApp(options, inferred) { ...@@ -323,6 +326,64 @@ function promptForInferredApp(options, inferred) {
}); });
} }
function promptForSystems(options) {
return promptForEditableValue({
title: options.title,
prompt: options.prompt,
value: options.fallback,
fallback: 'fedora',
okLabel: 'OK',
cancelLabel: 'Отмена'
});
}
function promptForEditableValue(options) {
return new Promise((resolve) => {
const quickPick = vscode.window.createQuickPick();
const okItem = { label: '', action: 'ok' };
const cancelItem = { label: `$(close) ${options.cancelLabel}`, action: 'cancel' };
let settled = false;
const finish = (value) => {
if (settled) {
return;
}
settled = true;
resolve(value);
};
const currentValue = () => quickPick.value.trim() || options.fallback;
const updateOkItem = () => {
okItem.label = `$(check) ${options.okLabel}: ${currentValue()}`;
quickPick.items = [okItem, cancelItem];
};
quickPick.title = options.title;
quickPick.placeholder = options.prompt;
quickPick.value = options.value || options.fallback;
updateOkItem();
quickPick.onDidChangeValue(updateOkItem);
quickPick.onDidAccept(() => {
const selected = quickPick.selectedItems[0];
if (selected?.action === 'cancel') {
quickPick.hide();
finish(undefined);
return;
}
quickPick.hide();
finish(currentValue());
});
quickPick.onDidHide(() => {
quickPick.dispose();
finish(undefined);
});
quickPick.show();
});
}
async function rerunLast() { async function rerunLast() {
const command = getWorkspaceState('lastCommand', lastRun); const command = getWorkspaceState('lastCommand', lastRun);
if (!command) { if (!command) {
...@@ -368,6 +429,9 @@ async function executeTest(request) { ...@@ -368,6 +429,9 @@ async function executeTest(request) {
if (Array.isArray(request.favoriteArgs)) { if (Array.isArray(request.favoriteArgs)) {
args.push(...request.favoriteArgs); args.push(...request.favoriteArgs);
} }
if (request.parallel && !args.includes('--parallel') && !args.includes('-j')) {
args.push('--parallel');
}
if (request.exec) { if (request.exec) {
args.push('--exec', request.exec); args.push('--exec', request.exec);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"onView:epmDockerTest.actions", "onView:epmDockerTest.actions",
"onCommand:epmDockerTest.runQuick", "onCommand:epmDockerTest.runQuick",
"onCommand:epmDockerTest.runApp", "onCommand:epmDockerTest.runApp",
"onCommand:epmDockerTest.runAppParallel",
"onCommand:epmDockerTest.runPreset", "onCommand:epmDockerTest.runPreset",
"onCommand:epmDockerTest.runExec", "onCommand:epmDockerTest.runExec",
"onCommand:epmDockerTest.rerunLast", "onCommand:epmDockerTest.rerunLast",
...@@ -33,6 +34,10 @@ ...@@ -33,6 +34,10 @@
"title": "EPM Docker Test: Run App on Systems" "title": "EPM Docker Test: Run App on Systems"
}, },
{ {
"command": "epmDockerTest.runAppParallel",
"title": "EPM Docker Test: Run App on Systems in Parallel"
},
{
"command": "epmDockerTest.runPreset", "command": "epmDockerTest.runPreset",
"title": "EPM Docker Test: Run App Preset" "title": "EPM Docker Test: Run App Preset"
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment