From 86e448c1363575d02a27798e18fcee0add3838da Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 12:54:16 -0700 Subject: [PATCH 01/10] Unskip venv tests --- .../terminalActivation.testvirtualenvs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 8a3d7c44208d..275d628bbfd4 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -26,7 +26,7 @@ import { sleep } from '../../../core'; import { initialize, initializeTest } from '../../../initialize'; import * as ExperimentHelpers from '../../../../client/common/experiments/helpers'; -suite.skip('Activation of Environments in Terminal', () => { +suite('Activation of Environments in Terminal', () => { const file = path.join( EXTENSION_ROOT_DIR_FOR_TESTS, 'src', From 3eead1733947bcc2d4c0eb70c9dcd4e5155b6f7b Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 12:55:48 -0700 Subject: [PATCH 02/10] Run only venv tests --- .github/workflows/pr-check.yml | 387 +-------------------------------- 1 file changed, 2 insertions(+), 385 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 9bfa4831cb73..2f8007e0c022 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -20,76 +20,6 @@ env: special-working-directory-relative: 'path with spaces' jobs: - build-vsix: - name: Build VSIX - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Install Node - uses: actions/setup-node@v2.3.0 - with: - node-version: ${{env.NODE_VERSION}} - - # Jedi LS depends on dataclasses which was a pypi install in 3.6 - - name: Use Python 3.6 for JediLSP - uses: actions/setup-python@v2 - with: - python-version: 3.6 - - - name: Build VSIX - uses: ./.github/actions/build-vsix - id: build-vsix - - - name: Rename VSIX - if: steps.build-vsix.outputs.path != env.VSIX_NAME - run: mv ${{ steps.build-vsix.outputs.path }} ${{ env.VSIX_NAME }} - - - uses: actions/upload-artifact@v2 - with: - name: ${{env.ARTIFACT_NAME_VSIX}} - path: ${{env.VSIX_NAME}} - retention-days: 7 - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Install Node - uses: actions/setup-node@v2.3.0 - with: - node-version: ${{env.NODE_VERSION}} - - - name: Install dependencies (npm ci) - run: npm ci --prefer-offline - - - name: Run gulp prePublishNonBundle - run: npx gulp prePublishNonBundle - - - name: Check dependencies - run: npm run checkDependencies - - - name: Run linting on TypeScript code - run: npm run lint - - - name: Run formatting on TypeScript code - run: npm run format-check - - - name: Use Python ${{env.PYTHON_VERSION}} - uses: actions/setup-python@v2 - 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 - ### Non-smoke tests tests: name: Tests @@ -105,8 +35,8 @@ jobs: # 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.9'] - test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] + python: ['3.9'] + test-suite: [venv] exclude: # For fast PR turn-around, skip 2.7 under Windows. - os: windows-latest @@ -303,316 +233,3 @@ jobs: - name: Run TypeScript 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] - strategy: - fail-fast: false - 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] - # 3.8 is still required here so that jupyter can install. - python: [3.8] - steps: - # Need the source to have the tests available. - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Install Node - uses: actions/setup-node@v2.3.0 - with: - node-version: ${{env.NODE_VERSION}} - - - name: Use Python ${{matrix.python}} - uses: actions/setup-python@v2 - with: - python-version: ${{matrix.python}} - - - name: Install dependencies (npm ci) - run: npm ci --prefer-offline - - - name: pip install system test requirements - run: | - python -m pip install --upgrade -r build/test-requirements.txt - 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 --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - shell: bash - - - name: pip install smoke test requirements - run: | - python -m pip install --upgrade -r build/smoke-test-requirements.txt - shell: bash - - # Save time by reusing bits from the VSIX. - - name: Download VSIX - uses: actions/download-artifact@v2 - with: - name: ${{env.ARTIFACT_NAME_VSIX}} - - # Compile the test files. - - name: Prepare for smoke tests - run: npx tsc -p ./ - shell: bash - - - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION - run: | - echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV - echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV - shell: bash - - - name: Run smoke tests - env: - DISPLAY: 10 - INSTALL_JUPYTER_EXTENSION: true - uses: GabrielBB/xvfb-action@v1.5 - with: - run: node --no-force-async-hooks-checks ./out/test/smokeTest.js - - # insider-tests: - # name: Insider 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 }} - # strategy: - # fail-fast: false - # 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] - # python: [3.8] - # steps: - # # Need the source to have the tests available. - # - name: Checkout - # uses: actions/checkout@v2.3.4 - - # - name: Install Node - # uses: actions/setup-node@v2.3.0 - # with: - # node-version: ${{env.NODE_VERSION}} - - # - name: Use Python ${{matrix.python}} - # uses: actions/setup-python@v2 - # with: - # python-version: ${{matrix.python}} - - # - name: Install dependencies (npm ci) - # run: npm ci --prefer-offline - - # - name: pip install system test requirements - # run: | - # python -m pip install --upgrade -r build/test-requirements.txt - # 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 --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - # shell: bash - - # - name: pip install smoke test requirements - # run: | - # python -m pip install --upgrade -r build/smoke-test-requirements.txt - # shell: bash - - # # Compile the test files. - # - name: Prepare for insiders tests - # run: npm run prePublish - # shell: bash - - # - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION - # run: | - # echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV - # echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV - # shell: bash - - # - name: Run insider tests - # env: - # DISPLAY: 10 - # INSTALL_JUPYTER_EXTENSION: true - # INSTALL_PYLANCE_EXTENSION: true - # VSC_PYTHON_CI_TEST_VSC_CHANNEL: insiders - # TEST_FILES_SUFFIX: insiders.test - # CODE_TESTS_WORKSPACE: ./src/testMultiRootWkspc/smokeTests - # uses: GabrielBB/xvfb-action@v1.5 - # with: - # run: node --no-force-async-hooks-checks ./out/test/standardTest.js - - ### Coverage run - coverage: - name: Coverage - # 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 }} - strategy: - fail-fast: false - matrix: - # Only run coverage on linux for PRs - os: [ubuntu-latest] - - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Install Node - uses: actions/setup-node@v2.3.0 - with: - node-version: ${{env.NODE_VERSION}} - - - name: Install dependencies (npm ci) - run: npm ci - - - name: Compile - run: npx gulp prePublishNonBundle - - - name: Use Python ${{env.PYTHON_VERSION}} - uses: actions/setup-python@v2 - with: - python-version: ${{env.PYTHON_VERSION}} - - - name: Install Node - uses: actions/setup-node@v2.3.0 - with: - node-version: ${{env.NODE_VERSION}} - - - 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 --no-user - # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. - python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - - - name: Install test requirements - run: python -m pip install --upgrade -r build/test-requirements.txt - - - name: Install functional test requirements - run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt - - - name: Prepare pipenv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - python -m pip install pipenv - python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath - - - name: Prepare poetry for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - shell: pwsh - run: | - python -m pip install poetry - Move-Item -Path ".\build\ci\pyproject.toml" -Destination . - poetry env use python - - - name: Prepare virtualenv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - python -m pip install virtualenv - python -m virtualenv .virtualenv/ - if ('${{matrix.os}}' -match 'windows-latest') { - & ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath - } else { - & ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath - } - - - name: Prepare venv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - python -m venv .venv - if ('${{matrix.os}}' -match 'windows-latest') { - & ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath - } else { - & ".venv/bin/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath - } - - - name: Prepare conda for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - # 1. For `terminalActivation.testvirtualenvs.test.ts` - if ('${{matrix.os}}' -match 'windows-latest') { - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda - } else{ - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda - } - & $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 "~/test_env3" -y python - - - name: Run TypeScript unit tests - run: npm run test:unittests:cover - - - name: Run Python unit tests - run: | - python pythonFiles/tests/run_all.py - - # 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 - env: - TEST_FILES_SUFFIX: testvirtualenvs - CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} - CI_DISABLE_AUTO_SELECTION: 1 - uses: GabrielBB/xvfb-action@v1.5 - with: - run: npm run testSingleWorkspace:cover - - - name: Run single-workspace tests - env: - CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} - CI_DISABLE_AUTO_SELECTION: 1 - uses: GabrielBB/xvfb-action@v1.5 - with: - run: npm run testSingleWorkspace:cover - - # Enable these tests when coverage is setup for multiroot workspace tests - # - name: Run multi-workspace tests - # env: - # CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} - # CI_DISABLE_AUTO_SELECTION: 1 - # uses: GabrielBB/xvfb-action@v1.5 - # with: - # run: npm run testMultiWorkspace:cover - - # Enable these tests when coverage is setup for debugger tests - # - name: Run debugger tests - # env: - # CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} - # CI_DISABLE_AUTO_SELECTION: 1 - # uses: GabrielBB/xvfb-action@v1.5 - # with: - # run: npm run testDebugger:cover - - # Run TypeScript functional tests - - name: Run TypeScript functional tests - env: - CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} - CI_DISABLE_AUTO_SELECTION: 1 - run: npm run test:functional:cover - - - name: Generate coverage reports - run: npm run test:cover:report - - - name: Upload HTML report - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-coverage-report-html - path: ./coverage - retention-days: 1 From d249e17d306c1a8704ad97e9ee73948a7fdbcf4c Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 13:38:15 -0700 Subject: [PATCH 03/10] Do not stub experiments service --- .../terminalActivation.testvirtualenvs.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 275d628bbfd4..459311979fb9 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -24,7 +24,6 @@ import { import { EXTENSION_ROOT_DIR_FOR_TESTS, TEST_TIMEOUT } from '../../../constants'; import { sleep } from '../../../core'; import { initialize, initializeTest } from '../../../initialize'; -import * as ExperimentHelpers from '../../../../client/common/experiments/helpers'; suite('Activation of Environments in Terminal', () => { const file = path.join( @@ -61,7 +60,6 @@ suite('Activation of Environments in Terminal', () => { let experiments: IExperimentService; const sandbox = sinon.createSandbox(); suiteSetup(async () => { - sandbox.stub(ExperimentHelpers, 'inDiscoveryExperiment').resolves(false); envPaths = await fs.readJson(envsLocation); terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders![0].uri); pythonSettings = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders![0].uri); From 836c3a497b0f84fcd29dd30798f7ed727bd78bc2 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 13:56:52 -0700 Subject: [PATCH 04/10] Use new terminal setting to update shell --- .../terminalActivation.testvirtualenvs.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 459311979fb9..59f3a0d02ae7 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -103,7 +103,7 @@ suite('Activation of Environments in Terminal', () => { vscode.ConfigurationTarget.WorkspaceFolder, ); await terminalSettings.update( - 'integrated.shell.windows', + 'integrated.defaultProfile.windows', defaultShell.Windows, vscode.ConfigurationTarget.Global, ); @@ -188,8 +188,8 @@ suite('Activation of Environments in Terminal', () => { }); test('Should activate with conda', async () => { await terminalSettings.update( - 'integrated.shell.windows', - 'C:\\Windows\\System32\\cmd.exe', + 'integrated.defaultProfile.windows', + 'Command Prompt', vscode.ConfigurationTarget.Global, ); await pythonSettings.update('condaPath', envPaths.condaExecPath, vscode.ConfigurationTarget.Workspace); From 8587d1a5848b0b5b753a118d41d683b75a959946 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 13:59:27 -0700 Subject: [PATCH 05/10] Initialize conda shell --- .github/workflows/pr-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 2f8007e0c022..1f87aa53e6a5 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -161,6 +161,7 @@ jobs: } & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaPath + & $condaExecPath init --all # 2. For `interpreterLocatorService.testvirtualenvs.ts` From f1f9e80dd959a5f6270514df5fe264ccc65b8116 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 14:11:45 -0700 Subject: [PATCH 06/10] Use new terminal setting everywhere --- .../terminalActivation.testvirtualenvs.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 59f3a0d02ae7..dc2324ac9900 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -63,9 +63,9 @@ suite('Activation of Environments in Terminal', () => { envPaths = await fs.readJson(envsLocation); terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders![0].uri); pythonSettings = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders![0].uri); - defaultShell.Windows = terminalSettings.inspect('integrated.shell.windows').globalValue; - defaultShell.Linux = terminalSettings.inspect('integrated.shell.linux').globalValue; - await terminalSettings.update('integrated.shell.linux', '/bin/bash', vscode.ConfigurationTarget.Global); + defaultShell.Windows = terminalSettings.inspect('integrated.defaultProfile.windows').globalValue; + defaultShell.Linux = terminalSettings.inspect('integrated.defaultProfile.linux').globalValue; + await terminalSettings.update('integrated.defaultProfile.linux', 'bash', vscode.ConfigurationTarget.Global); experiments = (await initialize()).serviceContainer.get(IExperimentService); }); @@ -107,7 +107,11 @@ suite('Activation of Environments in Terminal', () => { defaultShell.Windows, vscode.ConfigurationTarget.Global, ); - await terminalSettings.update('integrated.shell.linux', defaultShell.Linux, vscode.ConfigurationTarget.Global); + await terminalSettings.update( + 'integrated.defaultProfile.linux', + defaultShell.Linux, + vscode.ConfigurationTarget.Global, + ); await pythonSettings.update('condaPath', undefined, vscode.ConfigurationTarget.Workspace); if (experiments.inExperimentSync(DeprecatePythonPath.experiment)) { await resetGlobalInterpreterPathSetting(); @@ -187,6 +191,7 @@ suite('Activation of Environments in Terminal', () => { await testActivation(envPaths.virtualEnvPath); }); test('Should activate with conda', async () => { + // Powershell does not work with conda by default, hence use cmd. await terminalSettings.update( 'integrated.defaultProfile.windows', 'Command Prompt', From fa20991bb1d48d5b52eb1b5d7ee264642ee1be1a Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 17:55:20 -0700 Subject: [PATCH 07/10] Run all tests --- .github/workflows/pr-check.yml | 387 ++++++++++++++++++++++++++++++++- 1 file changed, 385 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 1f87aa53e6a5..1f5f016acd0a 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -20,6 +20,76 @@ env: special-working-directory-relative: 'path with spaces' jobs: + build-vsix: + name: Build VSIX + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Install Node + uses: actions/setup-node@v2.3.0 + with: + node-version: ${{env.NODE_VERSION}} + + # Jedi LS depends on dataclasses which was a pypi install in 3.6 + - name: Use Python 3.6 for JediLSP + uses: actions/setup-python@v2 + with: + python-version: 3.6 + + - name: Build VSIX + uses: ./.github/actions/build-vsix + id: build-vsix + + - name: Rename VSIX + if: steps.build-vsix.outputs.path != env.VSIX_NAME + run: mv ${{ steps.build-vsix.outputs.path }} ${{ env.VSIX_NAME }} + + - uses: actions/upload-artifact@v2 + with: + name: ${{env.ARTIFACT_NAME_VSIX}} + path: ${{env.VSIX_NAME}} + retention-days: 7 + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Install Node + uses: actions/setup-node@v2.3.0 + with: + node-version: ${{env.NODE_VERSION}} + + - name: Install dependencies (npm ci) + run: npm ci --prefer-offline + + - name: Run gulp prePublishNonBundle + run: npx gulp prePublishNonBundle + + - name: Check dependencies + run: npm run checkDependencies + + - name: Run linting on TypeScript code + run: npm run lint + + - name: Run formatting on TypeScript code + run: npm run format-check + + - name: Use Python ${{env.PYTHON_VERSION}} + uses: actions/setup-python@v2 + 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 + ### Non-smoke tests tests: name: Tests @@ -35,8 +105,8 @@ jobs: # 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: ['3.9'] - test-suite: [venv] + python: ['2.7', '3.9'] + test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] exclude: # For fast PR turn-around, skip 2.7 under Windows. - os: windows-latest @@ -234,3 +304,316 @@ jobs: - name: Run TypeScript 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] + strategy: + fail-fast: false + 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] + # 3.8 is still required here so that jupyter can install. + python: [3.8] + steps: + # Need the source to have the tests available. + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Install Node + uses: actions/setup-node@v2.3.0 + with: + node-version: ${{env.NODE_VERSION}} + + - name: Use Python ${{matrix.python}} + uses: actions/setup-python@v2 + with: + python-version: ${{matrix.python}} + + - name: Install dependencies (npm ci) + run: npm ci --prefer-offline + + - name: pip install system test requirements + run: | + python -m pip install --upgrade -r build/test-requirements.txt + 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 --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy + shell: bash + + - name: pip install smoke test requirements + run: | + python -m pip install --upgrade -r build/smoke-test-requirements.txt + shell: bash + + # Save time by reusing bits from the VSIX. + - name: Download VSIX + uses: actions/download-artifact@v2 + with: + name: ${{env.ARTIFACT_NAME_VSIX}} + + # Compile the test files. + - name: Prepare for smoke tests + run: npx tsc -p ./ + shell: bash + + - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION + run: | + echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV + echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV + shell: bash + + - name: Run smoke tests + env: + DISPLAY: 10 + INSTALL_JUPYTER_EXTENSION: true + uses: GabrielBB/xvfb-action@v1.5 + with: + run: node --no-force-async-hooks-checks ./out/test/smokeTest.js + + # insider-tests: + # name: Insider 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 }} + # strategy: + # fail-fast: false + # 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] + # python: [3.8] + # steps: + # # Need the source to have the tests available. + # - name: Checkout + # uses: actions/checkout@v2.3.4 + + # - name: Install Node + # uses: actions/setup-node@v2.3.0 + # with: + # node-version: ${{env.NODE_VERSION}} + + # - name: Use Python ${{matrix.python}} + # uses: actions/setup-python@v2 + # with: + # python-version: ${{matrix.python}} + + # - name: Install dependencies (npm ci) + # run: npm ci --prefer-offline + + # - name: pip install system test requirements + # run: | + # python -m pip install --upgrade -r build/test-requirements.txt + # 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 --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy + # shell: bash + + # - name: pip install smoke test requirements + # run: | + # python -m pip install --upgrade -r build/smoke-test-requirements.txt + # shell: bash + + # # Compile the test files. + # - name: Prepare for insiders tests + # run: npm run prePublish + # shell: bash + + # - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION + # run: | + # echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV + # echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV + # shell: bash + + # - name: Run insider tests + # env: + # DISPLAY: 10 + # INSTALL_JUPYTER_EXTENSION: true + # INSTALL_PYLANCE_EXTENSION: true + # VSC_PYTHON_CI_TEST_VSC_CHANNEL: insiders + # TEST_FILES_SUFFIX: insiders.test + # CODE_TESTS_WORKSPACE: ./src/testMultiRootWkspc/smokeTests + # uses: GabrielBB/xvfb-action@v1.5 + # with: + # run: node --no-force-async-hooks-checks ./out/test/standardTest.js + + ### Coverage run + coverage: + name: Coverage + # 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 }} + strategy: + fail-fast: false + matrix: + # Only run coverage on linux for PRs + os: [ubuntu-latest] + + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Install Node + uses: actions/setup-node@v2.3.0 + with: + node-version: ${{env.NODE_VERSION}} + + - name: Install dependencies (npm ci) + run: npm ci + + - name: Compile + run: npx gulp prePublishNonBundle + + - name: Use Python ${{env.PYTHON_VERSION}} + uses: actions/setup-python@v2 + with: + python-version: ${{env.PYTHON_VERSION}} + + - name: Install Node + uses: actions/setup-node@v2.3.0 + with: + node-version: ${{env.NODE_VERSION}} + + - 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 --no-user + # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. + python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy + + - name: Install test requirements + run: python -m pip install --upgrade -r build/test-requirements.txt + + - name: Install functional test requirements + run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt + + - name: Prepare pipenv for venv tests + env: + TEST_FILES_SUFFIX: testvirtualenvs + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + shell: pwsh + run: | + python -m pip install pipenv + python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath + + - name: Prepare poetry for venv tests + env: + TEST_FILES_SUFFIX: testvirtualenvs + shell: pwsh + run: | + python -m pip install poetry + Move-Item -Path ".\build\ci\pyproject.toml" -Destination . + poetry env use python + + - name: Prepare virtualenv for venv tests + env: + TEST_FILES_SUFFIX: testvirtualenvs + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + shell: pwsh + run: | + python -m pip install virtualenv + python -m virtualenv .virtualenv/ + if ('${{matrix.os}}' -match 'windows-latest') { + & ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath + } else { + & ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} virtualEnvPath + } + + - name: Prepare venv for venv tests + env: + TEST_FILES_SUFFIX: testvirtualenvs + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + shell: pwsh + run: | + python -m venv .venv + if ('${{matrix.os}}' -match 'windows-latest') { + & ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath + } else { + & ".venv/bin/python" ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} venvPath + } + + - name: Prepare conda for venv tests + env: + TEST_FILES_SUFFIX: testvirtualenvs + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + shell: pwsh + run: | + # 1. For `terminalActivation.testvirtualenvs.test.ts` + if ('${{matrix.os}}' -match 'windows-latest') { + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe + $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda + } else{ + $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python + $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda + } + & $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 "~/test_env3" -y python + + - name: Run TypeScript unit tests + run: npm run test:unittests:cover + + - name: Run Python unit tests + run: | + python pythonFiles/tests/run_all.py + + # 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 + env: + TEST_FILES_SUFFIX: testvirtualenvs + CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} + CI_DISABLE_AUTO_SELECTION: 1 + uses: GabrielBB/xvfb-action@v1.5 + with: + run: npm run testSingleWorkspace:cover + + - name: Run single-workspace tests + env: + CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} + CI_DISABLE_AUTO_SELECTION: 1 + uses: GabrielBB/xvfb-action@v1.5 + with: + run: npm run testSingleWorkspace:cover + + # Enable these tests when coverage is setup for multiroot workspace tests + # - name: Run multi-workspace tests + # env: + # CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} + # CI_DISABLE_AUTO_SELECTION: 1 + # uses: GabrielBB/xvfb-action@v1.5 + # with: + # run: npm run testMultiWorkspace:cover + + # Enable these tests when coverage is setup for debugger tests + # - name: Run debugger tests + # env: + # CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} + # CI_DISABLE_AUTO_SELECTION: 1 + # uses: GabrielBB/xvfb-action@v1.5 + # with: + # run: npm run testDebugger:cover + + # Run TypeScript functional tests + - name: Run TypeScript functional tests + env: + CI_PYTHON_VERSION: ${{env.PYTHON_VERSION}} + CI_DISABLE_AUTO_SELECTION: 1 + run: npm run test:functional:cover + + - name: Generate coverage reports + run: npm run test:cover:report + + - name: Upload HTML report + uses: actions/upload-artifact@v2 + with: + name: ${{ runner.os }}-coverage-report-html + path: ./coverage + retention-days: 1 From 6ddc8527ce94077cedc30acdfe19ac3450257b76 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 21 Jul 2021 17:57:27 -0700 Subject: [PATCH 08/10] Use python.condaPath as conda binary if set --- .../pythonEnvironments/common/environmentManagers/conda.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/pythonEnvironments/common/environmentManagers/conda.ts b/src/client/pythonEnvironments/common/environmentManagers/conda.ts index 1eb577ee1b1f..30359a06fda7 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/conda.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/conda.ts @@ -2,7 +2,7 @@ import * as fsapi from 'fs-extra'; import * as path from 'path'; import { traceVerbose } from '../../../common/logger'; import { getEnvironmentVariable, getOSType, getUserHomeDir, OSType } from '../../../common/utils/platform'; -import { exec, pathExists, readFile } from '../externalDependencies'; +import { exec, getPythonSetting, pathExists, readFile } from '../externalDependencies'; import { PythonVersion, UNKNOWN_PYTHON_VERSION } from '../../base/info'; import { parseVersion } from '../../base/info/pythonVersion'; @@ -238,6 +238,11 @@ export class Conda { // Produce a list of candidate binaries to be probed by exec'ing them. async function* getCandidates() { + const customCondaPath = getPythonSetting('condaPath'); + if (customCondaPath && customCondaPath !== 'conda') { + // If user has specified a custom conda path, use it first. + yield customCondaPath; + } // Check unqualified filename first, in case it's on PATH. yield 'conda'; if (getOSType() === OSType.Windows) { From 3913d27a09d5b0ecc6a29557b5377802d46f790f Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 22 Jul 2021 00:37:37 -0700 Subject: [PATCH 09/10] Add/Fix tests for custom conda path --- .../composite/resolverUtils.unit.test.ts | 21 +++++++++++-------- .../environmentManagers/conda.unit.test.ts | 15 +++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/test/pythonEnvironments/base/locators/composite/resolverUtils.unit.test.ts b/src/test/pythonEnvironments/base/locators/composite/resolverUtils.unit.test.ts index 0574685ffeca..c5de00c3072a 100644 --- a/src/test/pythonEnvironments/base/locators/composite/resolverUtils.unit.test.ts +++ b/src/test/pythonEnvironments/base/locators/composite/resolverUtils.unit.test.ts @@ -27,11 +27,21 @@ import { import { resolveBasicEnv } from '../../../../../client/pythonEnvironments/base/locators/composite/resolverUtils'; suite('Resolver Utils', () => { + let getWorkspaceFolders: sinon.SinonStub; + setup(() => { + sinon.stub(externalDependencies, 'getPythonSetting').withArgs('condaPath').returns('conda'); + getWorkspaceFolders = sinon.stub(externalDependencies, 'getWorkspaceFolders'); + getWorkspaceFolders.returns([]); + }); + + teardown(() => { + sinon.restore(); + }); + suite('Pyenv', () => { const testPyenvRoot = path.join(TEST_LAYOUT_ROOT, 'pyenvhome', '.pyenv'); const testPyenvVersionsDir = path.join(testPyenvRoot, 'versions'); setup(() => { - sinon.stub(externalDependencies, 'getWorkspaceFolders').returns([]); sinon.stub(platformApis, 'getEnvironmentVariable').withArgs('PYENV_ROOT').returns(testPyenvRoot); }); @@ -68,7 +78,6 @@ suite('Resolver Utils', () => { const testStoreAppRoot = path.join(testLocalAppData, 'Microsoft', 'WindowsApps'); setup(() => { - sinon.stub(externalDependencies, 'getWorkspaceFolders').returns([]); sinon.stub(platformApis, 'getEnvironmentVariable').withArgs('LOCALAPPDATA').returns(testLocalAppData); }); @@ -199,10 +208,6 @@ suite('Resolver Utils', () => { }; } - setup(() => { - sinon.stub(externalDependencies, 'getWorkspaceFolders').returns([]); - }); - teardown(() => { sinon.restore(); }); @@ -265,7 +270,7 @@ suite('Resolver Utils', () => { suite('Simple envs', () => { const testVirtualHomeDir = path.join(TEST_LAYOUT_ROOT, 'virtualhome'); setup(() => { - sinon.stub(externalDependencies, 'getWorkspaceFolders').returns([testVirtualHomeDir]); + getWorkspaceFolders.returns([testVirtualHomeDir]); }); teardown(() => { @@ -318,7 +323,6 @@ suite('Resolver Utils', () => { const testPosixKnownPathsRoot = path.join(TEST_LAYOUT_ROOT, 'posixroot'); const testLocation3 = path.join(testPosixKnownPathsRoot, 'location3'); setup(() => { - sinon.stub(externalDependencies, 'getWorkspaceFolders').returns([]); sinon.stub(platformApis, 'getOSType').callsFake(() => platformApis.OSType.Linux); }); @@ -514,7 +518,6 @@ suite('Resolver Utils', () => { setup(async () => { sinon.stub(winreg, 'readRegistryValues').callsFake(fakeRegistryValues); sinon.stub(winreg, 'readRegistryKeys').callsFake(fakeRegistryKeys); - sinon.stub(externalDependencies, 'getWorkspaceFolders').returns([]); sinon.stub(platformApis, 'getOSType').callsFake(() => platformApis.OSType.Windows); }); diff --git a/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts b/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts index 7bcb4b54d05b..369c65b3629f 100644 --- a/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts +++ b/src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts @@ -85,8 +85,12 @@ suite('Conda and its environments are located correctly', () => { }; } + let getPythonSetting: sinon.SinonStub; + setup(() => { osType = platform.OSType.Unknown; + getPythonSetting = sinon.stub(externalDependencies, 'getPythonSetting'); + getPythonSetting.withArgs('condaPath').returns('conda'); homeDir = undefined; execPath = []; files = {}; @@ -189,6 +193,17 @@ suite('Conda and its environments are located correctly', () => { expect(conda).to.equal(undefined, 'conda should be missing'); }); + test('Must find conda using `python.condaPath` setting and prefer it', async () => { + getPythonSetting.withArgs('condaPath').returns('condaPath/conda'); + + files = { + condaPath: { + conda: JSON.stringify(condaInfo('4.8.0')), + }, + }; + await expectConda('/condaPath/conda'); + }); + test('Must find conda on PATH, and prefer it', async () => { osType = platform.OSType.Linux; execPath = ['/bin']; From 01da446b7136f42f7db2de1dacff80decc588996 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 22 Jul 2021 14:56:51 -0700 Subject: [PATCH 10/10] Use conda init everywhere --- .github/workflows/build.yml | 1 + .github/workflows/nightly-coverage.yml | 1 + .github/workflows/pr-check.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d23f9c780094..27f67a681e7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -252,6 +252,7 @@ jobs: } & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaPath + & $condaExecPath init --all # 2. For `interpreterLocatorService.testvirtualenvs.ts` diff --git a/.github/workflows/nightly-coverage.yml b/.github/workflows/nightly-coverage.yml index 18f97ad6354d..48c228b81d1c 100644 --- a/.github/workflows/nightly-coverage.yml +++ b/.github/workflows/nightly-coverage.yml @@ -119,6 +119,7 @@ jobs: } & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaPath + & $condaExecPath init --all # 2. For `interpreterLocatorService.testvirtualenvs.ts` diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 1f5f016acd0a..de4d06c5f05b 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -546,6 +546,7 @@ jobs: } & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaExecPath $condaExecPath & $condaPythonPath ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} condaPath + & $condaExecPath init --all # 2. For `interpreterLocatorService.testvirtualenvs.ts`