From 6e302b7431cdfb3cced72ed9339d09393a190334 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 13:58:45 +0530 Subject: [PATCH 1/9] Attempt to fix CI --- src/test/linters/lint.multiroot.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/linters/lint.multiroot.test.ts b/src/test/linters/lint.multiroot.test.ts index f1eaa0bdf803..3466f9bf7f93 100644 --- a/src/test/linters/lint.multiroot.test.ts +++ b/src/test/linters/lint.multiroot.test.ts @@ -12,6 +12,14 @@ import { ProductService } from '../../client/common/installer/productService'; import { IProductPathService, IProductService } from '../../client/common/installer/types'; import { IConfigurationService, Product, ProductType } from '../../client/common/types'; import { OSType } from '../../client/common/utils/platform'; +import { PythonPathUpdaterService } from '../../client/interpreter/configuration/pythonPathUpdaterService'; +import { PythonPathUpdaterServiceFactory } from '../../client/interpreter/configuration/pythonPathUpdaterServiceFactory'; +import { + IPythonPathUpdaterServiceManager, + IPythonPathUpdaterServiceFactory, +} from '../../client/interpreter/configuration/types'; +import { IActivatedEnvironmentLaunch } from '../../client/interpreter/contracts'; +import { ActivatedEnvironmentLaunch } from '../../client/interpreter/virtualEnvs/activatedEnvLaunch'; import { ILinter, ILinterManager } from '../../client/linters/types'; import { isOs } from '../common'; import { TEST_TIMEOUT } from '../constants'; @@ -50,6 +58,18 @@ suite('Multiroot Linting', () => { ioc.registerVariableTypes(); ioc.registerFileSystemTypes(); await ioc.registerMockInterpreterTypes(); + ioc.serviceManager.addSingleton( + IActivatedEnvironmentLaunch, + ActivatedEnvironmentLaunch, + ); + ioc.serviceManager.addSingleton( + IPythonPathUpdaterServiceManager, + PythonPathUpdaterService, + ); + ioc.serviceManager.addSingleton( + IPythonPathUpdaterServiceFactory, + PythonPathUpdaterServiceFactory, + ); ioc.registerInterpreterStorageTypes(); ioc.serviceManager.addSingletonInstance(IProductService, new ProductService()); ioc.serviceManager.addSingleton( From 05a3ccdbfdc1df90d2a5dfbe4b2c4c291185b705 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 14:01:27 +0530 Subject: [PATCH 2/9] Only run multiroot test on ubunut --- .github/workflows/pr-check.yml | 223 ++------------------------------- 1 file changed, 11 insertions(+), 212 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index ab615f33b888..7d84622329fe 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -92,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, windows-latest] + os: [ubuntu-latest] # Run the tests on the oldest and most recent versions of Python. python: ['3.x'] - test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] + test-suite: [multi-workspace] steps: - name: Checkout @@ -275,6 +275,15 @@ jobs: working-directory: ${{ env.special-working-directory }} if: matrix.test-suite == 'multi-workspace' + - name: Run multi-workspace tests + env: + CI_PYTHON_VERSION: ${{ matrix.python }} + uses: GabrielBB/xvfb-action@v1.6 + with: + run: npm run testMultiWorkspace + working-directory: ${{ env.special-working-directory }} + if: matrix.test-suite == 'multi-workspace' + - name: Run debugger tests env: CI_PYTHON_VERSION: ${{ matrix.python }} @@ -288,213 +297,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@v3 - - - 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@v3 - - - name: Install Node - uses: actions/setup-node@v3 - 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@v4 - 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@v3 - with: - name: ${{ runner.os }}-coverage-report-html - path: ./coverage - retention-days: 1 From dbf4130e89de7b1c552193e961ca64fd1bd3a09a Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 14:38:47 +0530 Subject: [PATCH 3/9] Try something --- src/client/common/process/pythonExecutionFactory.ts | 10 +++++----- src/test/index.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/common/process/pythonExecutionFactory.ts b/src/client/common/process/pythonExecutionFactory.ts index fc13e7f2346c..3def2c20d08e 100644 --- a/src/client/common/process/pythonExecutionFactory.ts +++ b/src/client/common/process/pythonExecutionFactory.ts @@ -3,7 +3,7 @@ import { inject, injectable } from 'inversify'; import { IEnvironmentActivationService } from '../../interpreter/activation/types'; -import { IActivatedEnvironmentLaunch, IComponentAdapter } from '../../interpreter/contracts'; +import { IComponentAdapter } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; @@ -52,10 +52,10 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { public async create(options: ExecutionFactoryCreationOptions): Promise { let { pythonPath } = options; if (!pythonPath || pythonPath === 'python') { - const activatedEnvLaunch = this.serviceContainer.get( - IActivatedEnvironmentLaunch, - ); - await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv(); + // const activatedEnvLaunch = this.serviceContainer.get( + // IActivatedEnvironmentLaunch, + // ); + // await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv(); // If python path wasn't passed in, we need to auto select it and then read it // from the configuration. const interpreterPath = this.interpreterPathExpHelper.get(options.resource); diff --git a/src/test/index.ts b/src/test/index.ts index 60c730bffcf2..684d4ea8c46a 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -52,7 +52,7 @@ function configure(): SetupOptions { process.env.IS_MULTI_ROOT_TEST = IS_MULTI_ROOT_TEST.toString(); // Check for a grep setting. Might be running a subset of the tests - const defaultGrep = process.env.VSC_PYTHON_CI_TEST_GREP; + const defaultGrep = 'ultiroot Linting'; // Check whether to invert the grep (i.e. test everything that doesn't include the grep). const invert = (process.env.VSC_PYTHON_CI_TEST_INVERT_GREP || '').length > 0; From 30a8b2cf02b61a8193a4fe5b5aff8c9462ebb271 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 15:06:06 +0530 Subject: [PATCH 4/9] Try something --- src/test/linters/lint.multiroot.test.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/test/linters/lint.multiroot.test.ts b/src/test/linters/lint.multiroot.test.ts index 3466f9bf7f93..85d1cbe3afeb 100644 --- a/src/test/linters/lint.multiroot.test.ts +++ b/src/test/linters/lint.multiroot.test.ts @@ -33,22 +33,22 @@ suite('Multiroot Linting', () => { const flake8Setting = 'linting.flake8Enabled'; let ioc: UnitTestIocContainer; - suiteSetup(function () { + suiteSetup(async function () { if (!IS_MULTI_ROOT_TEST) { this.skip(); } - return initialize(); - }); - setup(async () => { + await initialize(); await initializeDI(); await initializeTest(); }); - suiteTeardown(closeActiveWindows); - teardown(async () => { + suiteTeardown(async () => { await ioc.dispose(); await closeActiveWindows(); PythonSettings.dispose(); }); + teardown(async () => { + await closeActiveWindows(); + }); async function initializeDI() { ioc = new UnitTestIocContainer(); @@ -109,11 +109,8 @@ suite('Multiroot Linting', () => { assert.strictEqual(messages.length > 0, mustHaveErrors, errorMessage); } - test('Enabling Pylint in root and also in Workspace, should return errors', async function () { + test('Enabling Pylint in root and also in Workspace, should return errors', async () => { // Timing out on Windows, tracked by #18337. - if (isOs(OSType.Windows)) { - return this.skip(); - } await runTest(Product.pylint, true, true, pylintSetting); From ae7f466d7d01b5729661a8c5e8344e934e41c444 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 15:15:50 +0530 Subject: [PATCH 5/9] Put it back in --- .github/workflows/pr-check.yml | 9 --------- src/client/common/process/pythonExecutionFactory.ts | 10 +++++----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 7d84622329fe..a81d29d5125a 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -275,15 +275,6 @@ jobs: working-directory: ${{ env.special-working-directory }} if: matrix.test-suite == 'multi-workspace' - - name: Run multi-workspace tests - env: - CI_PYTHON_VERSION: ${{ matrix.python }} - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testMultiWorkspace - working-directory: ${{ env.special-working-directory }} - if: matrix.test-suite == 'multi-workspace' - - name: Run debugger tests env: CI_PYTHON_VERSION: ${{ matrix.python }} diff --git a/src/client/common/process/pythonExecutionFactory.ts b/src/client/common/process/pythonExecutionFactory.ts index 3def2c20d08e..fc13e7f2346c 100644 --- a/src/client/common/process/pythonExecutionFactory.ts +++ b/src/client/common/process/pythonExecutionFactory.ts @@ -3,7 +3,7 @@ import { inject, injectable } from 'inversify'; import { IEnvironmentActivationService } from '../../interpreter/activation/types'; -import { IComponentAdapter } from '../../interpreter/contracts'; +import { IActivatedEnvironmentLaunch, IComponentAdapter } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; @@ -52,10 +52,10 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { public async create(options: ExecutionFactoryCreationOptions): Promise { let { pythonPath } = options; if (!pythonPath || pythonPath === 'python') { - // const activatedEnvLaunch = this.serviceContainer.get( - // IActivatedEnvironmentLaunch, - // ); - // await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv(); + const activatedEnvLaunch = this.serviceContainer.get( + IActivatedEnvironmentLaunch, + ); + await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv(); // If python path wasn't passed in, we need to auto select it and then read it // from the configuration. const interpreterPath = this.interpreterPathExpHelper.get(options.resource); From 972e1ac5cac15b5bbe69d83e714d09ba91280190 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 15:29:42 +0530 Subject: [PATCH 6/9] Undo --- src/test/index.ts | 2 +- src/test/linters/lint.multiroot.test.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/index.ts b/src/test/index.ts index 684d4ea8c46a..60c730bffcf2 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -52,7 +52,7 @@ function configure(): SetupOptions { process.env.IS_MULTI_ROOT_TEST = IS_MULTI_ROOT_TEST.toString(); // Check for a grep setting. Might be running a subset of the tests - const defaultGrep = 'ultiroot Linting'; + const defaultGrep = process.env.VSC_PYTHON_CI_TEST_GREP; // Check whether to invert the grep (i.e. test everything that doesn't include the grep). const invert = (process.env.VSC_PYTHON_CI_TEST_INVERT_GREP || '').length > 0; diff --git a/src/test/linters/lint.multiroot.test.ts b/src/test/linters/lint.multiroot.test.ts index 85d1cbe3afeb..a812788f10c0 100644 --- a/src/test/linters/lint.multiroot.test.ts +++ b/src/test/linters/lint.multiroot.test.ts @@ -109,8 +109,11 @@ suite('Multiroot Linting', () => { assert.strictEqual(messages.length > 0, mustHaveErrors, errorMessage); } - test('Enabling Pylint in root and also in Workspace, should return errors', async () => { + test('Enabling Pylint in root and also in Workspace, should return errors', async function () { // Timing out on Windows, tracked by #18337. + if (isOs(OSType.Windows)) { + return this.skip(); + } await runTest(Product.pylint, true, true, pylintSetting); From cba635a9e2810b06d6251317475cedc1bbcbd44d Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 15:36:50 +0530 Subject: [PATCH 7/9] Revert "Only run multiroot test on ubunut" This reverts commit 05a3ccdbfdc1df90d2a5dfbe4b2c4c291185b705. --- .github/workflows/pr-check.yml | 214 ++++++++++++++++++++++++++++++++- 1 file changed, 212 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a81d29d5125a..ab615f33b888 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -92,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: [multi-workspace] + test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] steps: - name: Checkout @@ -288,3 +288,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@v3 + + - 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@v3 + + - name: Install Node + uses: actions/setup-node@v3 + 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@v4 + 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@v3 + with: + name: ${{ runner.os }}-coverage-report-html + path: ./coverage + retention-days: 1 From 973aca096ed7b55f390fac7d1b67a9fd6d61265e Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 15:45:59 +0530 Subject: [PATCH 8/9] Fix --- src/test/linters/lint.multiroot.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/linters/lint.multiroot.test.ts b/src/test/linters/lint.multiroot.test.ts index a812788f10c0..f89ee86c0b42 100644 --- a/src/test/linters/lint.multiroot.test.ts +++ b/src/test/linters/lint.multiroot.test.ts @@ -42,7 +42,7 @@ suite('Multiroot Linting', () => { await initializeTest(); }); suiteTeardown(async () => { - await ioc.dispose(); + await ioc?.dispose(); await closeActiveWindows(); PythonSettings.dispose(); }); From c42c30fe21de5104372538b8287bccc2974ed2c1 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 1 Feb 2023 15:55:50 +0530 Subject: [PATCH 9/9] Attempt to fix lint --- pythonFiles/testing_tools/adapter/info.py | 1 - pythonFiles/testing_tools/adapter/pytest/_discovery.py | 4 ++-- .../testing_tools/adapter/pytest/test_discovery.py | 5 +---- .../tests/testing_tools/adapter/test___main__.py | 10 +++++----- .../tests/testing_tools/adapter/test_discovery.py | 5 ++--- pythonFiles/unittestadapter/execution.py | 1 - 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/pythonFiles/testing_tools/adapter/info.py b/pythonFiles/testing_tools/adapter/info.py index f99ce0b6f9a2..d518a29dd97a 100644 --- a/pythonFiles/testing_tools/adapter/info.py +++ b/pythonFiles/testing_tools/adapter/info.py @@ -27,7 +27,6 @@ def __init__(self, *args, **kwargs): class ParentInfo(namedtuple("ParentInfo", "id kind name root relpath parentid")): - KINDS = ("folder", "file", "suite", "function", "subtest") def __new__(cls, id, kind, name, root=None, relpath=None, parentid=None): diff --git a/pythonFiles/testing_tools/adapter/pytest/_discovery.py b/pythonFiles/testing_tools/adapter/pytest/_discovery.py index 34312dcc1997..4b852ecf81c9 100644 --- a/pythonFiles/testing_tools/adapter/pytest/_discovery.py +++ b/pythonFiles/testing_tools/adapter/pytest/_discovery.py @@ -7,7 +7,7 @@ import pytest -from .. import util, discovery +from .. import discovery, util from ._pytest_item import parse_item @@ -26,7 +26,7 @@ def discover( pytestargs = _adjust_pytest_args(pytestargs) # We use this helper rather than "-pno:terminal" due to possible # platform-dependent issues. - with (util.hide_stdio() if hidestdio else util.noop_cm()) as stdio: + with util.hide_stdio() if hidestdio else util.noop_cm() as stdio: ec = _pytest_main(pytestargs, [_plugin]) # See: https://docs.pytest.org/en/latest/usage.html#possible-exit-codes if ec == 5: diff --git a/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py b/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py index c3b8a2d679d1..83eeaa1f9062 100644 --- a/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py +++ b/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py @@ -46,7 +46,6 @@ def main(self, args, plugins): class StubPlugin(util.StubProxy): - _started = True def __init__(self, stub=None, tests=None): @@ -66,7 +65,6 @@ def func(*args, **kwargs): class StubDiscoveredTests(util.StubProxy): - NOT_FOUND = object() def __init__(self, stub=None): @@ -105,7 +103,6 @@ def __init__(self, name): class StubPytestItem(util.StubProxy): - _debugging = False _hasfunc = True @@ -218,6 +215,7 @@ def normcase(path): else: raise NotImplementedError + ########## def _fix_fileid(*args): return adapter_util.fix_fileid( @@ -332,7 +330,6 @@ def ret(args, plugins): class DiscoverTests(unittest.TestCase): - DEFAULT_ARGS = [ "--collect-only", ] diff --git a/pythonFiles/tests/testing_tools/adapter/test___main__.py b/pythonFiles/tests/testing_tools/adapter/test___main__.py index d0a778c1d024..5ff0ec30c947 100644 --- a/pythonFiles/tests/testing_tools/adapter/test___main__.py +++ b/pythonFiles/tests/testing_tools/adapter/test___main__.py @@ -3,14 +3,15 @@ import unittest -from ...util import Stub, StubProxy from testing_tools.adapter.__main__ import ( - parse_args, - main, - UnsupportedToolError, UnsupportedCommandError, + UnsupportedToolError, + main, + parse_args, ) +from ...util import Stub, StubProxy + class StubTool(StubProxy): def __init__(self, name, stub=None): @@ -115,7 +116,6 @@ def test_unsupported_tool(self): class MainTests(unittest.TestCase): - # TODO: We could use an integration test for pytest.discover(). def test_discover(self): diff --git a/pythonFiles/tests/testing_tools/adapter/test_discovery.py b/pythonFiles/tests/testing_tools/adapter/test_discovery.py index ec3d198b0108..cf3b8fb3139b 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_discovery.py +++ b/pythonFiles/tests/testing_tools/adapter/test_discovery.py @@ -5,13 +5,12 @@ import unittest +from testing_tools.adapter.discovery import DiscoveredTests, fix_nodeid +from testing_tools.adapter.info import ParentInfo, SingleTestInfo, SingleTestPath from testing_tools.adapter.util import fix_path, fix_relpath -from testing_tools.adapter.info import SingleTestInfo, SingleTestPath, ParentInfo -from testing_tools.adapter.discovery import fix_nodeid, DiscoveredTests def _fix_nodeid(nodeid): - nodeid = nodeid.replace("\\", "/") if not nodeid.startswith("./"): nodeid = "./" + nodeid diff --git a/pythonFiles/unittestadapter/execution.py b/pythonFiles/unittestadapter/execution.py index a016ff1af9ec..a926bcdcc09e 100644 --- a/pythonFiles/unittestadapter/execution.py +++ b/pythonFiles/unittestadapter/execution.py @@ -60,7 +60,6 @@ class TestOutcomeEnum(str, enum.Enum): class UnittestTestResult(unittest.TextTestResult): - formatted: Dict[str, Dict[str, str | None]] = dict() def startTest(self, test: unittest.TestCase):