Skip to content

Commit

Permalink
Merge pull request #85 from SanjulaGanepola/fix/build-output-retrieval
Browse files Browse the repository at this point in the history
Remove use of `pipefail`, switch to use `CustomExecution`, add decoration for unset settings
  • Loading branch information
SanjulaGanepola authored Nov 27, 2024
2 parents 9ab84de + fbd551a commit 1c1925d
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 107 deletions.
233 changes: 153 additions & 80 deletions src/act.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/componentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ export class ComponentsManager {

if (selectedPrebuiltExecutable) {
await env.openExternal(Uri.parse(selectedPrebuiltExecutable.link));
window.showInformationMessage('Unpack and run the executable in the terminal specifying the full path or add it to one of the paths in your PATH environment variable. Once nektos/act is successfully installed, refresh the components view.', 'Refresh').then(async value => {
window.showInformationMessage('Unpack the executable and move it to your desired location. Once nektos/act is successfully installed, add it to your shell\'s PATH and then refresh the components view.', 'Refresh').then(async value => {
if (value === 'Refresh') {
componentsTreeDataProvider.refresh();
}
});
}
} else if (selectedInstallationMethod.link) {
await env.openExternal(Uri.parse(selectedInstallationMethod.link));
window.showInformationMessage('Once nektos/act is successfully installed, refresh the components view.', 'Refresh').then(async value => {
window.showInformationMessage('Once nektos/act is successfully installed, add it to your shell\'s PATH and then refresh the components view.', 'Refresh').then(async value => {
if (value === 'Refresh') {
componentsTreeDataProvider.refresh();
}
Expand Down Expand Up @@ -162,7 +162,7 @@ export class ComponentsManager {
problemMatchers: [],
runOptions: {},
group: TaskGroup.Build,
execution: new ShellExecution('sudo dockerd')
execution: new ShellExecution('sudo dockerd', { executable: env.shell })
});
} else {
window.showErrorMessage(`Invalid environment: ${process.platform}`, 'Report an Issue').then(async value => {
Expand Down
8 changes: 4 additions & 4 deletions src/settingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class SettingsManager {
}

async getSettings(workspaceFolder: WorkspaceFolder, isUserSelected: boolean): Promise<Settings> {
const secrets = (await this.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true, Visibility.hide)).filter(secret => !isUserSelected || secret.selected);
const secrets = (await this.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true, Visibility.hide)).filter(secret => !isUserSelected || (secret.selected && secret.value));
const secretFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.SecretFiles)).filter(secretFile => !isUserSelected || secretFile.selected);
const variables = (await this.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false, Visibility.show)).filter(variable => !isUserSelected || variable.selected);
const variables = (await this.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false, Visibility.show)).filter(variable => !isUserSelected || (variable.selected && variable.value));
const variableFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.VariableFiles)).filter(variableFile => !isUserSelected || variableFile.selected);
const inputs = (await this.getSetting(workspaceFolder, SettingsManager.inputsRegExp, StorageKey.Inputs, false, Visibility.show)).filter(input => !isUserSelected || (input.selected && input.value));
const inputFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.InputFiles)).filter(inputFile => !isUserSelected || inputFile.selected);
Expand Down Expand Up @@ -164,15 +164,15 @@ export class SettingsManager {
return environments;
}

