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

Add GitHub Action to build PR #345

Merged
merged 5 commits into from
Aug 20, 2020
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
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