Skip to content

Commit 5812632

Browse files
authored
Merge pull request #2695 from microsoft/octref/vscode-test
vscode-test related updates
2 parents db73221 + 96d9e78 commit 5812632

8 files changed

Lines changed: 233 additions & 153 deletions

File tree

api/working-with-extensions/continuous-integration.md

Lines changed: 40 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -9,108 +9,57 @@ MetaDescription: Use Continuous Integration for testing Visual Studio Code exten
99

1010
# Continuous Integration
1111

12-
Extension tests can be run on CI services. The `vscode` npm module provides a built-in command (`bin/test`) which:
13-
14-
1. Downloads and unzips VS Code;
15-
2. Launches your extension tests inside VS Code;
16-
3. Prints the results to the console and exits with an appropriate status code.
17-
18-
The command will expose some optional environment variables, which you can use to customize the build:
19-
20-
| Name | Description |
21-
| ------------------------- | ---------------------------------------------------------------------------------------------- |
22-
| `CODE_VERSION` | Version of VS Code to run the tests against (e.g. `0.10.10`) |
23-
| `CODE_DOWNLOAD_URL` | Full URL of a VS Code drop to use for running tests against |
24-
| `CODE_TESTS_PATH` | Location of the tests to execute (default is `process.cwd()/out/test` or `process.cwd()/test`) |
25-
| `CODE_EXTENSIONS_PATH` | Location of the extensions to load (default is `process.cwd()`) |
26-
| `CODE_TESTS_WORKSPACE` | Location of a workspace to open for the test instance (default is CODE_TESTS_PATH) |
27-
| `CODE_LOCALE` | Display language to use when running the tests (default is English) |
28-
| `CODE_DISABLE_EXTENSIONS` | Disable all other extensions except the one that is being tested |
29-
| `CODE_TESTS_DATA_DIR` | Allows to specify the user-data-dir for the tests to use and thus enables to run multiple tests at the same time |
12+
Extension tests can be run on CI services. The `vscode-test` repository itself contains a sample extension that is tested on Azure Devops Pipelines. You can check out the [build pipeline](https://dev.azure.com/vscode/VSCode/_build?definitionId=14) or jump directly to the [build definition yaml file](https://github.com/microsoft/vscode-test/blob/master/sample/azure-pipelines.yml).
3013

3114
## Azure Pipelines
3215

3316
<a href="https://azure.microsoft.com/services/devops/"><img alt="Azure Pipelines" src="/assets/api/working-with-extensions/continuous-integration/pipelines-logo.png" width="318" /></a>
3417

3518
You can create free projects on [Azure DevOps](https://azure.microsoft.com/services/devops/). This gives you source code hosting, planning boards, building and testing infrastructure, and more. On top of that, you get [10 free parallel jobs](https://azure.microsoft.com/services/devops/pipelines/) for building your projects across all 3 major platforms: Windows, macOS and Linux.
3619

37-
After registering and creating your new project, simply add the following `build.yml` to the root of your extension's repository:
20+
After registering and creating your new project, simply add the following `azure-pipelines.yml` to the root of your extension's repository. Other than the xvfb setup for Linux, the definition is straight-forward:
3821

3922
```yaml
40-
jobs:
41-
- job: Windows
42-
pool:
43-
name: Hosted VS2017
44-
demands: npm
45-
steps:
46-
- task: NodeTool@0
47-
displayName: 'Use Node 8.x'
48-
inputs:
49-
versionSpec: 8.x
50-
- task: Npm@1
51-
displayName: 'Install dependencies'
52-
inputs:
53-
verbose: false
54-
- task: Npm@1
55-
displayName: 'Compile sources'
56-
inputs:
57-
command: custom
58-
verbose: false
59-
customCommand: 'run compile'
60-
- script: 'node node_modules/vscode/bin/test'
61-
displayName: 'Run tests'
62-
- job: macOS
63-
pool:
64-
name: Hosted macOS
65-
demands: npm
66-
steps:
67-
- task: NodeTool@0
68-
displayName: 'Use Node 8.x'
69-
inputs:
70-
versionSpec: 8.x
71-
- task: Npm@1
72-
displayName: 'Install dependencies'
73-
inputs:
74-
verbose: false
75-
- task: Npm@1
76-
displayName: 'Compile sources'
77-
inputs:
78-
command: custom
79-
verbose: false
80-
customCommand: 'run compile'
81-
- script: 'node node_modules/vscode/bin/test'
82-
displayName: 'Run tests'
83-
- job: Linux
84-
pool:
85-
name: Hosted Ubuntu 1604
86-
demands: npm
87-
steps:
88-
- task: NodeTool@0
89-
displayName: 'Use Node 8.x'
90-
inputs:
91-
versionSpec: 8.x
92-
- task: Npm@1
93-
displayName: 'Install dependencies'
94-
inputs:
95-
verbose: false
96-
- task: Npm@1
97-
displayName: 'Compile sources'
98-
inputs:
99-
command: custom
100-
verbose: false
101-
customCommand: 'run compile'
102-
- script: |
103-
set -e
104-
/usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
105-
disown -ar
106-
displayName: 'Start xvfb'
107-
- script: 'node node_modules/vscode/bin/test'
108-
displayName: 'Run tests'
109-
env:
110-
DISPLAY: :10
23+
trigger:
24+
- master
25+
26+
strategy:
27+
matrix:
28+
linux:
29+
imageName: 'ubuntu-16.04'
30+
mac:
31+
imageName: 'macos-10.13'
32+
windows:
33+
imageName: 'vs2017-win2016'
34+
35+
pool:
36+
vmImage: $(imageName)
37+
38+
steps:
39+
40+
- task: NodeTool@0
41+
inputs:
42+
versionSpec: '8.x'
43+
displayName: 'Install Node.js'
44+
45+
- bash: |
46+
set -e
47+
/usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
48+
disown -ar
49+
echo "Started xvfb"
50+
displayName: Start xvfb
51+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
52+
53+
- bash: |
54+
# vscode-test has its extension located at /sample
55+
cd sample
56+
yarn && yarn compile && yarn test
57+
displayName: Run Tests
58+
env:
59+
DISPLAY: :10
11160
```
11261
113-
Next [create a new Pipeline](https://docs.microsoft.com/azure/devops/pipelines/get-started-yaml?view=vsts#get-your-first-build) in your DevOps project and point it to the `build.yml` file. Trigger a build and voilà:
62+
Next [create a new Pipeline](https://docs.microsoft.com/azure/devops/pipelines/get-started-yaml?view=vsts#get-your-first-build) in your DevOps project and point it to the `azure-pipelines.yml` file. Trigger a build and voilà:
11463

11564
![pipelines](images/continuous-integration/pipelines.png)
11665

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:9c0d2a0a11a60cd6db74a2e53fc657c2fcfddeef14589b579cccc65d90cca6ab
3+
size 415650

api/working-with-extensions/images/testing-extension/launch-tests.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

api/working-with-extensions/images/testing-extension/pipelines-logo.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

api/working-with-extensions/images/testing-extension/pipelines.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

api/working-with-extensions/images/testing-extension/test-output.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)