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

Added system tests to check activation for virtual environments #3592

Merged
merged 36 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c1ba5cb
Added template for virtual environment tests
Dec 5, 2018
329b90b
Updated virtual_env_tests.yml
Dec 5, 2018
c670696
Temporarily Removed downloading task
Dec 6, 2018
e4d17c8
Correct Executable Folder
Dec 6, 2018
1aa6c54
Added dependencies
Dec 6, 2018
cef1777
Added system tests to check activation for virtual environments
Dec 7, 2018
ea86b35
Corrected suffix
Dec 8, 2018
cd15875
Added system test to check activation for CONDA
Dec 10, 2018
d439193
Corrected conda activation
Dec 10, 2018
a532b90
Corrected terminal for conda activation
Dec 11, 2018
964206a
Changed conda bash script to powershell
Dec 11, 2018
fe97466
Added system test to ensure terminal gets activated with anaconda env…
Dec 11, 2018
47708b2
Added system tests to ensure terminal gets activated with virtualenv …
Dec 11, 2018
b9cbb42
Added system test to ensure terminal gets activated with pipenv
Dec 11, 2018
358bb15
Addressed PR reviews
Dec 12, 2018
13c3b3b
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Dec 12, 2018
f218cfd
Added testing for linux
Dec 13, 2018
4f9fc47
Corrected conda executable location for linux
Dec 13, 2018
b074d54
Corrected YAML
Dec 13, 2018
b75bc92
Started xvfb task for venvs linux
Dec 13, 2018
10e9dcb
Added DISPLAY env
Dec 13, 2018
e1b7b19
Printing variables to console
Dec 14, 2018
e02793c
Temporarily removed other tasks for debugging
Dec 14, 2018
d1b981b
Debugging
Dec 14, 2018
66c5a2b
Debugging promise resolve
Dec 15, 2018
ddb2caf
Correct linux shell path
Dec 18, 2018
f9b452f
Testing conda env
Dec 18, 2018
5c40164
Adding more debug statements
Dec 18, 2018
eb2f7d9
Added /usr/share/miniconda to GlobPattern
Dec 18, 2018
53f846d
Add some more logging
Dec 19, 2018
9c4aa62
Using conda executable path instead of conda python path
Dec 19, 2018
65d5b57
Added event handler for condaPath setting
Dec 19, 2018
0cd6e2f
Added macOS
Dec 19, 2018
ff6d574
Clean up
Dec 19, 2018
15bc3a2
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Dec 24, 2018
07b8e0a
Fix Merge Conflicts
Dec 28, 2018
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
26 changes: 26 additions & 0 deletions build/ci/addEnvPath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

#Adds the virtual environment's executable path to json file
karrtikr marked this conversation as resolved.
Show resolved Hide resolved

import json,sys
import os.path
jsonPath = sys.argv[1]
key = sys.argv[2]

if os.path.isfile(jsonPath):
with open(jsonPath, 'r') as read_file:
data = json.load(read_file)
else:
directory = os.path.dirname(jsonPath)
if not os.path.exists(directory):
os.makedirs(directory)
with open(jsonPath, 'w+') as read_file:
data = {}
data = {}
with open(jsonPath, 'w') as outfile:
if key == 'condaExecPath':
data[key] = sys.argv[3]
else:
data[key] = sys.executable
json.dump(data, outfile, sort_keys=True, indent=4)
191 changes: 191 additions & 0 deletions build/ci/templates/virtual_env_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
jobs:
- job: ${{ parameters.name }}
dependsOn: 'PR_Validate_Windows_py37'
pool:
name: ${{ parameters.PoolName }}

variables:
nodeVersion: ${{ parameters.NodeVersion }}
npmVersion: ${{ parameters.NpmVersion }}
pythonVersion: ${{ parameters.PythonVersion }}
platform: ${{ parameters.Platform }}
azureStorageAcctName: ${{ parameters.AzureStorageAccountName }}
azureStorageContainerName: ${{ parameters.AzureStorageContainerName }}
environmentExecutableFolder: ${{ parameters.EnvironmentExecutableFolder }}
PYTHON_VIRTUAL_ENVS_LOCATION: ${{ parameters.PYTHON_VIRTUAL_ENVS_LOCATION }}
TEST_FILES_SUFFIX: ${{ parameters.TEST_FILES_SUFFIX }}
TestSuiteName: ${{ parameters.TestSuiteName }}

steps:
- bash: echo REQUESTED VARIABLE VALUES

echo Node Version = $(nodeVersion)

echo Python Version = $(pythonVersion)

echo NPM Version = $(npmVersion)

echo Mocha reportfile = '$(mochaReportFile)'

echo MOCHA_CI_REPORTFILE = $MOCHA_CI_REPORTFILE

echo MOCHA_CI_REPORTER_ID = $MOCHA_CI_REPORTER_ID

echo MOCHA_REPORTER_JUNIT = $MOCHA_REPORTER_JUNIT

echo COV_UUID = $COV_UUID

echo Run Hygiene = $(runHygiene)

displayName: 'Show build vars'
name: 'show_bld_vars'


- powershell: |
New-Item -ItemType directory -Path "$(System.ArtifactsDirectory)/bin-artifacts"

$buildArtifactUri = "https://$(azureStorageAcctName).blob.core.windows.net/$(azureStorageContainerName)/$(Build.BuildNumber)/bin-artifacts.zip"
Write-Verbose "Downloading from $buildArtifactUri"

$destination = "$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip"
Write-Verbose "Destination file: $destination"

Invoke-WebRequest -Uri $buildArtifactUri -OutFile $destination -Verbose

