Skip to content

Commit

Permalink
Add GitHub Action to build PR (#345)
Browse files Browse the repository at this point in the history
* Add GitHub Action to build PR

Signed-off-by: Yevhen Vydolob <[email protected]>

* add message to assert

Signed-off-by: Yevhen Vydolob <[email protected]>

* fix paths

Signed-off-by: Yevhen Vydolob <[email protected]>

* fix path

Signed-off-by: Yevhen Vydolob <[email protected]>

* Fix test

Signed-off-by: Yevhen Vydolob <[email protected]>
  • Loading branch information
evidolob authored Aug 20, 2020
1 parent 2a394cc commit 35d8383
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a basic workflow

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [master]
pull_request:
branches: [master]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Set up Node
- name: Use Node 12
uses: actions/setup-node@v1
with:
node-version: 12

# Run install dependencies
- name: Install dependencies
run: npm install

# Build extension
- name: Run build
run: npm run build

# Run tests
- name: Run Test
uses: GabrielBB/[email protected]
with:
run: npm test
8 changes: 4 additions & 4 deletions test/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode';
import { getDocUri, activate, testCompletion, updateSettings, testCompletionNotEmpty, resetSettings, sleep } from './helper';
import { getDocUri, activate, testCompletion, updateSettings, testCompletionNotEmpty, resetSettings } from './helper';
import * as path from 'path';

describe('Completion should work in multiple different scenarios', () => {
const docUri = getDocUri('completion/completion.yaml');
const travisUri = getDocUri('completion/.travis.yml');
const docUri = getDocUri(path.join('completion', 'completion.yaml'));
const travisUri = getDocUri(path.join('completion', '.travis.yml'));

afterEach(async () => {
await resetSettings('schemas', {});
Expand All @@ -20,7 +20,7 @@ describe('Completion should work in multiple different scenarios', () => {
await activate(docUri);
const schemaPath = path.join(__dirname, '..', '..', 'test', 'testFixture', 'schemas', 'basic_completion_schema.json');
await updateSettings('schemas', {
[schemaPath]: 'completion.yaml',
[vscode.Uri.file(schemaPath).toString()]: 'completion.yaml',
});
await testCompletion(docUri, new vscode.Position(0, 0), {
items: [
Expand Down
10 changes: 7 additions & 3 deletions test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function sleep(ms: number) {
}

export const getDocPath = (p: string) => {
return path.resolve(__dirname, '../../test/testFixture', p);
return path.resolve(__dirname, path.join('..', '..', 'test', 'testFixture', p));
};

export const getDocUri = (p: string) => {
Expand All @@ -61,7 +61,7 @@ export async function testCompletion(
docUri: vscode.Uri,
position: vscode.Position,
expectedCompletionList: vscode.CompletionList
) {
): Promise<void> {
// Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion
const actualCompletionList = (await vscode.commands.executeCommand(
'vscode.executeCompletionItemProvider',
Expand All @@ -70,7 +70,11 @@ export async function testCompletion(
)) as vscode.CompletionList;

const sortedActualCompletionList = actualCompletionList.items.sort((a, b) => (a.label > b.label ? 1 : -1));
assert.equal(actualCompletionList.items.length, expectedCompletionList.items.length);
assert.equal(
actualCompletionList.items.length,
expectedCompletionList.items.length,
"Completion List doesn't have expected size"
);
expectedCompletionList.items
.sort((a, b) => (a.label > b.label ? 1 : -1))
.forEach((expectedItem, i) => {
Expand Down

0 comments on commit 35d8383

Please sign in to comment.