Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ef09e29

Browse files
committed
Add tests to CI job
1 parent 0f7db9e commit ef09e29

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

.github/workflows/main.yml

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
11
name: Main
22
on:
3-
- push
4-
- pull_request_target
3+
- push
4+
- pull_request_target
55
jobs:
66
ci:
77
name: CI
8-
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
os:
11+
- macos-latest
12+
- ubuntu-latest
13+
- windows-latest
14+
ruby:
15+
- 3.1
16+
- 3.0
17+
- 2.7
18+
runs-on: ${{ matrix.os }}
919
env:
1020
CI: true
1121
steps:
12-
- uses: actions/checkout@master
13-
- uses: actions/setup-node@v3
14-
with:
15-
node-version: 14.x
16-
cache: yarn
17-
- name: Compile
18-
run: |
19-
yarn install --frozen-lockfile
20-
yarn compile
22+
- uses: actions/checkout@master
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: 14.x
26+
cache: yarn
27+
- uses: ruby/setup-ruby@v1
28+
with:
29+
bundler-cache: true
30+
ruby-version: ${{ matrix.ruby }}
31+
- name: Compile extension
32+
run: |
33+
yarn install --frozen-lockfile
34+
yarn compile
35+
- name: Install gem
36+
run: gem install syntax_tree
37+
- name: Run tests
38+
run: xvfb-run -a npm test
39+
if: runner.os == 'Linux'
40+
- name: Run tests
41+
run: npm test
42+
if: runner.os != 'Linux'
2143
automerge:
2244
name: AutoMerge
2345
needs: ci
2446
runs-on: ubuntu-latest
2547
if: github.event_name == 'pull_request_target' && (github.actor == github.repository_owner || github.actor == 'dependabot[bot]')
2648
steps:
27-
- uses: actions/github-script@v6
28-
with:
29-
script: |
30-
github.pulls.merge({
31-
owner: context.payload.repository.owner.login,
32-
repo: context.payload.repository.name,
33-
pull_number: context.payload.pull_request.number
34-
})
49+
- uses: actions/github-script@v6
50+
with:
51+
script: |
52+
github.pulls.merge({
53+
owner: context.payload.repository.owner.login,
54+
repo: context.payload.repository.name,
55+
pull_number: context.payload.pull_request.number
56+
})

src/test/suite/automation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { Uri, commands, window, workspace } from 'vscode';
1010
// but we need somewhere to put temp files.
1111
const WORKSPACE_FOLDER = fs.mkdtempSync(`${os.tmpdir()}${path.sep}vscode-syntax-tree-`);
1212

13+
export async function startExtension() {
14+
await commands.executeCommand('syntaxTree.start');
15+
}
16+
1317
export async function closeAll() {
1418
while (window.activeTextEditor) {
1519
await commands.executeCommand('workbench.action.closeActiveEditor');
@@ -21,6 +25,7 @@ export async function createEditor(content: string, filename = 'test.rb') {
2125
await workspace.fs.writeFile(uri, new TextEncoder().encode(content));
2226
await window.showTextDocument(uri);
2327
assert.ok(window.activeTextEditor);
28+
assert.equal(window.activeTextEditor.document.getText(), content);
2429
return window.activeTextEditor;
2530
}
2631

src/test/suite/index.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as assert from 'assert';
2+
import { before, beforeEach } from 'mocha';
23

34
import * as auto from './automation';
45

@@ -15,6 +16,7 @@ end
1516
`;
1617

1718
suite('Syntax Tree', () => {
19+
before(auto.startExtension);
1820
test('Format Document', async () => {
1921
await auto.closeAll();
2022
const editor = await auto.createEditor(UNFORMATTED);

0 commit comments

Comments
 (0)