Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding github actions for CI. #19

Merged
merged 9 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: lint
run-name: Installs project and runs linting
on: [ push, pull_request ]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 18 ]
name: Linting on Ubuntu with Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run lint
17 changes: 17 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: prettier
run-name: Installs project and runs prettier checks
on: [ push, pull_request ]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 18 ]
name: Prettier on Ubuntu with Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run prettier:verify
29 changes: 29 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: run-tests
run-name: Installs project and runs project tests
on: [ push, pull_request ]
jobs:
run-tests-nix:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 18 ]
name: Tests on Ubuntu with Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run compile
run-tests-win:
runs-on: windows-latest
strategy:
matrix:
node: [ 16, 18 ]
name: Tests on Windows with Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"prettier:write": "prettier --write \"src/**/*.{ts, js}\"",
"prettier:verify": "prettier --list-different \"src/**/*.{ts, js}\"",
"genl10n": "vscode-l10n-dev export ./src"
"prettier:verify": "prettier --list-different \"src/**/*.{ts, js}\""
},
"devDependencies": {
"@types/glob": "^8.1.0",
Expand Down
26 changes: 19 additions & 7 deletions src/commands/landingPageCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class LandingPageCommand {
*/
static async configureRecordListCard(uem: UEMBuilder): Promise<UEMBuilder> {
const selectedItem = await UIUtils.showQuickPick(
l10n.t('Select which sObject you want to display on the Record List.'),
l10n.t(
'Select which sObject you want to display on the Record List.'
),
l10n.t('Retrieving sObjects from your org, please wait...'),
() => {
return new Promise<QuickPickItem[]>(async (resolve, reject) => {
Expand Down Expand Up @@ -110,13 +112,15 @@ export class LandingPageCommand {

const finishedOption: QuickPickItem = {
label: l10n.t('-- Finished --'),
detail: l10n.t('I don\'t want any more fields to be displayed.')
detail: l10n.t("I don't want any more fields to be displayed.")
};

// Prompt user for up to 3 fields. The first request we will retrieve the fields and show a progress
// message
const selectedFieldPickItem1 = await UIUtils.showQuickPick(
l10n.t('Select which field you want to display as the primary field.'),
l10n.t(
'Select which field you want to display as the primary field.'
),
l10n.t('Retrieving list of fields for sObject.'),
() => {
return new Promise<QuickPickItem[]>(async (resolve, reject) => {
Expand All @@ -142,7 +146,9 @@ export class LandingPageCommand {

// get optional field 2 -- do not show a progress message.
const selectedFieldPickItem2 = await UIUtils.showQuickPick(
l10n.t('Select which field you want to display as the second field (or Finished to skip).'),
l10n.t(
'Select which field you want to display as the second field (or Finished to skip).'
),
undefined,
() => {
return new Promise<QuickPickItem[]>(async (resolve, reject) => {
Expand All @@ -165,7 +171,9 @@ export class LandingPageCommand {
let selectedFieldPickItem3: QuickPickItem;
if (selectedFieldPickItem2.label !== finishedOption.label) {
selectedFieldPickItem3 = await UIUtils.showQuickPick(
l10n.t('Select which field you want to display as the third field (or Finished to skip).'),
l10n.t(
'Select which field you want to display as the third field (or Finished to skip).'
),
undefined,
() => {
return new Promise<QuickPickItem[]>(
Expand Down Expand Up @@ -218,15 +226,19 @@ export class LandingPageCommand {
const cardTypes: QuickPickItem[] = [
{
label: `${LandingPageCommand.GLOBAL_ACTIONS_CARD_LABEL}`,
description: l10n.t('A card showing the LWC Global Quick Actions defined in the org.')
description: l10n.t(
'A card showing the LWC Global Quick Actions defined in the org.'
)
},
{
label: `${LandingPageCommand.RECORD_LIST_CARD_LABEL}`,
description: l10n.t('A card showing a list of records.')
},
{
label: `${LandingPageCommand.TIMED_LIST_CARD_LABEL}`,
description: l10n.t('A card showing a list of records filtered and sorted by a date/time range.')
description: l10n.t(
'A card showing a list of records filtered and sorted by a date/time range.'
)
},
{
label: '',
Expand Down
4 changes: 3 additions & 1 deletion src/commands/templateChooserCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export class TemplateChooserCommand {
},
{
label: l10n.t('Retail Execution'),
detail: l10n.t('Global quick actions with new Opportunity, new Lead, and more.'),
detail: l10n.t(
'Global quick actions with new Opportunity, new Lead, and more.'
),
filename: 'landing_page_retail_execution.json'
}
];
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/orgUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ suite('Org Utils Test Suite', () => {
const reloadSpy = sinon.spy(() => {
return Promise.resolve;
});

const config: SinonStub = sinon.stub(ConfigAggregator, 'create');
config.returns({
getInfo: (key: OrgConfigProperties) => {
Expand All @@ -87,7 +87,7 @@ suite('Org Utils Test Suite', () => {
const defaultUser = await OrgUtils.getDefaultUser();

assert.equal(defaultUser, 'username');
assert.equal(reloadSpy.called, true, "reload should be invoked");
assert.equal(reloadSpy.called, true, 'reload should be invoked');
});

test('Returns list of sobjects', async () => {
Expand Down
23 changes: 11 additions & 12 deletions src/test/suite/webviews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { afterEach, beforeEach } from 'mocha';
import * as fs from 'fs';

suite('InstructionsWebviewProvider Test Suite', () => {
const extensionUri = Uri.parse("file:///tmp/testdir");
const extensionUri = Uri.parse('file:///tmp/testdir');

beforeEach(function () {});

Expand All @@ -22,29 +22,28 @@ suite('InstructionsWebviewProvider Test Suite', () => {
});

test('Locale-specific file is returned if it exists', async () => {
const languageStub = sinon.stub(env, "language");
languageStub.value("es");
const languageStub = sinon.stub(env, 'language');
languageStub.value('es');

const fsExistStub = sinon.stub(fs, "existsSync");
const fsExistStub = sinon.stub(fs, 'existsSync');
fsExistStub.returns(true);

const provider = new InstructionsWebviewProvider(extensionUri);
const path = provider.getLocaleContentPath(extensionUri, "test.html");
const path = provider.getLocaleContentPath(extensionUri, 'test.html');

assert.equal(path, "test.es.html");
assert.equal(path, 'test.es.html');
});

test('Defaults to english file if locale-specific file does not exist.', async () => {
const languageStub = sinon.stub(env, "language");
languageStub.value("es");
const languageStub = sinon.stub(env, 'language');
languageStub.value('es');

const fsExistStub = sinon.stub(fs, "existsSync");
const fsExistStub = sinon.stub(fs, 'existsSync');
fsExistStub.returns(false);

const provider = new InstructionsWebviewProvider(extensionUri);
const path = provider.getLocaleContentPath(extensionUri, "test.html");
const path = provider.getLocaleContentPath(extensionUri, 'test.html');

assert.equal(path, "test.html");
assert.equal(path, 'test.html');
});

});
8 changes: 4 additions & 4 deletions src/utils/uemBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class UEMBuilder {
// TODO: Create a typed data structure for this instead of any
private cards: any[] = [];

static readonly valueTypes = [
static readonly VALUE_TYPES = [
'Int',
'String',
'Boolean',
Expand All @@ -40,10 +40,10 @@ export class UEMBuilder {
'Base64'
];

static readonly defaultValueType = 'StringValue';
static readonly DEFAULT_VALUE_TYPE = 'StringValue';

private getFieldType(field: Field): string {
const t = UEMBuilder.valueTypes.find(
const t = UEMBuilder.VALUE_TYPES.find(
(t) => t.toLowerCase() === field.type.toLowerCase()
);

Expand All @@ -52,7 +52,7 @@ export class UEMBuilder {
}

// default
return UEMBuilder.defaultValueType;
return UEMBuilder.DEFAULT_VALUE_TYPE;
}

addGlobalActionCard(): UEMBuilder {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/uiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { window, QuickPickItem, QuickPickItemKind, QuickPick } from 'vscode';
export class UIUtils {
/**
* Wraps the ability to ask user for a selection from a quick pick list.
*
*
* @param placeholderMessage Message shown to user in the quick pick text entry box.
* @param progressMessage Message shown while the quick pick is shown, but is not yet enabled due
* @param progressMessage Message shown while the quick pick is shown, but is not yet enabled due
* to building a list of options via the callback.
* @param optionsCallback Callback used to provide an array of QuickPickItems.
* @param ignoreFocusOut Boolean for the ignoreFocusOut option on QuickPick.
Expand All @@ -40,13 +40,13 @@ export class UIUtils {
if (selectedItem) {
resolve(selectedItem);
} else {
reject("Nothing selected");
reject('Nothing selected');
}
});

quickPick.onDidHide((e) => {
quickPick.dispose();
reject("Hiding");
reject('Hiding');
});

if (progressMessage) {
Expand Down
5 changes: 4 additions & 1 deletion src/webviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export class InstructionsWebviewProvider {
this.extensionUri,
contentPath
);
const htmlPath = vscode.Uri.joinPath(this.extensionUri, localeContentPath);
const htmlPath = vscode.Uri.joinPath(
this.extensionUri,
localeContentPath
);
const messagingJsPath = vscode.Uri.joinPath(
this.extensionUri,
MESSAGING_JS_PATH
Expand Down