-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from pappasam/ruff-and-nox
Disparate dev tools -> ruff + nox
- Loading branch information
Showing
16 changed files
with
215 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,71 @@ | ||
name: Testing | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Select Python 3.9 | ||
- name: Select Python 3.11 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.11 | ||
architecture: x64 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install -U pip | ||
python -m pip install wheel | ||
python -m pip install poetry | ||
poetry install | ||
- name: Run black formatter check | ||
run: poetry run black --extend-exclude test_data --check --diff jedi_language_server tests | ||
|
||
- name: Run docformatter check | ||
run: poetry run docformatter --exclude test_data --check --recursive jedi_language_server tests | ||
|
||
- name: Run isort check | ||
run: poetry run isort --check jedi_language_server tests/lsp_tests tests/lsp_test_client | ||
|
||
- name: Run mypy check | ||
run: poetry run mypy jedi_language_server | ||
|
||
- name: Run pylint | ||
run: poetry run pylint jedi_language_server tests | ||
|
||
- name: Run linting | ||
run: poetry run nox -s lint | ||
- name: Run static type checking | ||
run: poetry run nox -s typecheck | ||
tests: | ||
needs: [lint] | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup, Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: x64 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install -U pip | ||
python -m pip install wheel | ||
python -m pip install poetry | ||
poetry install | ||
- name: Run Tests | ||
run: poetry run pytest tests | ||
|
||
run: poetry run nox -s tests | ||
coverage: | ||
needs: [lint] | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Select Python 3.9 | ||
- name: Select Python 3.11 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.11 | ||
architecture: x64 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install -U pip | ||
python -m pip install wheel | ||
python -m pip install poetry | ||
poetry install | ||
- name: Run Coverage | ||
env: | ||
WITH_COVERAGE: true | ||
run: poetry run pytest --cov=jedi_language_server --cov-report=term-missing tests | ||
run: poetry run nox -s coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,56 @@ | ||
.PHONY: help | ||
help: ## Print this help menu | ||
help: ## Print this help menu | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ | ||
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: require | ||
require: ## Check that prerequisites are installed. | ||
@if ! command -v python3 > /dev/null; then \ | ||
printf "\033[1m\033[31mERROR\033[0m: python3 not installed\n" >&2 ; \ | ||
exit 1; \ | ||
fi | ||
printf "\033[1m\033[31mERROR\033[0m: python3 not installed\n" >&2 ; \ | ||
exit 1; \ | ||
fi | ||
@if ! python3 -c "import sys; sys.exit(sys.version_info < (3,8))"; then \ | ||
printf "\033[1m\033[31mERROR\033[0m: python 3.8+ required\n" >&2 ; \ | ||
exit 1; \ | ||
fi | ||
printf "\033[1m\033[31mERROR\033[0m: python 3.8+ required\n" >&2 ; \ | ||
exit 1; \ | ||
fi | ||
@if ! command -v poetry > /dev/null; then \ | ||
printf "\033[1m\033[31mERROR\033[0m: poetry not installed.\n" >&2 ; \ | ||
printf "Please install with 'python3 -mpip install --user poetry'\n" >&2 ; \ | ||
exit 1; \ | ||
fi | ||
printf "\033[1m\033[31mERROR\033[0m: poetry not installed.\n" >&2 ; \ | ||
printf "Please install with 'python3 -mpip install --user poetry'\n" >&2 ; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: setup | ||
setup: require .setup_complete ## Set up the local development environment | ||
setup: require .setup_complete ## Set up the local development environment | ||
|
||
.setup_complete: poetry.lock ## Internal helper to run the setup. | ||
.setup_complete: poetry.lock ## Internal helper to run the setup. | ||
poetry install | ||
poetry run pre-commit install | ||
touch .setup_complete | ||
|
||
.PHONY: test | ||
test: setup ## Run the tests, but only for current Python version | ||
poetry run black --extend-exclude test_data --check --diff jedi_language_server tests | ||
poetry run docformatter --exclude test_data --check --recursive jedi_language_server tests | ||
poetry run isort --check jedi_language_server tests/lsp_tests tests/lsp_test_client | ||
poetry run mypy jedi_language_server | ||
poetry run pylint jedi_language_server tests | ||
poetry run pytest tests | ||
.PHONY: fix | ||
fix: ## Fix all files in-place | ||
poetry run nox -s $@ | ||
|
||
.PHONY: lint | ||
lint: ## Run linters on all files | ||
poetry run nox -s $@ | ||
|
||
.PHONY: typecheck | ||
typecheck: ## Run static type checks | ||
poetry run nox -s $@ | ||
|
||
.PHONY: tests | ||
tests: ## Run unit tests | ||
poetry run nox -s $@ | ||
|
||
.PHONY: publish | ||
publish: setup ## Build & publish the new version | ||
publish: ## Build & publish the new version | ||
poetry build | ||
poetry publish | ||
|
||
.PHONY: format | ||
format: setup ## Autoformat all files in the repo. WARNING: changes files in-place | ||
poetry run black jedi_language_server tests | ||
poetry run isort jedi_language_server tests | ||
poetry run docformatter --recursive --in-place jedi_language_server tests | ||
|
||
.PHONY: clean | ||
.PHONY: clean | ||
clean: ## Remove local development environment | ||
if poetry env list | grep -q Activated; then \ | ||
poetry env remove python3; \ | ||
fi | ||
poetry env remove python3; \ | ||
fi | ||
rm -f .setup_complete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Configure nox.""" | ||
|
||
import nox | ||
|
||
NOX_SESSION = nox.session(python=False) | ||
|
||
|
||
@NOX_SESSION | ||
def fix(session: nox.Session): | ||
"""Fix files inplace.""" | ||
session.run("ruff", "format", "-s", ".") | ||
session.run("ruff", "check", "-se", "--fix", ".") | ||
|
||
|
||
@NOX_SESSION | ||
def lint(session: nox.Session): | ||
"""Check file formatting that only have to do with formatting.""" | ||
session.run("ruff", "format", "--check", ".") | ||
session.run("ruff", "check", ".") | ||
|
||
|
||
@NOX_SESSION | ||
def typecheck(session: nox.Session): | ||
session.run("mypy", "jedi_language_server") | ||
|
||
|
||
@NOX_SESSION | ||
def tests(session: nox.Session): | ||
session.run("pytest", "tests") | ||
|
||
|
||
@NOX_SESSION | ||
def coverage(session: nox.Session): | ||
session.run( | ||
"pytest", | ||
"--cov", | ||
"jedi_language_server", | ||
"--cov-report", | ||
"term-missing", | ||
"tests", | ||
) |
Oops, something went wrong.