Skip to content

Commit

Permalink
Update to latest LSP spec with type name changes (microsoft#286)
Browse files Browse the repository at this point in the history
closes microsoft#161
closes microsoft#159

Updates to latest LSP spec and re-generates lsprotocol package for
following languages:
- [x] python
- [x] rust
- [x] dotnet (C#)

This includes updates to tests and test code generation.
  • Loading branch information
karthiknadig authored Nov 10, 2023
1 parent d1d8d47 commit b96899b
Show file tree
Hide file tree
Showing 57 changed files with 6,479 additions and 4,592 deletions.
139 changes: 85 additions & 54 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use Python 3.7
- name: Use Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8

- name: Pip cache
uses: actions/cache@v3
Expand All @@ -28,8 +28,8 @@ jobs:
run: python -m pip install nox
shell: bash

- name: Build sdist and wheels
run: python -m nox --session build
- name: Build pypi package
run: python -m nox --session build_python_package
shell: bash

- name: Upload Python Packages to Artifacts
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout
Expand All @@ -115,6 +115,37 @@ jobs:
run: python -m nox --session tests
shell: bash

rust-tests:
name: 'Rust Tests'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@stable

- name: Install Generator
run: python -m pip install -r ./requirements.txt

- name: Generate Test Data
run: python -m generator --plugin testdata

- name: Rust Run Tests
run: cargo test --manifest-path tests/rust/Cargo.toml
shell: bash
env:
LSP_TEST_DATA_PATH: ${{ github.workspace }}/packages/testdata

dotnet-tests:
name: Dotnet Tests
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -187,52 +218,52 @@ jobs:
if-no-files-found: error
retention-days: 7

smoke-tests:
name: Smoke Tests (pygls)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout Pygls
uses: actions/checkout@v4
with:
repository: openlawlibrary/pygls
path: smoke_tests

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

- name: Update pip, install wheel
run: python -m pip install -U pip wheel
shell: bash

- name: Install pip pygls dependencies
run: python -m pip install typeguard mock pytest pytest-asyncio
shell: bash

- name: Install pip lsprotocol dependencies
run: python -m pip install -r ./packages/python/requirements.txt
shell: bash

- name: Install pygls
run: python -m pip install --no-deps ./smoke_tests
shell: bash

- name: Pip List
run: python -m pip list
shell: bash

- name: Run Tests
run: python -m pytest smoke_tests/tests
env:
PYTHONPATH: ./packages/python
shell: bash
# smoke-tests:
# name: Smoke Tests (pygls)
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-latest, windows-latest]
# python: ['3.8', '3.9', '3.10', '3.11', '3.12']

# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Checkout Pygls
# uses: actions/checkout@v4
# with:
# repository: openlawlibrary/pygls
# path: smoke_tests

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

# - name: Update pip, install wheel
# run: python -m pip install -U pip wheel
# shell: bash

# - name: Install pip pygls dependencies
# run: python -m pip install typeguard mock pytest pytest-asyncio
# shell: bash

# - name: Install pip lsprotocol dependencies
# run: python -m pip install -r ./packages/python/requirements.txt
# shell: bash

# - name: Install pygls
# run: python -m pip install --no-deps ./smoke_tests
# shell: bash

# - name: Pip List
# run: python -m pip list
# shell: bash

# - name: Run Tests
# run: python -m pytest smoke_tests/tests
# env:
# PYTHONPATH: ./packages/python
# shell: bash
39 changes: 35 additions & 4 deletions .github/workflows/push-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use Python 3.7
- name: Use Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8

- name: Pip cache
uses: actions/cache@v3
Expand All @@ -34,7 +34,7 @@ jobs:
shell: bash

- name: Build sdist and wheels
run: python -m nox --session build
run: python -m nox --session build_python_package
shell: bash

- name: Upload Python Packages to Artifacts
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout
Expand All @@ -120,6 +120,37 @@ jobs:
run: python -m nox --session tests
shell: bash

rust-tests:
name: 'Rust Tests'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@stable

- name: Install Generator
run: python -m pip install -r ./requirements.txt

- name: Generate Test Data
run: python -m generator --plugin testdata

- name: Rust Run Tests
run: cargo test --manifest-path tests/rust/Cargo.toml
shell: bash
env:
LSP_TEST_DATA_PATH: ${{ github.workspace }}/packages/testdata

dotnet-tests:
name: Dotnet Tests
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
version = line.split("=")[1].strip().strip('"')
year, minor, micro = version.split(".")
today = datetime.date.today()
if int(year) != today.year:
print(f"Version {version} year should be {today.year}")
if int(year) not in [today.year, today.year + 1]:
print(f"Version {version} year should be {today.year} or {today.year + 1}")
sys.exit(1)

print("Version check passed")
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ packages/rust/**/target/
packages/rust/**/Cargo.lock
packages/dotnet/lsprotocol/bin/
packages/dotnet/lsprotocol/obj/
tests/rust/**/target/
tests/rust/**/Cargo.lock
8 changes: 1 addition & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.black-formatter",
"ms-python.isort"
]
"recommendations": ["esbenp.prettier-vscode", "ms-python.python", "ms-python.vscode-pylance", "charliermarsh.ruff"]
}
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
"source.organizeImports": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": true
}
},
"isort.args": ["--profile", "black"],
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": ["packages/python", "tests/python/common"],
"rust-analyzer.linkedProjects": ["packages/rust/lsprotocol/Cargo.toml"]
"rust-analyzer.linkedProjects": ["packages/rust/lsprotocol/Cargo.toml", "tests/rust/Cargo.toml"]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This repository contains code to generate Language Server Protocol types and cla

