Skip to content

Commit 6133159

Browse files
authored
Fix issue with setting up envs for venv test on GitHub Actions (#11512)
* Fix issue with setting up envs for venv test * Ensure testvirtualenvs is set for venv tests
1 parent 7f5dae9 commit 6133159

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -267,52 +267,68 @@ jobs:
267267
python -m pip install --upgrade -r ./build/functional-test-requirements.txt
268268
if: matrix.test-suite == 'functional'
269269

270-
- name: Prepare environment for venv tests
270+
- name: Prepare pipenv for venv tests
271271
env:
272272
TEST_FILES_SUFFIX: testvirtualenvs
273273
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
274+
shell: pwsh
275+
if: matrix.test-suite == 'venv'
274276
run: |
275-
# venv/bin or venv\\Scripts (windows)?
276-
$environmentExecutableFolder = 'bin'
277-
if ('${{runner.os}}' -match 'windows-latest') {
278-
$environmentExecutableFolder = 'Scripts'
279-
}
280-
281-
# pipenv
282277
python -m pip install pipenv
283-
python -m pipenv run python build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
278+
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
284279
285-
# venv
286-
if ('${{matrix.python}}' -like '3.?') {
287-
python -m venv .venv
288-
& ".venv/$environmentExecutableFolder/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath
289-
}
290-
291-
# virtualenv
280+
- name: Prepare virtualenv for venv tests
281+
env:
282+
TEST_FILES_SUFFIX: testvirtualenvs
283+
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
284+
shell: pwsh
285+
if: matrix.test-suite == 'venv'
286+
run: |
292287
python -m pip install virtualenv
293-
python -m virtualenv .virtualenv
294-
& ".virtualenv/$environmentExecutableFolder/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath
288+
python -m virtualenv .virtualenv/
289+
if ('${{matrix.os}}' -match 'windows-latest') {
290+
& ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath
291+
} else {
292+
& ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath
293+
}
295294
296-
# conda
295+
- name: Prepare venv for venv tests
296+
env:
297+
TEST_FILES_SUFFIX: testvirtualenvs
298+
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
299+
shell: pwsh
300+
if: matrix.test-suite == 'venv' && startsWith(matrix.python, 3.)
301+
run: |
302+
python -m venv .venv
303+
if ('${{matrix.os}}' -match 'windows-latest') {
304+
& ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath
305+
} else {
306+
& ".venv/bin/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath
307+
}
297308
309+
- name: Prepare conda for venv tests
310+
env:
311+
TEST_FILES_SUFFIX: testvirtualenvs
312+
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
313+
shell: pwsh
314+
if: matrix.test-suite == 'venv'
315+
run: |
298316
# 1. For `terminalActivation.testvirtualenvs.test.ts`
299-
300-
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath $environmentExecutableFolder | Join-Path -ChildPath conda
301-
if ('${{runner.os}}' -match 'windows-latest') {
302-
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python
317+
if ('${{matrix.os}}' -match 'windows-latest') {
318+
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe
319+
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda
303320
} else{
304-
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath $environmentExecutableFolder | Join-Path -ChildPath python
305-
& $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath
321+
$condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python
322+
$condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda
306323
}
324+
& $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath
307325
& $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaPath
308326
309327
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
310328
311329
& $condaExecPath create -n "test_env1" -y python
312330
& $condaExecPath create -p "./test_env2" -y python
313-
& $condaExecPath create -p "$Env:HOME/test_env3" -y python
314-
shell: pwsh
315-
if: matrix.test-suite == 'venv'
331+
& $condaExecPath create -p "~/test_env3" -y python
316332
317333
# Run TypeScript unit tests only for Python 3.X.
318334
- name: Run TypeScript unit tests
@@ -341,6 +357,8 @@ jobs:
341357
# run tests and then clean up the process once the tests ran.
342358
# See https://github.com/GabrielBB/xvfb-action
343359
- name: Run venv tests
360+
env:
361+
TEST_FILES_SUFFIX: testvirtualenvs
344362
uses: GabrielBB/[email protected]
345363
with:
346364
run: npm run testSingleWorkspace

0 commit comments

Comments
 (0)