Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: "Lint"
description: "Lint Python code"
name: 'Lint'
description: 'Lint Python code'

runs:
using: "composite"
using: 'composite'
steps:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
python-version: '3.x'

- name: Pip cache
uses: actions/cache@v2
Expand Down Expand Up @@ -43,3 +43,12 @@ runs:
uses: actions-rust-lang/rustfmt@v1
with:
manifest-path: packages/rust/lsprotocol/Cargo.toml

- name: Dotnet Tool Chain setup
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'

- name: Dotnet Format Check
run: dotnet format packages/dotnet/lsprotocol/lsprotocol.csproj --verify-no-changes
shell: bash
40 changes: 38 additions & 2 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Lint
uses: ./.github/actions/lint

tests:
name: Tests
python-tests:
name: Python Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -50,6 +50,42 @@ jobs:
run: python -m nox --session tests
shell: bash

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

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

- name: Dotnet Tool Chain setup
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'

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

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

- name: Generate C# Code
run: python -m generator --plugin dotnet

- name: Dotnet Run Tests
run: dotnet test tests/dotnet/lsprotocol_tests/lsprotocol_tests.csproj
shell: bash
env:
LSP_TEST_DATA_PATH: ${{ github.workspace }}/packages/testdata

smoke-tests:
name: Smoke Tests (pygls)
runs-on: ${{ matrix.os }}
Expand Down
58 changes: 47 additions & 11 deletions .github/workflows/push-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Push Validation
on:
push:
branches:
- "main"
- "release"
- "release/*"
- "release-*"
- 'main'
- 'release'
- 'release/*'
- 'release-*'

jobs:
build-vsix:
Expand All @@ -29,28 +29,64 @@ jobs:
- name: Lint
uses: ./.github/actions/lint

tests:
name: Tests
python-tests:
name: Python Tests
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"]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']

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

- name: Update pip, install wheel and nox
run: python -m pip install -U pip wheel nox
shell: bash
- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

# The new python may not have nox so install it again
- name: Update pip, install wheel and nox
run: python -m pip install -U pip wheel nox
shell: bash

- name: Run tests
run: python -m nox --session tests
shell: bash

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

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

- name: Dotnet Tool Chain setup
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'

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

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

- name: Generate C# Code
run: python -m generator --plugin dotnet

- name: Dotnet Run Tests
run: dotnet test tests/dotnet/lsprotocol_tests/lsprotocol_tests.csproj
shell: bash
env:
LSP_TEST_DATA_PATH: ${{ github.workspace }}/packages/testdata
11 changes: 7 additions & 4 deletions generator/plugins/testdata/testdata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

def generate_from_spec(spec: model.LSPModel, output_dir: str) -> None:
"""Generate the code for the given spec."""
cleanup(output_dir)
output = pathlib.Path(output_dir)

if not output.exists():
output.mkdir(parents=True, exist_ok=True)

cleanup(output)
# key is the relative path to the file, value is the content
code: Dict[str, str] = generate(spec, logger)
for file_name in code:
Expand All @@ -24,8 +28,7 @@ def generate_from_spec(spec: model.LSPModel, output_dir: str) -> None:
file.write_text(code[file_name], encoding="utf-8")


def cleanup(output_dir: str) -> None:
def cleanup(output_path: pathlib.Path) -> None:
"""Cleanup the generated C# files."""
output = pathlib.Path(output_dir)
for file in output.glob("*.json"):
for file in output_path.glob("*.json"):
file.unlink()
4 changes: 2 additions & 2 deletions tests/dotnet/lsprotocol_tests/LSPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ private static void RunTest(bool valid, string data, Type type)
JToken token2 = JToken.Parse(newJson);
RemoveNullProperties(token1);
RemoveNullProperties(token2);
Assert.True(JToken.DeepEquals(token1, token2));
Assert.True(JToken.DeepEquals(token1, token2), $"Failed for : {data}");
}
else
{
try
{
JsonConvert.DeserializeObject(data, type);
// Explicitly fail the test
Assert.True(false, "Should have thrown an exception.");
Assert.True(false, $"Should have thrown an exception for : {data}");
}
catch
{
Expand Down