Skip to content

Clear environment collection only after all async operations are done… #1518

Clear environment collection only after all async operations are done…

Clear environment collection only after all async operations are done… #1518

Workflow file for this run

name: Build
on:
push:
branches:
- 'main'
- 'release'
- 'release/*'
- 'release-*'
env:
NODE_VERSION: 16.17.1
PYTHON_VERSION: '3.10' # YML treats 3.10 the number as 3.1, so quotes around 3.10
# Force a path with spaces and to test extension works in these scenarios
# Unicode characters are causing 2.7 failures so skip that for now.
special-working-directory: './path with spaces'
special-working-directory-relative: 'path with spaces'
# Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter).
# Also enables a reporter which exits the process running the tests if it haven't already.
MOCHA_REPORTER_JUNIT: true
jobs:
setup:
name: Set up
if: github.repository == 'microsoft/vscode-python'
runs-on: ubuntu-latest
defaults:
run:
shell: python
outputs:
vsix_name: ${{ steps.vsix_names.outputs.vsix_name }}
vsix_artifact_name: ${{ steps.vsix_names.outputs.vsix_artifact_name }}
steps:
- name: VSIX names
id: vsix_names
run: |
import os
if os.environ["GITHUB_REF"].endswith("/main"):
vsix_type = "insiders"
else:
vsix_type = "release"
print(f"::set-output name=vsix_name::ms-python-{vsix_type}.vsix")
print(f"::set-output name=vsix_artifact_name::ms-python-{vsix_type}-vsix")
build-vsix:
name: Create VSIX
if: github.repository == 'microsoft/vscode-python'
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build VSIX
uses: ./.github/actions/build-vsix
with:
node_version: ${{ env.NODE_VERSION }}
vsix_name: ${{ needs.setup.outputs.vsix_name }}
artifact_name: ${{ needs.setup.outputs.vsix_artifact_name }}
lint:
name: Lint
if: github.repository == 'microsoft/vscode-python'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint
uses: ./.github/actions/lint
with:
node_version: ${{ env.NODE_VERSION }}
check-types:
name: Check Python types
if: github.repository == 'microsoft/vscode-python'
runs-on: ubuntu-latest
steps:
- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Checkout
uses: actions/checkout@v4
- name: Install core 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:
version: 1.1.308
working-directory: 'pythonFiles'
### Non-smoke tests
tests:
name: Tests
if: github.repository == 'microsoft/vscode-python'
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ${{ env.special-working-directory }}
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]
python: ['3.x']
test-suite: [ts-unit, python-unit, venv, single-workspace, multi-workspace, debugger, functional]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.special-working-directory-relative }}
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: ${{ env.special-working-directory-relative }}/package-lock.json
- name: Install dependencies (npm ci)
run: npm ci
- name: Compile
run: npx gulp prePublishNonBundle
- name: Install Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Download get-pip.py
run: |
python -m pip install wheel
python -m pip install -r build/build-install-requirements.txt
python ./pythonFiles/download_get_pip.py
shell: bash
- 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 --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
- name: Install core Python requirements
uses: brettcannon/pip-secure-install@v1
with:
requirements-file: '"${{ env.special-working-directory-relative }}/requirements.txt"'
options: '-t "${{ env.special-working-directory-relative }}/pythonFiles/lib/python" --no-cache-dir --implementation py'
if: startsWith(matrix.python, 3.)
- name: Install Jedi requirements
uses: brettcannon/pip-secure-install@v1
with:
requirements-file: '"${{ env.special-working-directory-relative }}/pythonFiles/jedilsp_requirements/requirements.txt"'
options: '-t "${{ env.special-working-directory-relative }}/pythonFiles/lib/jedilsp" --no-cache-dir --implementation py'
if: startsWith(matrix.python, 3.)
- name: Install test requirements
run: python -m pip install --upgrade -r build/test-requirements.txt
- name: Install debugpy wheels (Python ${{ matrix.python }})
run: |
python -m pip install wheel
python -m pip install -r build/build-install-requirements.txt
python ./pythonFiles/install_debugpy.py
shell: bash
if: matrix.test-suite == 'debugger'
- name: Install functional test requirements
run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt
if: matrix.test-suite == 'functional'
- name: Prepare pipenv for venv tests
env:
TEST_FILES_SUFFIX: testvirtualenvs
PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json'
shell: pwsh
if: matrix.test-suite == 'venv'
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
if: matrix.test-suite == 'venv'
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
if: matrix.test-suite == 'venv'
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
if: matrix.test-suite == 'venv' && startsWith(matrix.python, 3.)
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
if: matrix.test-suite == 'venv'
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: 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
if: matrix.test-suite != 'ts-unit'
# Run TypeScript unit tests only for Python 3.X.
- name: Run TypeScript unit tests
run: npm run test:unittests
if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, '3.')
- name: Run Python unit tests
run: python pythonFiles/tests/run_all.py
if: matrix.test-suite == 'python-unit'
# 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: ${{ matrix.python }}
uses: GabrielBB/[email protected]
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/[email protected]
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/[email protected]
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/[email protected]
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
if: github.repository == 'microsoft/vscode-python'
runs-on: ${{ matrix.os }}
needs: [setup, 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:
- name: Checkout
uses: actions/checkout@v4
- name: Smoke tests
uses: ./.github/actions/smoke-tests
with:
node_version: ${{ env.NODE_VERSION }}
artifact_name: ${{ needs.setup.outputs.vsix_artifact_name }}