Skip to content

Commit

Permalink
Add python 3.8 and 3x specific runs (#22023)
Browse files Browse the repository at this point in the history
Closes #22024
  • Loading branch information
karthiknadig authored Sep 18, 2023
1 parent 2df331b commit 05ae266
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 20 deletions.
46 changes: 40 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,45 @@ jobs:
version: 1.1.308
working-directory: 'pythonFiles'

### Non-smoke tests
python-tests:
name: Python 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 }}
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]
# Run the tests on the oldest and most recent versions of Python.
python: ['3.8', '3.x']

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.special-working-directory-relative }}

- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install base 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'

- name: Install test requirements
run: python -m pip install --upgrade -r build/test-requirements.txt

- name: Run Python unit tests
run: python pythonFiles/tests/run_all.py

tests:
name: Tests
if: github.repository == 'microsoft/vscode-python'
Expand All @@ -122,7 +160,7 @@ jobs:
# 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]
test-suite: [ts-unit, venv, single-workspace, multi-workspace, debugger, functional]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -268,10 +306,6 @@ jobs:
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.
Expand Down
50 changes: 40 additions & 10 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,45 @@ jobs:
version: 1.1.308
working-directory: 'pythonFiles'

### Non-smoke tests
python-tests:
name: Python 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 }}
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]
# Run the tests on the oldest and most recent versions of Python.
python: ['3.8', '3.x']

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.special-working-directory-relative }}

- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install base 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'

- name: Install test requirements
run: python -m pip install --upgrade -r build/test-requirements.txt

- name: Run Python unit tests
run: python pythonFiles/tests/run_all.py

tests:
name: Tests
# The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded.
Expand All @@ -96,7 +134,7 @@ jobs:
os: [ubuntu-latest, windows-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: [ts-unit, venv, single-workspace, debugger, functional]

steps:
- name: Checkout
Expand Down Expand Up @@ -139,14 +177,12 @@ jobs:
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
Expand Down Expand Up @@ -243,12 +279,6 @@ jobs:
run: npm run test:unittests
if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.)

# Run the Python tests in our codebase.
- 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.
Expand Down
6 changes: 4 additions & 2 deletions pythonFiles/unittestadapter/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PayloadDict(TypedDict):
class EOTPayloadDict(TypedDict):
"""A dictionary that is used to send a end of transmission post request to the server."""

command_type: Literal["discovery"] | Literal["execution"]
command_type: Union[Literal["discovery"], Literal["execution"]]
eot: bool


Expand Down Expand Up @@ -113,7 +113,9 @@ def discover_tests(
return payload


def post_response(payload: PayloadDict | EOTPayloadDict, port: int, uuid: str) -> None:
def post_response(
payload: Union[PayloadDict, EOTPayloadDict], port: int, uuid: str
) -> None:
# Build the request data (it has to be a POST request or the Node side will not process it), and send it.
addr = ("localhost", port)
data = json.dumps(payload)
Expand Down
6 changes: 4 additions & 2 deletions pythonFiles/unittestadapter/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class PayloadDict(TypedDict):
class EOTPayloadDict(TypedDict):
"""A dictionary that is used to send a end of transmission post request to the server."""

command_type: Literal["discovery"] | Literal["execution"]
command_type: Union[Literal["discovery"], Literal["execution"]]
eot: bool


Expand Down Expand Up @@ -250,7 +250,9 @@ def send_run_data(raw_data, port, uuid):
post_response(payload, port, uuid)


def post_response(payload: PayloadDict | EOTPayloadDict, port: int, uuid: str) -> None:
def post_response(
payload: Union[PayloadDict, EOTPayloadDict], port: int, uuid: str
) -> None:
# Build the request data (it has to be a POST request or the Node side will not process it), and send it.
addr = ("localhost", port)
global __socket
Expand Down

0 comments on commit 05ae266

Please sign in to comment.