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
## Actions
- `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 exec command`: asks for a shell command and target systems or preset.
- `./bin/epm play <app>`: runs a local play command outside Docker.
......
......@@ -25,7 +25,8 @@ function activate(context) {
context.subscriptions.push(
status,
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.runExec', runExec),
vscode.commands.registerCommand('epmDockerTest.runLocalPlay', () => runLocalPlay(false)),
......@@ -78,6 +79,7 @@ class ActionsProvider {
const builtIns = [
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 exec command', 'epmDockerTest.runExec', undefined, new vscode.ThemeIcon('terminal')),
separatorItem('Local EPM'),
......@@ -113,6 +115,7 @@ function separatorItem(label) {
async function runQuick() {
const choice = await vscode.window.showQuickPick([
{ 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: '$(terminal) Run exec command', command: 'epmDockerTest.runExec' },
{ label: '$(play) Local ./bin/epm play', command: 'epmDockerTest.runLocalPlay' },
......@@ -128,9 +131,9 @@ async function runQuick() {
}
}
async function runApp() {
async function runApp(parallel) {
const app = await promptForApp({
title: 'EPM Docker Test',
title: parallel ? 'EPM Docker Test Parallel' : 'EPM Docker Test',
prompt: 'Application name for epm play',
fallbackKey: 'lastApp'
});
......@@ -138,10 +141,10 @@ async function runApp() {
return;
}
const systems = await vscode.window.showInputBox({
title: 'EPM Docker Test',
const systems = await promptForSystems({
title: parallel ? 'EPM Docker Test Parallel' : 'EPM Docker Test',
prompt: 'Target systems separated by spaces',
value: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora'))
fallback: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora'))
});
if (!systems) {
return;
......@@ -149,7 +152,7 @@ async function runApp() {
await setWorkspaceState('lastApp', app);
await setWorkspaceState('lastSystems', systems);
await executeTest({ app, systems: splitArgs(systems) });
await executeTest({ app, systems: splitArgs(systems), parallel });
}
async function runPreset() {
......@@ -203,10 +206,10 @@ async function runExec() {
return;
}
const systems = await vscode.window.showInputBox({
const systems = await promptForSystems({
title: 'EPM Docker Test',
prompt: 'Target systems separated by spaces',
value: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora'))
fallback: getWorkspaceState('lastSystems', getConfig().get('defaultSystems', 'fedora'))
});
if (systems) {
await setWorkspaceState('lastSystems', systems);
......@@ -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() {
const command = getWorkspaceState('lastCommand', lastRun);
if (!command) {
......@@ -368,6 +429,9 @@ async function executeTest(request) {
if (Array.isArray(request.favoriteArgs)) {
args.push(...request.favoriteArgs);
}
if (request.parallel && !args.includes('--parallel') && !args.includes('-j')) {
args.push('--parallel');
}
if (request.exec) {
args.push('--exec', request.exec);
......
......@@ -15,6 +15,7 @@
"onView:epmDockerTest.actions",
"onCommand:epmDockerTest.runQuick",
"onCommand:epmDockerTest.runApp",
"onCommand:epmDockerTest.runAppParallel",
"onCommand:epmDockerTest.runPreset",
"onCommand:epmDockerTest.runExec",
"onCommand:epmDockerTest.rerunLast",
......@@ -33,6 +34,10 @@
"title": "EPM Docker Test: Run App on Systems"
},
{
"command": "epmDockerTest.runAppParallel",
"title": "EPM Docker Test: Run App on Systems in Parallel"
},
{
"command": "epmDockerTest.runPreset",
"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