File size: 5,004 Bytes
ebffcb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
# DO NOT TOUCH — Managed by doc writer
ContentId: 891072bb-c46d-4392-800a-84d747072ce3
DateApproved: 3/7/2019

# Summarize the whole topic in less than 300 characters for SEO purpose
MetaDescription: Use Continuous Integration for testing Visual Studio Code extensions (plug-ins).
---

# Continuous Integration

Extension tests can be run on CI services. The `vscode` npm module provides a built-in command (`bin/test`) which:

1. Downloads and unzips VS Code;
2. Launches your extension tests inside VS Code;
3. Prints the results to the console and exits with an appropriate status code.

The command will expose some optional environment variables, which you can use to customize the build:

| Name                      | Description                                                                                    |
| ------------------------- | ---------------------------------------------------------------------------------------------- |
| `CODE_VERSION`            | Version of VS Code to run the tests against (e.g. `0.10.10`)                                   |
| `CODE_DOWNLOAD_URL`       | Full URL of a VS Code drop to use for running tests against                                    |
| `CODE_TESTS_PATH`         | Location of the tests to execute (default is `process.cwd()/out/test` or `process.cwd()/test`) |
| `CODE_EXTENSIONS_PATH`    | Location of the extensions to load (default is `process.cwd()`)                                |
| `CODE_TESTS_WORKSPACE`    | Location of a workspace to open for the test instance (default is CODE_TESTS_PATH)             |
| `CODE_LOCALE`             | Display language to use when running the tests (default is English)                            |
| `CODE_DISABLE_EXTENSIONS` | Disable all other extensions except the one that is being tested                               |
| `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 |

## Azure Pipelines

<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>

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.

After registering and creating your new project, simply add the following `build.yml` to the root of your extension's repository:

```yaml
jobs:
  - job: Windows
    pool:
      name: Hosted VS2017
      demands: npm
    steps:
      - task: NodeTool@0
        displayName: 'Use Node 8.x'
        inputs:
          versionSpec: 8.x
      - task: Npm@1
        displayName: 'Install dependencies'
        inputs:
          verbose: false
      - task: Npm@1
        displayName: 'Compile sources'
        inputs:
          command: custom
          verbose: false
          customCommand: 'run compile'
      - script: 'node node_modules/vscode/bin/test'
        displayName: 'Run tests'
  - job: macOS
    pool:
      name: Hosted macOS
      demands: npm
    steps:
      - task: NodeTool@0
        displayName: 'Use Node 8.x'
        inputs:
          versionSpec: 8.x
      - task: Npm@1
        displayName: 'Install dependencies'
        inputs:
          verbose: false
      - task: Npm@1
        displayName: 'Compile sources'
        inputs:
          command: custom
          verbose: false
          customCommand: 'run compile'
      - script: 'node node_modules/vscode/bin/test'
        displayName: 'Run tests'
  - job: Linux
    pool:
      name: Hosted Ubuntu 1604
      demands: npm
    steps:
      - task: NodeTool@0
        displayName: 'Use Node 8.x'
        inputs:
          versionSpec: 8.x
      - task: Npm@1
        displayName: 'Install dependencies'
        inputs:
          verbose: false
      - task: Npm@1
        displayName: 'Compile sources'
        inputs:
          command: custom
          verbose: false
          customCommand: 'run compile'
      - script: |
          set -e
          /usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
          disown -ar
        displayName: 'Start xvfb'
      - script: 'node node_modules/vscode/bin/test'
        displayName: 'Run tests'
        env:
          DISPLAY: :10
```

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à:

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

You can enable the build to run continuously when pushing to a branch and even on pull requests. [Click here](https://docs.microsoft.com/azure/devops/pipelines/build/triggers) to learn more.