displayName: 'Download bin-artifacts from cloud-storage'


- task: ExtractFiles@1
displayName: 'Splat bin-artifacts'
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/bin-artifacts/bin-artifacts.zip'

destinationFolder: '$(Build.SourcesDirectory)'

cleanDestinationFolder: false


- task: NodeTool@0
displayName: 'Use Node $(nodeVersion)'
inputs:
versionSpec: '$(nodeVersion)'


- task: UsePythonVersion@0
displayName: 'Use Python $(pythonVersion)'
inputs:
versionSpec: '$(pythonVersion)'


- task: CmdLine@1
displayName: 'pip install pipenv'
inputs:
filename: python

arguments: '-m pip install pipenv'


- bash: |
pipenv run python ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) pipenvPath

displayName: 'Create and save pipenv environment'


- task: CmdLine@1
displayName: 'Create venv environment'
inputs:
filename: python

arguments: '-m venv .venv'


- bash: |
.venv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) venvPath

displayName: 'Save venv environment executable'


- task: CmdLine@1
displayName: 'pip install virtualenv'
inputs:
filename: python

arguments: '-m pip install virtualenv'


- task: CmdLine@1
displayName: 'Create virtualenv environment'
inputs:
filename: python

arguments: '-m virtualenv .virtualenv'


- bash: |
.virtualenv/$(environmentExecutableFolder)/python ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) virtualEnvPath

displayName: 'Save virtualenv environment executable'

- powershell: |
Write-Host $Env:CONDA
Write-Host $Env:PYTHON_VIRTUAL_ENVS_LOCATION

if( '$(platform)' -eq 'Windows' ){
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath conda

} else{
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath python
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $(environmentExecutableFolder) | Join-Path -ChildPath conda

}

& $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaPath

& $condaPythonPath ./build/ci/addEnvPath.py $(PYTHON_VIRTUAL_ENVS_LOCATION) condaExecPath $condaExecPath

Get-Content $Env:PYTHON_VIRTUAL_ENVS_LOCATION

displayName: 'Save conda environment executable'


- task: Npm@1
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
displayName: 'update npm'
inputs:
command: custom

verbose: true

customCommand: 'install -g npm@$(NpmVersion)'


- task: Npm@1
displayName: 'npm ci'
inputs:
command: custom

verbose: true

customCommand: ci


- script: |
set -e
/usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
disown -ar
displayName: 'Start xvfb'
condition: and(succeeded(), eq(variables['Platform'], 'Linux'))


- task: Npm@1
displayName: 'run $(TestSuiteName)'
inputs:
command: custom

verbose: true

customCommand: 'run $(TestSuiteName)'
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
env:
DISPLAY: :10


48 changes: 48 additions & 0 deletions build/ci/vscode-python-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,54 @@ jobs:
AzureStorageAccountName: 'vscodepythonci'
AzureStorageContainerName: 'vscode-python-ci'


- template: templates/virtual_env_tests.yml
parameters:
name: 'VirtualEnv_Tests_Windows_py37'
PythonVersion: '3.7'
NodeVersion: '8.11.2'
NpmVersion: 'latest'
AzureStorageAccountName: 'vscodepythonci'
AzureStorageContainerName: 'vscode-python-ci'
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
Platform: 'Windows'
PoolName: 'Hosted VS2017'
EnvironmentExecutableFolder: 'Scripts'
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
TEST_FILES_SUFFIX: 'testvirtualenvs'
TestSuiteName: 'testSingleWorkspace'


- template: templates/virtual_env_tests.yml
parameters:
name: 'VirtualEnv_Tests_Linux_py37'
PythonVersion: '3.7'
NodeVersion: '8.11.2'
NpmVersion: 'latest'
AzureStorageAccountName: 'vscodepythonci'
AzureStorageContainerName: 'vscode-python-ci'
Platform: 'Linux'
PoolName: 'Hosted Ubuntu 1604'
EnvironmentExecutableFolder: 'bin'
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
TEST_FILES_SUFFIX: 'testvirtualenvs'
TestSuiteName: 'testSingleWorkspace'


- template: templates/virtual_env_tests.yml
parameters:
name: 'VirtualEnv_Tests_MacOS_py37'
PythonVersion: '3.7'
NodeVersion: '8.11.2'
NpmVersion: 'latest'
AzureStorageAccountName: 'vscodepythonci'
AzureStorageContainerName: 'vscode-python-ci'
Platform: 'macOS'
PoolName: 'Hosted macOS'
EnvironmentExecutableFolder: 'bin'
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
TEST_FILES_SUFFIX: 'testvirtualenvs'
TestSuiteName: 'testSingleWorkspace'

- job: 'System_Test_macOS'
dependsOn: 'PR_Validate_Windows_py37'
pool:
Expand Down
1 change: 1 addition & 0 deletions news/3 Code Health/1521.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Created system test to ensure terminal gets activated with anaconda environment
1 change: 1 addition & 0 deletions news/3 Code Health/1522.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added system tests to ensure terminal gets activated with virtualenv environment
1 change: 1 addition & 0 deletions news/3 Code Health/1523.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added system test to ensure terminal gets activated with pipenv
1 change: 0 additions & 1 deletion src/client/common/terminal/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class TerminalHelper implements ITerminalHelper {
public getTerminalShellPath(): string {
const workspace = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);
const shellConfig = workspace.getConfiguration('terminal.integrated.shell');

const platformService = this.serviceContainer.get<IPlatformService>(IPlatformService);
let osSection = '';
if (platformService.isWindows) {
Expand Down
Loading