async createSettingFile(workspaceFolder: WorkspaceFolder, storageKey: StorageKey, settingFileName: string) {
async createSettingFile(workspaceFolder: WorkspaceFolder, storageKey: StorageKey, settingFileName: string, content: string) {
const settingFileUri = Uri.file(path.join(workspaceFolder.uri.fsPath, settingFileName));

try {
await workspace.fs.stat(settingFileUri);
window.showErrorMessage(`A file or folder named ${settingFileName} already exists at ${workspaceFolder.uri.fsPath}. Please choose another name.`);
} catch (error: any) {
try {
await workspace.fs.writeFile(settingFileUri, new TextEncoder().encode(''));
await workspace.fs.writeFile(settingFileUri, new TextEncoder().encode(content));
await this.locateSettingFile(workspaceFolder, storageKey, [settingFileUri]);
const document = await workspace.openTextDocument(settingFileUri);
await window.showTextDocument(document);
Expand Down
29 changes: 22 additions & 7 deletions src/views/decorationProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { CancellationToken, Event, FileDecoration, FileDecorationProvider, ProviderResult, ThemeColor, Uri } from "vscode";
import { CliStatus, ExtensionStatus } from "../componentsManager";
import ComponentTreeItem from "./components/component";
import InputsTreeItem from "./settings/inputs";
import RunnersTreeItem from "./settings/runners";
import SecretsTreeItem from "./settings/secrets";
import { SettingContextValue } from "./settings/setting";
import VariablesTreeItem from "./settings/variables";
import WorkflowTreeItem from "./workflows/workflow";

export class DecorationProvider implements FileDecorationProvider {
Expand Down Expand Up @@ -37,14 +42,24 @@ export class DecorationProvider implements FileDecorationProvider {
color: new ThemeColor('GitHubLocalActions.red')
};
}
}
} else if ([SecretsTreeItem.contextValue, VariablesTreeItem.contextValue, InputsTreeItem.contextValue, RunnersTreeItem.contextValue].includes(uri.scheme)) {
const hasAllValues = params.get('hasAllValues') === 'true';

// else if (uri.scheme === SecretsTreeItem.contextValue || uri.scheme === VariablesTreeItem.contextValue || uri.scheme === InputsTreeItem.contextValue || uri.scheme === RunnersTreeItem.contextValue) {
// const selected = params.get('selected');
if (!hasAllValues) {
return {
color: new ThemeColor('GitHubLocalActions.red')
};
}
} else if (Object.values(SettingContextValue).includes(uri.scheme as any)) {
const isSelected = params.get('isSelected') === 'true';
const hasValue = params.get('hasValue') === 'true';

// return {
// badge: `${selected}`
// };
// }
if (isSelected && !hasValue) {
return {
badge: '?',
color: new ThemeColor('GitHubLocalActions.red')
};
}
}
}
}
4 changes: 3 additions & 1 deletion src/views/settings/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
import { act } from "../../extension";
import { Setting, SettingFile } from "../../settingsManager";
import { StorageKey } from "../../storageManager";
Expand All @@ -17,6 +17,8 @@ export default class InputsTreeItem extends TreeItem implements GithubLocalActio
(selectedInputFiles.length > 0 ? ` + ${selectedInputFiles[0].name}` : ``);
this.contextValue = InputsTreeItem.contextValue;
this.iconPath = new ThemeIcon('record-keys');
const hasAllValues = inputs.filter(input => input.selected && input.value === '').length === 0;
this.resourceUri = Uri.parse(`${InputsTreeItem.contextValue}:Inputs?hasAllValues=${hasAllValues}`, true);
}

async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
Expand Down
4 changes: 3 additions & 1 deletion src/views/settings/runners.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
import { act } from "../../extension";
import { Setting } from "../../settingsManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
Expand All @@ -12,6 +12,8 @@ export default class RunnersTreeItem extends TreeItem implements GithubLocalActi
this.description = `${runners.filter(runner => runner.selected).length}/${runners.length}`;
this.contextValue = RunnersTreeItem.contextValue;
this.iconPath = new ThemeIcon('server-environment');
const hasAllValues = runners.filter(runner => runner.selected && runner.value === '').length === 0;
this.resourceUri = Uri.parse(`${RunnersTreeItem.contextValue}:Runners?hasAllValues=${hasAllValues}`, true);
}

async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
Expand Down
4 changes: 3 additions & 1 deletion src/views/settings/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
import { act } from "../../extension";
import { Setting, SettingFile } from "../../settingsManager";
import { StorageKey } from "../../storageManager";
Expand All @@ -17,6 +17,8 @@ export default class SecretsTreeItem extends TreeItem implements GithubLocalActi
(selectedSecretFiles.length > 0 ? ` + ${selectedSecretFiles[0].name}` : ``);
this.contextValue = SecretsTreeItem.contextValue;
this.iconPath = new ThemeIcon('lock');
const hasAllValues = secrets.filter(secret => secret.selected && secret.value === '').length === 0;
this.resourceUri = Uri.parse(`${SecretsTreeItem.contextValue}:Secrets?hasAllValues=${hasAllValues}`, true);
}

async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
Expand Down
18 changes: 13 additions & 5 deletions src/views/settings/setting.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
import { Setting, Visibility } from "../../settingsManager";
import { StorageKey } from "../../storageManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";

