Skip to content

Contributing Guide

Karthik Nadig edited this page Aug 17, 2023 · 3 revisions

Requirements

You will need the following tools and packages:

  • NodeJs : 16.17.0
  • Npm : 8.19.3
  • python 3.7 : This is needed for bundled libs

Getting the project ready

  1. Create a fork of this repo and clone your fork locally.

  2. Create virtual environment, activate it, and install packages:

    1. python -m venv .venv, select this environment after creation. In VS Code you can use the command Python: Create Environment from the command pallet.
    2. Open a terminal and activate the selected environment. If using VS Code terminal, and you have selected the .venv environment, it should auto activate.
    3. python -m pip install nox
    4. nox --session setup if you're using Python 3.7. Otherwise, run python -m pip install -t ./bundled/libs --no-cache-dir --implementation py --no-deps --upgrade -r ./requirements.txt
    5. python -m pip install -r src/test/python_tests/requirements.txt
  3. Install npm packages by running npm install

Your project should now be ready to run and debug.

Linting Server

Most of the linting code is in bundled/tool/lsp_server.py, look in that file for examples on how to work with Language Server Protocol. This file is launched by VS Code, this launch configuration is in src/common/server.ts. These two files are the main files needed for this project to work.

Settings needed for this project are defined in package.json. These settings are generically read and passed to server.py via language server protocol. This is done in src/extension.ts

Testing

To test the linter server, we have a custom LSP client. See src/test/python_tests/test_linting.py for examples on how to write tests for this project.

Debugging

This repo has a few pre-defined configurations that you can use to debug the extension, or the tests. You can select these from the debug view:

  1. Debug Extension and Python: This configuration allows you to debug both the Type Script and the Python code. This is useful if you have made changes to TypeScript side and want to track the flow of content from TS side to python.
  2. Debug Extension Only: this configuration allows you to debug just the TypeScript part of the extension.
  3. Python Attach: This configuration is useful to debug python server that is already running.
  4. TS Unit Test: This configuration allows you to debug TypeScript unit tests.

Debugging Python Tests

You can debug the server using the Debug Test button in the test explorer. The test framework here allows you to control the server using a python-based client. The client allows you to behave like an IDE programmatically and allows you to launch and configure the server as needed for your tests. This is pre-configured to allow you to step into the packages needed to fix issues with the server and inspect values inside the tools that you are using.

Creating Pull Request

Run the following commands from the terminal and address any reported issues:

  • python -m nox --session tests
  • python -m nox --session lint

After the above commands are successful, push your changes to your fork, and create a pull request against the main branch in this repo.