You will need a python environment to run the generator. Here are the steps:

1. Create a python environment (min supported python 3.7): `python -m venv .venv`
1. Create a python environment (min supported python 3.8): `python -m venv .venv`
2. Get this tool: `python -m pip install git+https://github.com/microsoft/lsprotocol.git`
3. Run your plugin: `python -m generator --plugin dotnet --output-dir ./code`

Expand Down Expand Up @@ -52,10 +52,10 @@ You can format code, run tests, and other tasks using `nox` as well.

Follow these steps to generate boiler plate code for new plugin:

1. Create a virtual environment for python using python 3.7 and activate that environment.
1. Create a virtual environment for python using python 3.8 and activate that environment.
1. If you have python extension for VS Code installed then run `Python: Create Environment` command. Be sure to select all the `requirements.txt` files in the repo. This should, install all packages needed and select the environment for you.
1. Ensure `nox` is installed.
1. Run `nox --list`, is nox is installed oyu should see a list of available sessions. Otherwise, run `python -m pip install nox` from the python 3.7 environment you created above.
1. Run `nox --list`, is nox is installed oyu should see a list of available sessions. Otherwise, run `python -m pip install nox` from the python 3.8 environment you created above.
1. Run `nox --session create_plugin` and follow the prompts to create a new plugin.

Example:
Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines/release-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ extends:
template: azure-pipelines/pypi-package/pipeline.yml@templates
parameters:
publishPackage: ${{ parameters.publishPackage }}
pythonVersion: '3.7'
pythonVersion: '3.8'
# We don't ship any built in packages.
generateNotice: false
pyProjectTomlPath: $(Build.SourcesDirectory)/packages/python/pyproject.toml
buildSteps:
- script: python -m pip install nox
displayName: Install nox

- script: python -m nox --session build
- script: python -m nox --session build_python_package
displayName: Build package (sdist and wheels)

- publish: $(Build.SourcesDirectory)/packages/python/dist
artifact: dist
displayName: 🚛 Publish artifact
displayName: 🚛 Publish pypi artifact
36 changes: 0 additions & 36 deletions azure-pipelines/release.yml

This file was deleted.

Loading

0 comments on commit b96899b

Please sign in to comment.