forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
487 lines (408 loc) · 18.7 KB
/
ci.yml
File metadata and controls
487 lines (408 loc) · 18.7 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
name: CI
on:
push:
branches:
# Run the CI workflow only on master for microsoft/vscode-python for now.
- master
env:
PYTHON_VERSION: 3.8
CACHE_NPM_DEPS: cache-npm
CACHE_OUT_DIRECTORY: cache-out-directory
CACHE_PIP_DEPS: cache-pip
# Key for the cache created at the end of the the 'Cache ./pythonFiles/lib/python' step.
CACHE_PYTHONFILES: cache-pvsc-pythonFiles
ARTIFACT_NAME_VSIX: ms-python-insiders-vsix
COVERAGE_REPORTS: tests-coverage-reports
TEST_RESULTS_DIRECTORY: .
LKG_TAG: ci-lkg
jobs:
### Initialization: retrieve, install and cache dependencies
python-deps:
name: Install Python Requirements
runs-on: ubuntu-latest
if: github.repository == 'microsoft/vscode-python'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Python ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v1
with:
python-version: ${{env.PYTHON_VERSION}}
- name: Upgrade pip
run: python -m pip install -U pip
- name: Install Python requirements
run: |
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
- name: Install debugpy wheels
run: |
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
python ./pythonFiles/install_debugpy.py
# Retrieve the list of debugpy versions from PyPI in order to increase the specificity of the pip cache key,
# so that the cache gets invalidated as necessary.
# See https://github.com/microsoft/vscode-python/pull/9843#discussion_r373635221
- name: curl PyPI to get debugpy versions
run: curl --output debugpy.json https://pypi.org/pypi/debugpy/json
- name: Cache pip files
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{runner.os}}-${{env.CACHE_PIP_DEPS}}-pip-${{env.PYTHON_VERSION}}-${{hashFiles('requirements.txt')}}-${{hashFiles('build/debugger-install-requirements.txt')}}-${{hashFiles('debugpy.json')}}
- name: Cache ./pythonFiles/lib/python
uses: actions/cache@v1
with:
path: ./pythonFiles/lib/python
key: ${{runner.os}}-${{env.CACHE_PYTHONFILES}}-pythonFiles-${{env.PYTHON_VERSION}}-${{hashFiles('requirements.txt')}}-${{hashFiles('build/debugger-install-requirements.txt')}}-${{hashFiles('debugpy.json')}}
js-ts-deps:
name: Install npm dependencies
runs-on: ubuntu-latest
if: github.repository == 'microsoft/vscode-python'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies (npm ci)
run: npm ci --prefer-offline
- name: Cache npm files
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-${{env.CACHE_NPM_DEPS}}-${{hashFiles('package-lock.json')}}
### Hygiene + VSIX upload
compile-hygiene:
name: Compile, lint, check for errors
runs-on: ubuntu-latest
if: github.repository == 'microsoft/vscode-python'
needs: [js-ts-deps, python-deps]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cached npm files
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-${{env.CACHE_NPM_DEPS}}-${{hashFiles('package-lock.json')}}
- name: Install dependencies (npm ci)
run: npm ci --prefer-offline
- name: Run gulp prePublishNonBundle
run: npx gulp prePublishNonBundle
- name: Cache the out/ directory
uses: actions/cache@v1
with:
path: ./out
key: ${{runner.os}}-${{env.CACHE_OUT_DIRECTORY}}-${{hashFiles('src/**')}}
- name: Check dependencies
run: npm run checkDependencies
- name: Run linting on TypeScript code
run: npx tslint --project tsconfig.json
- name: Run prettier on TypeScript code
run: npx prettier 'src/**/*.ts*' --check
- name: Run prettier on JavaScript code
run: npx prettier 'build/**/*.js' --check
- name: Use Python ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v1
with:
python-version: ${{env.PYTHON_VERSION}}
- name: Run Black on Python code
run: |
python -m pip install -U black
python -m black . --check
working-directory: pythonFiles
build-vsix:
name: Build VSIX
runs-on: ubuntu-latest
if: github.repository == 'microsoft/vscode-python'
needs: [python-deps, js-ts-deps]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cached npm files
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-${{env.CACHE_NPM_DEPS}}-${{hashFiles('package-lock.json')}}
- name: curl PyPI to get debugpy versions
run: curl --output debugpy.json https://pypi.org/pypi/debugpy/json
- name: Retrieve cached pythonFiles/ directory
uses: actions/cache@v1
with:
path: ./pythonFiles/lib/python
key: ${{runner.os}}-${{env.CACHE_PYTHONFILES}}-pythonFiles-${{env.PYTHON_VERSION}}-${{hashFiles('requirements.txt')}}-${{hashFiles('build/debugger-install-requirements.txt')}}-${{hashFiles('debugpy.json')}}
- name: Install dependencies (npm ci)
run: npm ci --prefer-offline
- name: Clean directory
run: npm run clean
# Use the GITHUB_RUN_ID environment variable to update the build number.
# GITHUB_RUN_ID is a unique number for each run within a repository.
# This number does not change if you re-run the workflow run.
- name: Update build number
run: npm run updateBuildNumber -- --buildNumber $GITHUB_RUN_ID
- name: Package the VSIX
run: npm run package
- uses: actions/upload-artifact@v1
with:
name: ${{env.ARTIFACT_NAME_VSIX}}
path: ms-python-insiders.vsix
### Non-smoke tests
tests:
name: Tests
# The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded.
runs-on: ${{ matrix.os }}
if: github.repository == 'microsoft/vscode-python'
needs: [python-deps, js-ts-deps]
strategy:
matrix:
# We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used,
# macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case.
os: [ubuntu-latest, windows-latest]
# Run the tests on the oldest and most recent versions of Python.
python: [2.7, 3.8]
test-suite: [ts-unit, python-unit, venv, single-workspace, multi-workspace, debugger, functional]
env:
# Something in Node 12.16.0 breaks the TS debug adapter, and ubuntu-latest bundles Node 12.16.1.
# We can remove this when we switch over to the python-based DA in https://github.com/microsoft/vscode-python/issues/7136.
# See https://github.com/microsoft/ptvsd/issues/2068
NODE_VERSION: 12.15.0
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cached npm files
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-${{env.CACHE_NPM_DEPS}}-${{hashFiles('package-lock.json')}}
- name: Install dependencies (npm ci)
run: npm ci
- name: Retrieve cached compile output directory
# Use an id for this step so that its cache-hit output can be accessed and checked in the next step.
id: out-cache
uses: actions/cache@v1
with:
path: ./out
key: ${{runner.os}}-${{env.CACHE_OUT_DIRECTORY}}-${{hashFiles('src/**')}}
- name: Compile if not cached
run: npx gulp prePublishNonBundle
if: steps.out-cache.outputs.cache-hit == false
- name: Use Python ${{matrix.python}}
uses: actions/setup-python@v1
with:
python-version: ${{matrix.python}}
- name: Use Node ${{env.NODE_VERSION}}
uses: actions/setup-node@v1
with:
node-version: ${{env.NODE_VERSION}}
- name: curl PyPI to get debugpy versions
run: curl --output debugpy.json https://pypi.org/pypi/debugpy/json
- name: Retrieve cached pythonFiles/ directory
uses: actions/cache@v1
# Use an id for this step so that its cache-hit output can be accessed and checked in the next step.
id: pythonFiles-cache
with:
path: ./pythonFiles/lib/python
key: ${{runner.os}}-${{env.CACHE_PYTHONFILES}}-pythonFiles-${{env.PYTHON_VERSION}}-${{hashFiles('requirements.txt')}}-${{hashFiles('build/debugger-install-requirements.txt')}}-${{hashFiles('debugpy.json')}}
- name: Install Python requirements if not cached
run: |
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/old_ptvsd --no-cache-dir --implementation py --no-deps --upgrade 'ptvsd==4.3.2'
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python/debugpy/no_wheels --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
if: steps.pythonFiles-cache.outputs.cache-hit == false
- name: Install debugpy wheels if not cached
run: |
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
python ./pythonFiles/install_debugpy.py
if: steps.pythonFiles-cache.outputs.cache-hit == false
- name: Install test requirements
run: python -m pip install --upgrade -r build/test-requirements.txt
- name: Install IPython test requirements
run: |
python -m pip install numpy
python -m pip install --upgrade -r ./build/ipython-test-requirements.txt
if: matrix.test-suite == 'python-unit'
- name: Install functional test requirements
run: |
python -m pip install numpy
python -m pip install --upgrade -r ./build/functional-test-requirements.txt
if: matrix.test-suite == 'functional'
- name: Prepare environment for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
run: |
# venv/bin or venv\\Scripts (windows)?
$environmentExecutableFolder = 'bin'
if ('${{runner.os}}' -match 'windows-latest') {
$environmentExecutableFolder = 'Scripts'
}
# pipenv
python -m pip install pipenv
python -m pipenv run python build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
# venv
if ('${{matrix.python}}' -like '3.?') {
python -m venv .venv
& ".venv/$environmentExecutableFolder/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath
}
# virtualenv
python -m pip install virtualenv
python -m virtualenv .virtualenv
& ".virtualenv/$environmentExecutableFolder/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath
# conda
# 1. For `terminalActivation.testvirtualenvs.test.ts`
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $environmentExecutableFolder | Join-Path -ChildPath conda
if ('${{runner.os}}' -match 'windows-latest') {
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python
} else{
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $environmentExecutableFolder | Join-Path -ChildPath python
& $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath
}
& $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaPath
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "$Env:HOME/test_env3" -y python
shell: pwsh
if: matrix.test-suite == 'venv'
# Run TypeScript unit tests only for Python 3.X.
- name: Run TypeScript unit tests
run: npm run test:unittests:cover
if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.)
# Upload unit test coverage reports for later use in the "reports" job.
- name: Upload unit test coverage reports
uses: actions/upload-artifact@v1
with:
name: ${{runner.os}}-${{env.COVERAGE_REPORTS}}
path: .nyc_output
if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.)
# Run the Python and IPython tests in our codebase.
- name: Run Python and IPython unit tests
run: |
python pythonFiles/tests/run_all.py
python -m IPython pythonFiles/tests/run_all.py
if: matrix.test-suite == 'python-unit'
# The virtual environment based tests use the `testSingleWorkspace` set of tests
# with the environment variable `TEST_FILES_SUFFIX` set to `testvirtualenvs`,
# which is set in the "Prepare environment for venv tests" step.
# We also use a third-party GitHub Action to install xvfb on Linux,
# run tests and then clean up the process once the tests ran.
# See https://github.com/GabrielBB/xvfb-action
- name: Run venv tests
uses: GabrielBB/xvfb-action@v1.0
with:
run: npm run testSingleWorkspace
if: matrix.test-suite == 'venv'
- name: Run single-workspace tests
uses: GabrielBB/xvfb-action@v1.0
with:
run: npm run testSingleWorkspace
if: matrix.test-suite == 'single-workspace'
- name: Run multi-workspace tests
uses: GabrielBB/xvfb-action@v1.0
with:
run: npm run testMultiWorkspace
if: matrix.test-suite == 'multi-workspace'
- name: Run debugger tests
uses: GabrielBB/xvfb-action@v1.0
with:
run: npm run testDebugger
if: matrix.test-suite == 'debugger'
- name: Run functional tests
run: npm run test:functional
if: matrix.test-suite == 'functional'
smoke-tests:
name: Smoke tests
# The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded.
runs-on: ${{ matrix.os }}
needs: [build-vsix]
if: github.repository == 'microsoft/vscode-python'
strategy:
matrix:
# We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used,
# macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case.
os: [ubuntu-latest, windows-latest]
python: [3.8]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cached npm files
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-${{env.CACHE_NPM_DEPS}}-${{hashFiles('package-lock.json')}}
- name: Install dependencies (npm ci)
run: npm ci --prefer-offline
- name: Download VSIX
uses: actions/download-artifact@v1
with:
name: ${{env.ARTIFACT_NAME_VSIX}}
# Extract the artifact from its download folder (./${{env.ARTIFACT_NAME_VSIX}}) to the repo root,
# then delete the download folder and compile the source code.
- name: Prepare for smoke tests
run: |
mv ${{env.ARTIFACT_NAME_VSIX}}/* .
rm -r ${{env.ARTIFACT_NAME_VSIX}}
npx tsc -p ./
shell: bash
- name: Run smoke tests
env:
DISPLAY: 10
uses: GabrielBB/xvfb-action@v1.0
with:
run: node ./out/test/smokeTest.js
coverage:
name: Coverage reports upload
runs-on: ubuntu-latest
if: github.repository == 'microsoft/vscode-python'
needs: [tests, smoke-tests]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cached npm files
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-${{env.CACHE_NPM_DEPS}}-${{hashFiles('package-lock.json')}}
- name: Install dependencies (npm ci)
run: npm ci --prefer-offline
# It isn't possible to specify a regex for artifact names, so we have to download each artifact manually.
# The name pattern is ${{runner.os}}-${{env.COVERAGE_REPORTS}}, and possible values for runner.os are `Linux`, `Windows`, or `macOS`.
# See https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#runner-context
- name: Download Ubuntu test coverage artifacts
uses: actions/download-artifact@v1
with:
name: Linux-${{env.COVERAGE_REPORTS}}
- name: Extract Ubuntu coverage artifacts to ./nyc_output
run: |
mkdir .nyc_output
mv Linux-${{env.COVERAGE_REPORTS}}/* .nyc_output
rm -r Linux-${{env.COVERAGE_REPORTS}}
- name: Generate coverage reports
run: npm run test:cover:report
continue-on-error: true
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
file: ./coverage/cobertura-coverage.xml
lkg-tag:
# LKG = last known good
name: Tag successful build as CI LKG
runs-on: ubuntu-latest
needs: [tests, smoke-tests]
if: github.repository == 'microsoft/vscode-python'
steps:
- name: Delete existing tag
run: |
curl -s -X DELETE https://api.github.com/repos/microsoft/vscode-python/git/refs/tags/${{env.LKG_TAG}} \
-H "Authorization: token ${{secrets.GITHUB_TOKEN}}"
# We only need to create a tag reference for lightweight tags.
# See https://developer.github.com/v3/git/tags/#create-a-tag-object
# And https://developer.github.com/v3/git/refs/#create-a-reference
- name: Create a tag reference
run: |
curl -s -X POST "https://api.github.com/repos/microsoft/vscode-python/git/refs" \
-H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
-d @- << EOF
{
"ref": "refs/tags/${{env.LKG_TAG}}",
"sha": "${{github.sha}}"
}
EOF