-
Notifications
You must be signed in to change notification settings - Fork 19
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 #73 from pappasam/update-dev-deps
Modernize tests, fix test errors
- Loading branch information
Showing
18 changed files
with
496 additions
and
1,679 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
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.10 | ||
uses: actions/setup-python@v2 | ||
uses: actions/checkout@v4 | ||
- name: Select Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.12" | ||
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 --check --diff toml_sort tests | ||
|
||
- name: Run docformatter check | ||
run: poetry run docformatter --check --recursive toml_sort tests | ||
|
||
- name: Run isort check | ||
run: poetry run isort --check toml_sort tests | ||
|
||
- name: Run mypy check | ||
run: poetry run mypy toml_sort | ||
|
||
- name: Run pylint | ||
run: poetry run pylint toml_sort 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] | ||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
python-version: ["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 | ||
uses: actions/checkout@v4 | ||
- name: Select Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
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: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Select Python 3.10 | ||
uses: actions/setup-python@v2 | ||
uses: actions/checkout@v4 | ||
- name: Select Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.12" | ||
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=toml_sort --cov-report=term-missing tests | ||
run: poetry run nox -s coverage |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,49 +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 | ||
@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 | ||
@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 | ||
|
||
.PHONY: setup | ||
setup: ## 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. | ||
poetry install | ||
poetry run pre-commit install | ||
touch .setup_complete | ||
|
||
.PHONY: fix | ||
fix: ## Fix all files in-place | ||
poetry run nox -s $@ | ||
|
||
.PHONY: test | ||
test: ## Run the tests, but only for current Python version | ||
poetry run tox -e py | ||
.PHONY: lint | ||
lint: ## Run linters on all files | ||
poetry run nox -s $@ | ||
|
||
.PHONY: test-all | ||
test-all: ## Run the tests for all relevant Python version | ||
poetry run tox | ||
.PHONY: typecheck | ||
typecheck: ## Run static type checks | ||
poetry run nox -s $@ | ||
|
||
.PHONY: tests | ||
tests: ## Run unit tests | ||
poetry run nox -s $@ | ||
|
||
.PHONY: publish | ||
publish: ## Build & publish the new version | ||
publish: ## Build & publish the new version | ||
poetry build | ||
poetry publish | ||
|
||
.PHONY: format | ||
format: ## Autoformat all files in the repo. WARNING: changes files in-place | ||
poetry run black toml_sort tests | ||
poetry run isort toml_sort tests | ||
poetry run docformatter --recursive --in-place toml_sort tests | ||
|
||
.PHONY: build-docs | ||
build-docs: docs/autogen-requirements.txt ## Build the Sphinx docs | ||
sphinx-build -M html docs docs/_build | ||
|
||
.PHONY: serve-docs | ||
serve-docs: build-docs ## Simple development server for Sphinx docs | ||
@echo "Serving documentation locally." | ||
@echo "Open browser with 'make open-docs'" | ||
@find docs toml_sort | entr -ps "$(MAKE) build-docs" | ||
|
||
.PHONY: open-docs | ||
open-docs: ## Open Sphinx docs index in a browser | ||
gio open docs/_build/html/index.html | ||
|
||
.PHONY: clean-docs | ||
clean-docs: ## Clean the docs | ||
rm -r docs/_build | ||
|
||
docs/autogen-requirements.txt: poetry.lock ## Autogenerate the requirements.txt | ||
poetry export --dev --format requirements.txt --output $@ && git add $@ | ||
.PHONY: clean | ||
clean: ## Remove local development environment | ||
if poetry env list | grep -q Activated; then \ | ||
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
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", "toml_sort") | ||
|
||
|
||
@NOX_SESSION | ||
def tests(session: nox.Session): | ||
session.run("pytest", "tests") | ||
|
||
|
||
@NOX_SESSION | ||
def coverage(session: nox.Session): | ||
session.run( | ||
"pytest", | ||
"--cov", | ||
"toml_sort", | ||
"--cov-report", | ||
"term-missing", | ||
"tests", | ||
) |
Oops, something went wrong.