Skip to content

Commit

Permalink
Create test for virtual environment (microsoft#6007)
Browse files Browse the repository at this point in the history
* Create test for virtual environment

* Figure out why python path test is failing

* Eliminate quotes on venv_path

* Actually set the python path

* Try just printing path on windows

* Print a different variable

* Try other echo patterns

* user powershell commands to append

* Fix prettier
  • Loading branch information
rchiodo authored Sep 25, 2023
1 parent 0e95e48 commit 21aee77
Show file tree
Hide file tree
Showing 4 changed files with 817 additions and 551 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: 'Validation'

env:
NODE_VERSION: '16' # Shipped with VS Code.
PYTHON_VERSION: 3.11

on:
push:
Expand Down Expand Up @@ -107,6 +108,48 @@ jobs:
run: npm test
working-directory: packages/pyright-internal

# Install python so we can create a VENV for tests
- name: Use Python ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v4
id: install_python
with:
python-version: ${{env.PYTHON_VERSION}}

- name: Create Venv
run: |
${{ steps.install_python.outputs.python-path }} -m venv .venv
- name: Activate and install pytest (linux)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
python -m pip install pytest
python -c "import sys;print('python_venv_path=' + sys.executable)" >> $GITHUB_ENV
- name: Activate and install pytest (windows)
if: runner.os == 'Windows'
run: |
.venv\scripts\activate
python -m pip install pytest
python -c "import sys;print('python_venv_path=' + sys.executable)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Echo python_venv_path
run: |
echo python_venv_path=${{env.python_venv_path}}
- name: Run import tests with venv
env:
CI_IMPORT_TEST_VENVPATH: '../../'
CI_IMPORT_TEST_VENV: '.venv'
run: npm run test:imports
working-directory: packages/pyright-internal

- name: Run import tests with pythonpath
env:
CI_IMPORT_TEST_PYTHONPATH: ${{env.python_venv_path}}
run: npm run test:imports
working-directory: packages/pyright-internal

build:
runs-on: ubuntu-latest
name: Build
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,7 @@ junit.xml

# OS files
.DS_Store
Thumbs.db
Thumbs.db

# Potential venv
.venv
3 changes: 2 additions & 1 deletion packages/pyright-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"build": "tsc",
"clean": "shx rm -rf ./dist ./out",
"test": "jest --forceExit",
"test:coverage": "jest --forceExit --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --coverageReporters=html --coverageReporters=json"
"test:coverage": "jest --forceExit --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --coverageReporters=html --coverageReporters=json",
"test:imports": "jest importResolver.test --forceExit --runInBand"
},
"dependencies": {
"@iarna/toml": "2.2.5",
Expand Down
Loading

0 comments on commit 21aee77

Please sign in to comment.