From bdd49e3f2a94154d7557f4768c5f7f8b1ad18dd9 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 19:21:54 +0530 Subject: [PATCH 1/9] Lets begin --- .github/workflows/pr-check.yml | 275 +----------------- src/client/common/configSettings.ts | 6 + .../terminalActivation.testvirtualenvs.ts | 2 - 3 files changed, 9 insertions(+), 274 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 7ec43a27b925..f06e81a4af27 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -20,65 +20,6 @@ env: special-working-directory-relative: 'path with spaces' jobs: - build-vsix: - name: Create VSIX - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Build VSIX - uses: ./.github/actions/build-vsix - with: - node_version: ${{ env.NODE_VERSION}} - vsix_name: ${{ env.VSIX_NAME }} - artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Lint - uses: ./.github/actions/lint - with: - node_version: ${{ env.NODE_VERSION }} - - check-types: - name: Check Python types - runs-on: ubuntu-latest - steps: - - name: Use Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v2 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Install base Python requirements - uses: brettcannon/pip-secure-install@v1 - with: - options: '-t ./pythonFiles/lib/python --no-cache-dir --implementation py' - - - name: Install Jedi requirements - uses: brettcannon/pip-secure-install@v1 - with: - requirements-file: './pythonFiles/jedilsp_requirements/requirements.txt' - options: '-t ./pythonFiles/lib/jedilsp --no-cache-dir --implementation py' - - - name: Install other Python requirements - run: | - python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - python -m pip install --upgrade -r build/test-requirements.txt - - - name: Run Pyright - uses: jakebailey/pyright-action@v1 - with: - working-directory: 'pythonFiles' - ### Non-smoke tests tests: name: Tests @@ -92,10 +33,10 @@ jobs: 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] + os: [ubuntu-latest] # Run the tests on the oldest and most recent versions of Python. - python: ['2.7', '3.x'] - test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] + python: ['3.x'] + test-suite: [venv] exclude: # For fast PR turn-around, skip 2.7 under Windows. - os: windows-latest @@ -297,213 +238,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] - steps: - # Need the source to have the tests available. - - name: Checkout - uses: actions/checkout@v2 - - - name: Smoke tests - uses: ./.github/actions/smoke-tests - with: - node_version: ${{ env.NODE_VERSION }} - artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} - - ### 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 - - - name: Install Node - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - 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 }} - cache: 'pip' - cache-dependency-path: | - requirements.txt - pythonFiles/jedilsp_requirements/requirements.txt - build/test-requirements.txt - build/functional-test-requirements.txt - - - name: Install base Python requirements - uses: brettcannon/pip-secure-install@v1 - with: - options: '-t ./pythonFiles/lib/python --implementation py' - - - name: Install Jedi requirements - uses: brettcannon/pip-secure-install@v1 - with: - requirements-file: './pythonFiles/jedilsp_requirements/requirements.txt' - options: '-t ./pythonFiles/lib/jedilsp --implementation py' - - - name: Install debugpy - run: | - # 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 --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 - & $condaExecPath init --all - - - 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.6 - 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.6 - 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.6 - # 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.6 - # 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 diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 893021a7f73d..fd706931a3fc 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -524,7 +524,13 @@ export class PythonSettings implements IPythonSettings { public initialize(): void { const onDidChange = () => { const currentConfig = this.workspace.getConfiguration('python', this.workspaceRoot); + console.log(`Before update [default]: ${this.defaultInterpreterPath}`); + console.log(`Before update [python]: ${this.pythonPath}`); + console.log(`Changed path [default]: ${currentConfig.get('defaultInterpreterPath')}`); + console.log('Inspect path [default]', JSON.stringify(currentConfig.inspect('defaultInterpreterPath'))); this.update(currentConfig); + console.log(`After update [default]: ${this.defaultInterpreterPath}`); + console.log(`After update [python]: ${this.pythonPath}`); // If workspace config changes, then we could have a cascading effect of on change events. // Let's defer the change notification. diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index a5e5ef6146dc..d55243420e86 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -168,8 +168,6 @@ suite('Activation of Environments in Terminal', () => { if (process.env.CI_PYTHON_VERSION && process.env.CI_PYTHON_VERSION.startsWith('2.')) { this.skip(); } - // https://github.com/microsoft/vscode-python/issues/17666 - this.skip(); await testActivation(envPaths.venvPath); }); test('Should activate with pipenv', async function () { From 933fc09615148131ac6a62e0a076bac5d4c0c095 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 19:48:01 +0530 Subject: [PATCH 2/9] Print envsPath.json --- .../terminalActivation.testvirtualenvs.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index d55243420e86..9a02afd9089b 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -56,6 +56,7 @@ suite('Activation of Environments in Terminal', () => { const sandbox = sinon.createSandbox(); suiteSetup(async () => { envPaths = await fs.readJson(envsLocation); + console.log('Beginning suite', envPaths); 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.defaultProfile.windows').globalValue; @@ -149,6 +150,7 @@ suite('Activation of Environments in Terminal', () => { vscode.ConfigurationTarget.WorkspaceFolder, ); await setGlobalInterpreterPath(envPath); + console.log('Setting global interpreter path', envPath); const content = await openTerminalAndAwaitCommandContent(waitTimeForActivation, file, outputFile, 5_000); expect(fileSystem.arePathsSame(content, envPath)).to.equal(true, 'Environment not activated'); } From 769b7b8003bd85ad8eb8ee70eb518c3bf67ee894 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:03:12 +0530 Subject: [PATCH 3/9] More logging --- src/client/common/interpreterPathService.ts | 2 ++ src/client/common/terminal/activator/base.ts | 1 + .../terminalActivation.testvirtualenvs.ts | 9 +++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/common/interpreterPathService.ts b/src/client/common/interpreterPathService.ts index cf31eaa37d44..f2f2dae13535 100644 --- a/src/client/common/interpreterPathService.ts +++ b/src/client/common/interpreterPathService.ts @@ -71,6 +71,7 @@ export class InterpreterPathService implements IInterpreterPathService { } const defaultInterpreterPath: InspectInterpreterSettingType = this.workspaceService.getConfiguration('python', resource)?.inspect('defaultInterpreterPath') ?? {}; + console.log('DEFAULT SETTING', JSON.stringify(defaultInterpreterPath), resource?.fsPath); return { globalValue: defaultInterpreterPath.globalValue, workspaceFolderValue: workspaceFolderSetting?.value || defaultInterpreterPath.workspaceFolderValue, @@ -80,6 +81,7 @@ export class InterpreterPathService implements IInterpreterPathService { public get(resource: Resource): string { const settings = this.inspect(resource); + console.log('SETTING', JSON.stringify(settings)); const value = settings.workspaceFolderValue || settings.workspaceValue || diff --git a/src/client/common/terminal/activator/base.ts b/src/client/common/terminal/activator/base.ts index 93ee13ccaaf0..2af65bcdb56e 100644 --- a/src/client/common/terminal/activator/base.ts +++ b/src/client/common/terminal/activator/base.ts @@ -31,6 +31,7 @@ export class BaseTerminalActivator implements ITerminalActivator { for (const command of activationCommands) { terminal.show(options?.preserveFocus); terminal.sendText(command); + console.log(`ACTIVATION COMMAND (sent): ${command}`); await this.waitForCommandToProcess(terminalShellType); activated = true; } diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 9a02afd9089b..724d6b46f9a9 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -13,7 +13,7 @@ import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants'; import { PYTHON_PATH, resetGlobalInterpreterPathSetting, - setGlobalInterpreterPath, + setPythonPathInWorkspaceRoot, updateSetting, waitForCondition, } from '../../../common'; @@ -36,7 +36,7 @@ suite('Activation of Environments in Terminal', () => { const envsLocation = PYTHON_VIRTUAL_ENVS_LOCATION !== undefined ? path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) - : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); + : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { condaExecPath: string; @@ -149,8 +149,9 @@ suite('Activation of Environments in Terminal', () => { vscode.workspace.workspaceFolders![0].uri, vscode.ConfigurationTarget.WorkspaceFolder, ); - await setGlobalInterpreterPath(envPath); - console.log('Setting global interpreter path', envPath); + console.log('Setting workspace default interpreter path', envPath); + await setPythonPathInWorkspaceRoot(envPath); + console.log('Finished setting workspace default interpreter path', envPath); const content = await openTerminalAndAwaitCommandContent(waitTimeForActivation, file, outputFile, 5_000); expect(fileSystem.arePathsSame(content, envPath)).to.equal(true, 'Environment not activated'); } From 2618f259e284b2f99ad96487e7e8ee6d9849f229 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:09:18 +0530 Subject: [PATCH 4/9] Oops --- .../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 724d6b46f9a9..b4082c1ee698 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -36,7 +36,7 @@ suite('Activation of Environments in Terminal', () => { const envsLocation = PYTHON_VIRTUAL_ENVS_LOCATION !== undefined ? path.join(EXTENSION_ROOT_DIR_FOR_TESTS, PYTHON_VIRTUAL_ENVS_LOCATION) - : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'envPaths.json'); + : path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'tmp', 'envPaths.json'); const waitTimeForActivation = 5000; type EnvPath = { condaExecPath: string; From 73c5e6ee5996aefde53b0149d066486cc6fe2bbe Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:16:14 +0530 Subject: [PATCH 5/9] Skip all tests --- .../terminalActivation.testvirtualenvs.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index b4082c1ee698..16954f0eb4f8 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -174,17 +174,12 @@ suite('Activation of Environments in Terminal', () => { await testActivation(envPaths.venvPath); }); test('Should activate with pipenv', async function () { - // https://github.com/microsoft/vscode-python/issues/17666 - this.skip(); await testActivation(envPaths.pipenvPath); }); test('Should activate with virtualenv', async function () { - // https://github.com/microsoft/vscode-python/issues/17666 - this.skip(); await testActivation(envPaths.virtualEnvPath); }); test('Should activate with conda', async function () { - this.skip(); // Powershell does not work with conda by default, hence use cmd. await terminalSettings.update( 'integrated.defaultProfile.windows', From e7d3002bb6955c7d15f257d7386d5a8bcf494c51 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:26:16 +0530 Subject: [PATCH 6/9] lets try this --- .../terminalActivation.testvirtualenvs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 16954f0eb4f8..00146ecc56ad 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -13,7 +13,7 @@ import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants'; import { PYTHON_PATH, resetGlobalInterpreterPathSetting, - setPythonPathInWorkspaceRoot, + setGlobalInterpreterPath, updateSetting, waitForCondition, } from '../../../common'; @@ -150,7 +150,7 @@ suite('Activation of Environments in Terminal', () => { vscode.ConfigurationTarget.WorkspaceFolder, ); console.log('Setting workspace default interpreter path', envPath); - await setPythonPathInWorkspaceRoot(envPath); + await setGlobalInterpreterPath(envPath); console.log('Finished setting workspace default interpreter path', envPath); const content = await openTerminalAndAwaitCommandContent(waitTimeForActivation, file, outputFile, 5_000); expect(fileSystem.arePathsSame(content, envPath)).to.equal(true, 'Environment not activated'); From adb226c8f987b0554ada2c86ef6f7d719baeecef Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:38:06 +0530 Subject: [PATCH 7/9] Done investigating --- .github/workflows/pr-check.yml | 275 ++++++++++++++++++- src/client/common/configSettings.ts | 6 - src/client/common/interpreterPathService.ts | 2 - src/client/common/terminal/activator/base.ts | 1 - 4 files changed, 272 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index f06e81a4af27..7ec43a27b925 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -20,6 +20,65 @@ env: special-working-directory-relative: 'path with spaces' jobs: + build-vsix: + name: Create VSIX + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build VSIX + uses: ./.github/actions/build-vsix + with: + node_version: ${{ env.NODE_VERSION}} + vsix_name: ${{ env.VSIX_NAME }} + artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Lint + uses: ./.github/actions/lint + with: + node_version: ${{ env.NODE_VERSION }} + + check-types: + name: Check Python types + runs-on: ubuntu-latest + steps: + - name: Use Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Install base Python requirements + uses: brettcannon/pip-secure-install@v1 + with: + options: '-t ./pythonFiles/lib/python --no-cache-dir --implementation py' + + - name: Install Jedi requirements + uses: brettcannon/pip-secure-install@v1 + with: + requirements-file: './pythonFiles/jedilsp_requirements/requirements.txt' + options: '-t ./pythonFiles/lib/jedilsp --no-cache-dir --implementation py' + + - name: Install other Python requirements + run: | + python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy + python -m pip install --upgrade -r build/test-requirements.txt + + - name: Run Pyright + uses: jakebailey/pyright-action@v1 + with: + working-directory: 'pythonFiles' + ### Non-smoke tests tests: name: Tests @@ -33,10 +92,10 @@ jobs: 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] + os: [ubuntu-latest, windows-latest] # Run the tests on the oldest and most recent versions of Python. - python: ['3.x'] - test-suite: [venv] + python: ['2.7', '3.x'] + 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 @@ -238,3 +297,213 @@ 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] + steps: + # Need the source to have the tests available. + - name: Checkout + uses: actions/checkout@v2 + + - name: Smoke tests + uses: ./.github/actions/smoke-tests + with: + node_version: ${{ env.NODE_VERSION }} + artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} + + ### 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 + + - name: Install Node + uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - 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 }} + cache: 'pip' + cache-dependency-path: | + requirements.txt + pythonFiles/jedilsp_requirements/requirements.txt + build/test-requirements.txt + build/functional-test-requirements.txt + + - name: Install base Python requirements + uses: brettcannon/pip-secure-install@v1 + with: + options: '-t ./pythonFiles/lib/python --implementation py' + + - name: Install Jedi requirements + uses: brettcannon/pip-secure-install@v1 + with: + requirements-file: './pythonFiles/jedilsp_requirements/requirements.txt' + options: '-t ./pythonFiles/lib/jedilsp --implementation py' + + - name: Install debugpy + run: | + # 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 --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 + & $condaExecPath init --all + + - 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.6 + 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.6 + 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.6 + # 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.6 + # 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 diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index fd706931a3fc..893021a7f73d 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -524,13 +524,7 @@ export class PythonSettings implements IPythonSettings { public initialize(): void { const onDidChange = () => { const currentConfig = this.workspace.getConfiguration('python', this.workspaceRoot); - console.log(`Before update [default]: ${this.defaultInterpreterPath}`); - console.log(`Before update [python]: ${this.pythonPath}`); - console.log(`Changed path [default]: ${currentConfig.get('defaultInterpreterPath')}`); - console.log('Inspect path [default]', JSON.stringify(currentConfig.inspect('defaultInterpreterPath'))); this.update(currentConfig); - console.log(`After update [default]: ${this.defaultInterpreterPath}`); - console.log(`After update [python]: ${this.pythonPath}`); // If workspace config changes, then we could have a cascading effect of on change events. // Let's defer the change notification. diff --git a/src/client/common/interpreterPathService.ts b/src/client/common/interpreterPathService.ts index f2f2dae13535..cf31eaa37d44 100644 --- a/src/client/common/interpreterPathService.ts +++ b/src/client/common/interpreterPathService.ts @@ -71,7 +71,6 @@ export class InterpreterPathService implements IInterpreterPathService { } const defaultInterpreterPath: InspectInterpreterSettingType = this.workspaceService.getConfiguration('python', resource)?.inspect('defaultInterpreterPath') ?? {}; - console.log('DEFAULT SETTING', JSON.stringify(defaultInterpreterPath), resource?.fsPath); return { globalValue: defaultInterpreterPath.globalValue, workspaceFolderValue: workspaceFolderSetting?.value || defaultInterpreterPath.workspaceFolderValue, @@ -81,7 +80,6 @@ export class InterpreterPathService implements IInterpreterPathService { public get(resource: Resource): string { const settings = this.inspect(resource); - console.log('SETTING', JSON.stringify(settings)); const value = settings.workspaceFolderValue || settings.workspaceValue || diff --git a/src/client/common/terminal/activator/base.ts b/src/client/common/terminal/activator/base.ts index 2af65bcdb56e..93ee13ccaaf0 100644 --- a/src/client/common/terminal/activator/base.ts +++ b/src/client/common/terminal/activator/base.ts @@ -31,7 +31,6 @@ export class BaseTerminalActivator implements ITerminalActivator { for (const command of activationCommands) { terminal.show(options?.preserveFocus); terminal.sendText(command); - console.log(`ACTIVATION COMMAND (sent): ${command}`); await this.waitForCommandToProcess(terminalShellType); activated = true; } From 03ee6fffc09c92e84fcd902eb24e55893bb3557d Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:39:44 +0530 Subject: [PATCH 8/9] Fix test --- .../terminalActivation.testvirtualenvs.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index 00146ecc56ad..af85d40cc11c 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -12,8 +12,8 @@ import { FileSystem } from '../../../../client/common/platform/fileSystem'; import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../ciConstants'; import { PYTHON_PATH, - resetGlobalInterpreterPathSetting, - setGlobalInterpreterPath, + restorePythonPathInWorkspaceRoot, + setPythonPathInWorkspaceRoot, updateSetting, waitForCondition, } from '../../../common'; @@ -56,7 +56,6 @@ suite('Activation of Environments in Terminal', () => { const sandbox = sinon.createSandbox(); suiteSetup(async () => { envPaths = await fs.readJson(envsLocation); - console.log('Beginning suite', envPaths); 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.defaultProfile.windows').globalValue; @@ -108,7 +107,7 @@ suite('Activation of Environments in Terminal', () => { vscode.ConfigurationTarget.Global, ); await pythonSettings.update('condaPath', undefined, vscode.ConfigurationTarget.Global); - await resetGlobalInterpreterPathSetting(); + await restorePythonPathInWorkspaceRoot(); } /** @@ -149,9 +148,7 @@ suite('Activation of Environments in Terminal', () => { vscode.workspace.workspaceFolders![0].uri, vscode.ConfigurationTarget.WorkspaceFolder, ); - console.log('Setting workspace default interpreter path', envPath); - await setGlobalInterpreterPath(envPath); - console.log('Finished setting workspace default interpreter path', envPath); + await setPythonPathInWorkspaceRoot(envPath); const content = await openTerminalAndAwaitCommandContent(waitTimeForActivation, file, outputFile, 5_000); expect(fileSystem.arePathsSame(content, envPath)).to.equal(true, 'Environment not activated'); } From 792dd9e8b21b7c1b1c08aac93f674512cc1a8f29 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 1 Feb 2022 20:56:29 +0530 Subject: [PATCH 9/9] Skip python2 tests for pipenv --- .../terminalActivation.testvirtualenvs.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts index af85d40cc11c..bdcfbb15db2d 100644 --- a/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts +++ b/src/test/common/terminals/environmentActivationProviders/terminalActivation.testvirtualenvs.ts @@ -171,6 +171,9 @@ suite('Activation of Environments in Terminal', () => { await testActivation(envPaths.venvPath); }); test('Should activate with pipenv', async function () { + if (process.env.CI_PYTHON_VERSION && process.env.CI_PYTHON_VERSION.startsWith('2.')) { + this.skip(); + } await testActivation(envPaths.pipenvPath); }); test('Should activate with virtualenv', async function () {