diff --git a/.github/codecov.yml b/.github/codecov.yml index 9e7bc6e3d208..6242fe9ad403 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -29,6 +29,3 @@ comment: layout: 'diff, files' behavior: default require_changes: no - -fixes: - - 'path with spaces/::' diff --git a/.github/workflows/insiders.yml b/.github/workflows/insiders.yml index 55e2bd9ad187..3922556218e9 100644 --- a/.github/workflows/insiders.yml +++ b/.github/workflows/insiders.yml @@ -9,11 +9,8 @@ env: NODE_VERSION: 12.15.0 PYTHON_VERSION: 3.9 MOCHA_REPORTER_JUNIT: true # 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. - # Key for the cache created at the end of the the 'Cache ./pythonFiles/lib/python' step. - CACHE_PYTHONFILES: cache-pvsc-pythonFiles ARTIFACT_NAME_VSIX: ms-python-insiders-vsix VSIX_NAME: ms-python-insiders.vsix - COVERAGE_REPORTS: tests-coverage-reports TEST_RESULTS_DIRECTORY: . # 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. @@ -100,12 +97,6 @@ jobs: name: 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 }} - env: - # Something in Node 12.16.0 breaks the TS debug adapter, and ubuntu-latest bundles Node 12.16.1. - # We can remove this when we switch over to the python-based DA in https://github.com/microsoft/vscode-python/issues/7136. - # See https://github.com/microsoft/ptvsd/issues/2068 - # At this point pinning is only needed for consistency. We no longer have TS debug adapter. - NODE_VERSION: 12.15.0 defaults: run: working-directory: ${{env.special-working-directory}} @@ -170,9 +161,7 @@ jobs: if: matrix.test-suite == 'debugger' && matrix.python == 2.7 - name: Install functional test requirements - run: | - python -m pip install numpy - python -m pip install --upgrade -r ./build/functional-test-requirements.txt + run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt if: matrix.test-suite == 'functional' - name: Prepare pipenv for venv tests @@ -247,16 +236,7 @@ jobs: # Run TypeScript unit tests only for Python 3.X. - name: Run TypeScript unit tests - run: npm run test:unittests:cover - if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) - - # Upload unit test coverage reports for later use in the "reports" job. - - name: Upload unit test coverage reports - uses: actions/upload-artifact@v2 - with: - name: ${{runner.os}}-${{env.COVERAGE_REPORTS}} - path: ${{ env.special-working-directory }}/.nyc_output - retention-days: 1 + run: npm run test:unittests if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) # Run the Python tests in our codebase. @@ -310,16 +290,7 @@ jobs: # Run TypeScript functional tests - name: Run TypeScript functional tests - run: npm run test:functional:cover - if: matrix.test-suite == 'functional' - - # Upload functional test coverage reports for later use in the "reports" job. - - name: Upload functional test coverage reports - uses: actions/upload-artifact@v2 - with: - name: ${{runner.os}}-${{env.COVERAGE_REPORTS}} - path: ${{ env.special-working-directory }}/.nyc_output - retention-days: 1 + run: npm run test:functional if: matrix.test-suite == 'functional' smoke-tests: @@ -444,92 +415,14 @@ jobs: 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.4 - # with: - # run: node --no-force-async-hooks-checks ./out/test/standardTest.js - - coverage: - name: Coverage reports upload - runs-on: ubuntu-latest - if: github.repository == 'microsoft/vscode-python' - needs: [tests, smoke-tests] - defaults: - run: - working-directory: ${{env.special-working-directory}} - steps: - # Checkout the repo in the same way as how the tests are run, - # or nyc won't know how to reconcile the reports generated by the tests. - - name: Checkout - uses: actions/checkout@v2 - with: - path: ${{env.special-working-directory-relative}} - - - name: Install Node - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{env.NODE_VERSION}} - - - name: Install dependencies (npm ci) - run: npm ci --prefer-offline - - # It isn't possible to specify a regex for artifact names, so we have to download each artifact manually. - # The name pattern is ${{runner.os}}-${{env.COVERAGE_REPORTS}}, and possible values for runner.os are `Linux`, `Windows`, or `macOS`. - # See https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#runner-context - - name: Download Ubuntu test coverage artifacts - uses: actions/download-artifact@v2 - with: - name: Linux-${{ env.COVERAGE_REPORTS }} - path: ${{env.special-working-directory}}/Linux-${{ env.COVERAGE_REPORTS }} - - - name: Extract Ubuntu coverage artifacts to ./nyc_output - run: | - mkdir .nyc_output - mv Linux-${{ env.COVERAGE_REPORTS }}/* .nyc_output - rm -r Linux-${{ env.COVERAGE_REPORTS }} - - - name: Generate coverage reports - run: npm run test:cover:report - continue-on-error: true - - # The only location supported by the codecov action is the workspace root. - # See https://github.com/codecov/codecov-action#arguments - - name: Move codecov.yml to root - run: | - mkdir $GITHUB_WORKSPACE/.github - mv .github/codecov.yml $GITHUB_WORKSPACE - - - name: Upload coverage to codecov - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ${{env.special-working-directory}}/coverage/cobertura-coverage.xml - - upload: - name: Upload VSIX to Azure Blob Storage - if: github.repository == 'microsoft/vscode-python' - runs-on: ubuntu-latest - needs: [tests, smoke-tests, build-vsix] - env: - BLOB_CONTAINER_NAME: extension-builds - BLOB_NAME: ms-python-insiders.vsix - steps: - - name: Download VSIX - uses: actions/download-artifact@v2 - with: - name: ${{ env.ARTIFACT_NAME_VSIX }} - - name: Azure Login - uses: azure/login@v1 + - 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.4 with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - name: Upload to Blob Storage - run: az storage blob upload --file ${{ env.VSIX_NAME }} --account-name pvsc --container-name ${{ env.BLOB_CONTAINER_NAME }} --name ${{ env.BLOB_NAME }} --auth-mode login - - name: Get URL to uploaded VSIX - run: az storage blob url --account-name pvsc --container-name ${{ env.BLOB_CONTAINER_NAME }} --name ${{ env.BLOB_NAME }} --auth-mode login + run: node --no-force-async-hooks-checks ./out/test/standardTest.js diff --git a/.github/workflows/nightly-coverage.yml b/.github/workflows/nightly-coverage.yml new file mode 100644 index 000000000000..e4b08cd42b61 --- /dev/null +++ b/.github/workflows/nightly-coverage.yml @@ -0,0 +1,188 @@ +name: Coverage + +on: + schedule: + # Run daily at 2:00 AM + - cron: '0 2 * * *' + +env: + NODE_VERSION: 12.15.0 + PYTHON_VERSION: 3.9 + MOCHA_REPORTER_JUNIT: true # 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. + ARTIFACT_NAME_VSIX: ms-python-insiders-vsix + VSIX_NAME: ms-python-insiders.vsix + TEST_RESULTS_DIRECTORY: . + +jobs: + tests: + name: Tests with 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: + # 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@v2 + + - name: Install Node + uses: actions/setup-node@v2.1.5 + with: + node-version: ${{env.NODE_VERSION}} + + - 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 + + - 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 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 + + # 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.4 + 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.4 + 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.4 + # 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.4 + # with: + # run: npm run testDebugger:cover + + - 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 + + - name: Upload coverage to codecov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage/cobertura-coverage.xml diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 80be9ab71961..d76124c38c7b 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -11,11 +11,8 @@ env: NODE_VERSION: 12.15.0 PYTHON_VERSION: 3.9 MOCHA_REPORTER_JUNIT: true # 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. - # Key for the cache created at the end of the the 'Cache ./pythonFiles/lib/python' step. - CACHE_PYTHONFILES: cache-pvsc-pythonFiles ARTIFACT_NAME_VSIX: ms-python-insiders-vsix VSIX_NAME: ms-python-insiders.vsix - COVERAGE_REPORTS: tests-coverage-reports TEST_RESULTS_DIRECTORY: . # 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. @@ -100,12 +97,6 @@ jobs: name: 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 }} - env: - # Something in Node 12.16.0 breaks the TS debug adapter, and ubuntu-latest bundles Node 12.16.1. - # We can remove this when we switch over to the python-based DA in https://github.com/microsoft/vscode-python/issues/7136. - # See https://github.com/microsoft/ptvsd/issues/2068 - # At this point pinning is only needed for consistency. We no longer have TS debug adapter. - NODE_VERSION: 12.15.0 defaults: run: working-directory: ${{env.special-working-directory}} @@ -173,9 +164,7 @@ jobs: if: matrix.test-suite == 'debugger' && matrix.python == 2.7 - name: Install functional test requirements - run: | - python -m pip install numpy - python -m pip install --upgrade -r ./build/functional-test-requirements.txt + run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt if: matrix.test-suite == 'functional' - name: Prepare pipenv for venv tests @@ -250,16 +239,7 @@ jobs: # Run TypeScript unit tests only for Python 3.X. - name: Run TypeScript unit tests - run: npm run test:unittests:cover - if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) - - # Upload unit test coverage reports for later use in the "reports" job. - - name: Upload unit test coverage reports - uses: actions/upload-artifact@v2 - with: - name: ${{runner.os}}-${{env.COVERAGE_REPORTS}} - path: ${{ env.special-working-directory }}/.nyc_output - retention-days: 1 + run: npm run test:unittests if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) # Run the Python tests in our codebase. @@ -313,16 +293,7 @@ jobs: # Run TypeScript functional tests - name: Run TypeScript functional tests - run: npm run test:functional:cover - if: matrix.test-suite == 'functional' - - # Upload functional test coverage reports for later use in the "reports" job. - - name: Upload functional test coverage reports - uses: actions/upload-artifact@v2 - with: - name: ${{runner.os}}-${{env.COVERAGE_REPORTS}} - path: ${{ env.special-working-directory }}/.nyc_output - retention-days: 1 + run: npm run test:functional if: matrix.test-suite == 'functional' smoke-tests: @@ -445,32 +416,32 @@ jobs: 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.4 - # with: - # run: node --no-force-async-hooks-checks ./out/test/standardTest.js + - 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.4 + with: + run: node --no-force-async-hooks-checks ./out/test/standardTest.js + ### Coverage run coverage: - name: Coverage reports upload - runs-on: ubuntu-latest - needs: [tests, smoke-tests] - defaults: - run: - working-directory: ${{env.special-working-directory}} + 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: - # Checkout the repo in the same way as how the tests are run, - # or nyc won't know how to reconcile the reports generated by the tests. - name: Checkout uses: actions/checkout@v2 - with: - path: ${{env.special-working-directory-relative}} - name: Install Node uses: actions/setup-node@v2.1.5 @@ -478,37 +449,160 @@ jobs: node-version: ${{env.NODE_VERSION}} - name: Install dependencies (npm ci) - run: npm ci --prefer-offline + run: npm ci - # It isn't possible to specify a regex for artifact names, so we have to download each artifact manually. - # The name pattern is ${{runner.os}}-${{env.COVERAGE_REPORTS}}, and possible values for runner.os are `Linux`, `Windows`, or `macOS`. - # See https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions#runner-context - - name: Download Ubuntu test coverage artifacts - uses: actions/download-artifact@v2 + - name: Compile + run: npx gulp prePublishNonBundle + + - name: Use Python ${{env.PYTHON_VERSION}} + uses: actions/setup-python@v2 with: - name: Linux-${{ env.COVERAGE_REPORTS }} - path: ${{env.special-working-directory}}/Linux-${{ env.COVERAGE_REPORTS }} + python-version: ${{env.PYTHON_VERSION}} + + - name: Install Node + uses: actions/setup-node@v2.1.5 + with: + node-version: ${{env.NODE_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 + + - 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 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: Extract Ubuntu coverage artifacts to ./nyc_output + - name: Prepare venv for venv tests + env: + TEST_FILES_SUFFIX: testvirtualenvs + PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' + shell: pwsh run: | - mkdir .nyc_output - mv Linux-${{ env.COVERAGE_REPORTS }}/* .nyc_output - rm -r Linux-${{ env.COVERAGE_REPORTS }} + 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 + + # 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.4 + 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.4 + 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.4 + # 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.4 + # 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 - continue-on-error: true - # The only location supported by the codecov action is the workspace root. - # See https://github.com/codecov/codecov-action#arguments - - name: Move codecov.yml to root - run: | - mkdir $GITHUB_WORKSPACE/.github - mv .github/codecov.yml $GITHUB_WORKSPACE + - name: Upload HTML report + uses: actions/upload-artifact@v2 + with: + name: ${{ runner.os }}-coverage-report-html + path: ./coverage + retention-days: 1 - name: Upload coverage to codecov uses: codecov/codecov-action@v1 with: # Can't use the token to disambiguate since secrets aren't available from PR-triggered runs. #token: ${{ secrets.CODECOV_TOKEN }} - file: ${{env.special-working-directory}}/coverage/cobertura-coverage.xml + file: ./coverage/cobertura-coverage.xml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f59ea2c5837..02e00dbf0a7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,6 @@ env: CACHE_PYTHONFILES: cache-pvsc-pythonFiles ARTIFACT_NAME_VSIX: ms-python-release-vsix VSIX_NAME: ms-python-release.vsix - COVERAGE_REPORTS: tests-coverage-reports TEST_RESULTS_DIRECTORY: . jobs: @@ -90,11 +89,6 @@ jobs: # 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 }} env: - # Something in Node 12.16.0 breaks the TS debug adapter, and ubuntu-latest bundles Node 12.16.1. - # We can remove this when we switch over to the python-based DA in https://github.com/microsoft/vscode-python/issues/7136. - # See https://github.com/microsoft/ptvsd/issues/2068 - # At this point pinning is only needed for consistency. We no longer have TS debug adapter. - NODE_VERSION: 12.15.0 # 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' @@ -163,9 +157,7 @@ jobs: if: matrix.test-suite == 'debugger' && matrix.python == 2.7 - name: Install functional test requirements - run: | - python -m pip install numpy - python -m pip install --upgrade -r ./build/functional-test-requirements.txt + run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt if: matrix.test-suite == 'functional' - name: Prepare pipenv for venv tests @@ -240,7 +232,7 @@ jobs: # Run TypeScript unit tests only for Python 3.X. - name: Run TypeScript unit tests - run: npm run test:unittests:cover + run: npm run test:unittests if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) # Run the Python tests in our codebase. @@ -294,16 +286,7 @@ jobs: # Run TypeScript functional tests - name: Run TypeScript functional tests - run: npm run test:functional:cover - if: matrix.test-suite == 'functional' - - # Upload functional test coverage reports for later use in the "reports" job. - - name: Upload functional test coverage reports - uses: actions/upload-artifact@v2 - with: - name: ${{runner.os}}-${{env.COVERAGE_REPORTS}} - path: ${{ env.special-working-directory }}/.nyc_output - retention-days: 1 + run: npm run test:functional if: matrix.test-suite == 'functional' smoke-tests: diff --git a/build/.nycrc b/build/.nycrc index bfd7cfc2ad9e..b92a4f36785d 100644 --- a/build/.nycrc +++ b/build/.nycrc @@ -2,8 +2,7 @@ "extends": "@istanbuljs/nyc-config-typescript", "all": true, "include": [ - "src/client/**/*.ts", "out/client/**/*.js", - "src/startPage-ui/**/*.ts", "out/startPage-ui/**/*.js" + "src/client/**/*.ts", "out/client/**/*.js" ], "exclude": ["src/test/**/*.ts", "out/test/**/*.js"], "exclude-node-modules": true diff --git a/build/functional-test-requirements.txt b/build/functional-test-requirements.txt index d2f1977a7be4..d45208f671f4 100644 --- a/build/functional-test-requirements.txt +++ b/build/functional-test-requirements.txt @@ -1,2 +1,3 @@ # List of requirements for functional tests versioneer +numpy diff --git a/package.json b/package.json index b3cc146a2f3d..6a56deed2e45 100644 --- a/package.json +++ b/package.json @@ -1976,7 +1976,9 @@ "test:functional:cover": "nyc --no-clean --nycrc-path ./build/.nycrc mocha --require source-map-support/register --config ./build/.mocha.functional.json", "test:cover:report": "nyc --nycrc-path ./build/.nycrc report --reporter=text --reporter=html --reporter=text-summary --reporter=cobertura", "testDebugger": "node ./out/test/testBootstrap.js ./out/test/debuggerTest.js", + "testDebugger:cover": "nyc --no-clean --use-spawn-wrap --nycrc-path ./build/.nycrc --require source-map-support/register node ./out/test/debuggerTest.js", "testSingleWorkspace": "node ./out/test/testBootstrap.js ./out/test/standardTest.js", + "testSingleWorkspace:cover": "nyc --no-clean --use-spawn-wrap --nycrc-path ./build/.nycrc --require source-map-support/register node ./out/test/standardTest.js", "preTestJediLSP": "node ./out/test/languageServers/jedi/lspSetup.js", "testJediLSP": "node ./out/test/languageServers/jedi/lspSetup.js && cross-env CODE_TESTS_WORKSPACE=src/test VSC_PYTHON_CI_TEST_GREP='Language Server:' node ./out/test/testBootstrap.js ./out/test/standardTest.js && node ./out/test/languageServers/jedi/lspTeardown.js", "testMultiWorkspace": "node ./out/test/testBootstrap.js ./out/test/multiRootTest.js",