export enum SettingContextValue {
secret = 'githubLocalActions.secret',
variable = 'githubLocalActions.variable',
input = 'githubLocalActions.input',
runner = 'githubLocalActions.runner'
}

export default class SettingTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
setting: Setting;
storageKey: StorageKey;
Expand All @@ -19,6 +26,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
this.contextValue = `${treeItem.contextValue}_${setting.password ? setting.visible : ''}`;
this.iconPath = treeItem.iconPath;
this.checkboxState = setting.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
this.resourceUri = Uri.parse(`${treeItem.contextValue}:${setting.key}?isSelected=${setting.selected}&hasValue=${setting.value !== ''}`, true);
}

static getSecretTreeItem(workspaceFolder: WorkspaceFolder, secret: Setting): SettingTreeItem {
Expand All @@ -27,7 +35,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
secret,
StorageKey.Secrets,
{
contextValue: 'githubLocalActions.secret',
contextValue: SettingContextValue.secret,
iconPath: new ThemeIcon('key')
}
);
Expand All @@ -39,7 +47,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
variable,
StorageKey.Variables,
{
contextValue: 'githubLocalActions.variable',
contextValue: SettingContextValue.variable,
iconPath: new ThemeIcon('symbol-variable')
}
);
Expand All @@ -51,7 +59,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
input,
StorageKey.Inputs,
{
contextValue: 'githubLocalActions.input',
contextValue: SettingContextValue.input,
iconPath: new ThemeIcon('symbol-parameter')
}
);
Expand All @@ -63,7 +71,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
runner,
StorageKey.Runners,
{
contextValue: 'githubLocalActions.runner',
contextValue: SettingContextValue.runner,
iconPath: new ThemeIcon('vm-connect')
}
);
Expand Down
8 changes: 4 additions & 4 deletions src/views/settings/settingsTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
});

if (secretFileName) {
await act.settingsManager.createSettingFile(secretsTreeItem.workspaceFolder, secretsTreeItem.storageKey, secretFileName);
await act.settingsManager.createSettingFile(secretsTreeItem.workspaceFolder, secretsTreeItem.storageKey, secretFileName, '');
this.refresh();
}
}),
Expand All @@ -55,7 +55,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
});

if (variableFileName) {
await act.settingsManager.createSettingFile(variablesTreeItem.workspaceFolder, variablesTreeItem.storageKey, variableFileName);
await act.settingsManager.createSettingFile(variablesTreeItem.workspaceFolder, variablesTreeItem.storageKey, variableFileName, '');
this.refresh();
}
}),
Expand All @@ -81,7 +81,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
});

if (inputFileName) {
await act.settingsManager.createSettingFile(inputsTreeItem.workspaceFolder, inputsTreeItem.storageKey, inputFileName);
await act.settingsManager.createSettingFile(inputsTreeItem.workspaceFolder, inputsTreeItem.storageKey, inputFileName, '');
this.refresh();
}
}),
Expand All @@ -107,7 +107,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
});

if (payloadFileName) {
await act.settingsManager.createSettingFile(payloadsTreeItem.workspaceFolder, payloadsTreeItem.storageKey, payloadFileName);
await act.settingsManager.createSettingFile(payloadsTreeItem.workspaceFolder, payloadsTreeItem.storageKey, payloadFileName, '{}');
this.refresh();
}
}),
Expand Down
4 changes: 3 additions & 1 deletion src/views/settings/variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
import { act } from "../../extension";
import { Setting, SettingFile } from "../../settingsManager";
import { StorageKey } from "../../storageManager";
Expand All @@ -17,6 +17,8 @@ export default class VariablesTreeItem extends TreeItem implements GithubLocalAc
(selectedVariableFiles.length > 0 ? ` + ${selectedVariableFiles[0].name}` : ``);
this.contextValue = VariablesTreeItem.contextValue;
this.iconPath = new ThemeIcon('symbol-key');
const hasAllValues = variables.filter(variable => variable.selected && variable.value === '').length === 0;
this.resourceUri = Uri.parse(`${VariablesTreeItem.contextValue}:Variables?hasAllValues=${hasAllValues}`, true);
}

async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
Expand Down

0 comments on commit 1c1925d

Please sign in to comment.