Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI issue with venv #17708

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
874603e
Log activated env paths.
karthiknadig Oct 12, 2021
bbdf483
Ensure extension is activated.
karthiknadig Oct 12, 2021
8d3ab58
Check extension activation.
karthiknadig Oct 12, 2021
28ec5ed
Use proposed API to seeif activation occurs.
karthiknadig Oct 12, 2021
d5b54d8
Ensure Python set for testing is same as the one we set.
karthiknadig Oct 12, 2021
d1c2c89
Add wait for the settings to propagate.
karthiknadig Oct 12, 2021
8bdbf4d
Ensure we wait long enough for settings to propagate
karthiknadig Oct 12, 2021
b9f22fa
Ensure settings are propagated.
karthiknadig Oct 12, 2021
08c4ebf
Change settings till it is applied.
karthiknadig Oct 12, 2021
afd6d94
Wait for settings to propagate for much longer.
karthiknadig Oct 12, 2021
80da5d1
Remove settings debounce
karthiknadig Oct 12, 2021
abcd6f5
Ensure global settings are updated during tests
karthiknadig Oct 12, 2021
4a103d2
More minor tweaks
karthiknadig Oct 12, 2021
c73abce
Ensue config change event is fired on vscode.
karthiknadig Oct 12, 2021
747d2ee
More tweaks
karthiknadig Oct 13, 2021
2643d00
Ensure we set the on changed event correctly.
karthiknadig Oct 13, 2021
f06504d
Try again.
karthiknadig Oct 13, 2021
4a1a8e2
Try with additional logging
karthiknadig Oct 13, 2021
fb5181a
More logs
karthiknadig Oct 13, 2021
3a9c87e
Try setting both values.
karthiknadig Oct 13, 2021
4f8845e
More logging
karthiknadig Oct 13, 2021
cb7ad60
More logs
karthiknadig Oct 13, 2021
b4040be
Even More logs
karthiknadig Oct 13, 2021
1cd6951
Log activation command provider
karthiknadig Oct 13, 2021
eb06661
Try forcing interpreter details
karthiknadig Oct 13, 2021
11c5273
Log details
Oct 13, 2021
7527340
Go
Oct 13, 2021
4408d72
More logging
Oct 13, 2021
c7e0d5f
Run only venv tests
Oct 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
315 changes: 3 additions & 312 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ jobs:
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 }}

### Non-smoke tests
tests:
name: Tests
Expand All @@ -59,10 +47,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.9']
test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional]
test-suite: [venv]
exclude:
# For fast PR turn-around, skip 2.7 under Windows.
- os: windows-latest
Expand Down Expand Up @@ -225,306 +213,9 @@ jobs:
env:
TEST_FILES_SUFFIX: testvirtualenvs
CI_PYTHON_VERSION: ${{ matrix.python }}
VSC_PYTHON_FORCE_LOGGING: 1
uses: GabrielBB/xvfb-action@v1.5
with:
run: npm run testSingleWorkspace
working-directory: ${{ env.special-working-directory }}
if: matrix.test-suite == 'venv' && matrix.os == 'ubuntu-latest'

- name: Run single-workspace tests
env:
CI_PYTHON_VERSION: ${{ matrix.python }}
uses: GabrielBB/xvfb-action@v1.5
with:
run: npm run testSingleWorkspace
working-directory: ${{ env.special-working-directory }}
if: matrix.test-suite == 'single-workspace'

- name: Run multi-workspace tests
env:
CI_PYTHON_VERSION: ${{ matrix.python }}
uses: GabrielBB/xvfb-action@v1.5
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 }}
uses: GabrielBB/xvfb-action@v1.5
with:
run: npm run testDebugger
working-directory: ${{ env.special-working-directory }}
if: matrix.test-suite == 'debugger'

# Run TypeScript functional tests
- 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 }}

# 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

# - name: Install Node
# uses: actions/setup-node@v2
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: 'npm'

# - 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

- 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 }}

- 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
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/jedilsp --no-cache-dir --implementation py --no-deps --upgrade -r ./jedils_requirements.txt

- 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

# 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
18 changes: 9 additions & 9 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
ITerminalSettings,
Resource,
} from './types';
import { debounceSync } from './utils/decorators';
import { SystemVariables } from './variables/systemVariables';
import { getOSType, OSType } from './utils/platform';

Expand Down Expand Up @@ -550,11 +549,16 @@ 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<string>('defaultInterpreterPath')}`);
console.log('Inspect path [default]', JSON.stringify(currentConfig.inspect('defaultInterpreterPath')));
console.log(`Changed path [python]: ${currentConfig.get<string>('pythonPath')}`);
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.
this.debounceChangeNotification();
this.changed.fire();
};
this.disposables.push(this.workspace.onDidChangeWorkspaceFolders(this.onWorkspaceFoldersChanged, this));
this.disposables.push(
Expand All @@ -577,11 +581,6 @@ export class PythonSettings implements IPythonSettings {
}
}

@debounceSync(1)
protected debounceChangeNotification(): void {
this.changed.fire();
}

private getPythonPath(
pythonSettings: WorkspaceConfiguration,
systemVariables: SystemVariables,
Expand All @@ -594,6 +593,7 @@ export class PythonSettings implements IPythonSettings {
* `pythonPath` setting, and I've checked that `pythonPath` setting is not accessed anywhere in the constructor.
*/
const inExperiment = this.experimentsManager?.inExperimentSync(DeprecatePythonPath.experiment);
console.log('I should be in experiment', inExperiment);
// Use the interpreter path service if in the experiment otherwise use the normal settings
this.pythonPath = systemVariables.resolveAny(
inExperiment && this.interpreterPathService
Expand Down
Loading