From d2ff78b22a79a98fb7420f590ab40fce32dfe646 Mon Sep 17 00:00:00 2001 From: 573Dev <> Date: Sun, 18 Apr 2021 15:02:53 -0500 Subject: [PATCH] clean up config files --- .flake8 | 4 -- .github/workflows/main.yml | 128 +++++++++++++++++++++++++++++++++++++ .mypy.ini | 3 - .readthedocs.yml | 13 ++++ docs/conf.py | 19 ++++-- pyproject.toml | 14 ++-- setup.cfg | 15 +++++ setup.py | 17 +++-- tox.ini | 13 ++-- 9 files changed, 195 insertions(+), 31 deletions(-) delete mode 100644 .flake8 create mode 100644 .github/workflows/main.yml delete mode 100644 .mypy.ini create mode 100644 .readthedocs.yml create mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 deleted file mode 100644 index dd622a3..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -ignore = E203, W503 -max-line-length = 88 -inline-quotes = double diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..73f0c4b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,128 @@ +name: build +on: [push] + + # A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + check: + runs-on: ubuntu-latest + steps: + # Checkout Repo + - uses: actions/checkout@v2 + + # Set up python + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + python-version: 3.x + + # Install Deps + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + # Run Check + - name: Run Code Linters + run: tox -e check + + + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + steps: + # Checkout Repo + - uses: actions/checkout@v2 + + # Set up python + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + # Install Deps + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + + # Run Tests + - name: Run Python Tests + run: tox + + - name: Show items + run: ls -la + + # Upload Coverage Artifacts + - name: Upload Coverage Data + uses: actions/upload-artifact@v2 + with: + name: coverage_${{ matrix.python-version }} + path: .coverage.* + + coverage: + needs: test + runs-on: ubuntu-latest + steps: + # Checkout Repo + - uses: actions/checkout@v2 + + # Set up python + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + python-version: 3.x + + # Install Deps + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + # Download Coverage Artifacts + - name: Download Coverage Data + uses: actions/download-artifact@v2 + + - name: Move coverage data + run: | + mv coverage_*/.coverage* . + rm -rf coverage_*/ + + # Run Coverage + - name: Run Coverage + run: tox -e coverage + + # Upload coverage to Codecov + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./dist/coverage.xml + directory: ./coverage/reports/ + name: codecov-umbrella + fail_ci_if_error: true + path_to_write_report: ./coverage/codecov_report.txt + verbose: false + + documentation: + runs-on: ubuntu-latest + steps: + # Checkout Repo + - uses: actions/checkout@v2 + + # Set up python + - name: Set up Python 3.x + uses: actions/setup-python@v2 + with: + python-version: 3.x + + # Install Deps + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + # Run Documentation + - name: Run Documentation + run: tox -e docs diff --git a/.mypy.ini b/.mypy.ini deleted file mode 100644 index dfb537e..0000000 --- a/.mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -ignore_missing_imports = True -plugins = sqlmypy diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..cd20139 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,13 @@ +version: 2 + +sphinx: + builder: html + configuration: docs/conf.py + +python: + version: 3 + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/docs/conf.py b/docs/conf.py index cb27825..b28a545 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,8 +1,18 @@ +from datetime import datetime + +from recommonmark.parser import CommonMarkParser from recommonmark.transform import AutoStructify from v8_server import __version__ +# This exists to fix a bug in recommonmark due to a missing function definition +# https://github.com/readthedocs/recommonmark/issues/177 +class CustomCommonMarkParser(CommonMarkParser): + def visit_document(self, node): + pass + + # Sphinx Base -------------------------------------------------------------------------- # Extensions extensions = [ @@ -16,8 +26,6 @@ extensions = [ "sphinx.ext.viewcode", # https://sphinx-autoapi.readthedocs.io/en/latest/ "autoapi.extension", - # https://github.com/rtfd/recommonmark - "recommonmark", ] # Set initial page name @@ -25,7 +33,7 @@ master_doc = "index" # Project settings project = "V8 Server" -year = "2020" +year = datetime.now().year author = "573dev" copyright = f"{year}, {author}" @@ -64,9 +72,8 @@ napoleon_use_param = False # Sphinx Extension AutoAPI ------------------------------------------------------------- autoapi_type = "python" autoapi_dirs = ["../v8_server/"] -autoapi_template_dir = "docs/autoapi_templates" +autoapi_template_dir = "./autoapi_templates" autoapi_root = "autoapi" -autoapi_ignore = ["*/v8_server/version.py"] autoapi_add_toctree_entry = False autoapi_keep_files = False @@ -80,6 +87,8 @@ def setup(app): # Set source filetype(s) # Allow .rst files along with .md app.add_source_suffix(".rst", "restructuredtext") + app.add_source_suffix(".md", "markdown") + app.add_source_parser(CustomCommonMarkParser) # RecommonMark Settings ------------------------------------------------------------ # Enable the evaluation of rst directive in .md files diff --git a/pyproject.toml b/pyproject.toml index ee0592d..663f981 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,11 @@ show_missing = true skip_covered = true exclude_lines = ["if __name__ == .__main__.:", "def __str__", "def __repr__", "pragma: no cover"] +[tool.coverage.xml] +output = "./dist/coverage.xml" + [tool.isort] -line_length = 88 -force_grid_wrap = "0" -multi_line_output = "3" -use_parentheses = true +profile = "black" +color_output = true +lines_after_imports = 2 combine_as_imports = true -known_first_party = ["v8_server"] -known_third_party = ["pytest, recommonmark"] -include_trailing_comma = true -lines_after_imports = "2" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..3c569ff --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[aliases] +test=pytest + +[bdist_wheel] +universal = 1 + +[flake8] +ignore = E203, W503 +max-line-length = 88 +inline-quotes = double + +[mypy] +warn_unused_ignores = true +ignore_missing_imports = true +plugins = sqlmypy diff --git a/setup.py b/setup.py index ea5defa..a0feba2 100644 --- a/setup.py +++ b/setup.py @@ -5,18 +5,25 @@ from setuptools import find_packages, setup TEST_DEPS = ["coverage[toml]", "pytest", "pytest-cov"] -DOCS_DEPS = ["sphinx", "sphinx-rtd-theme", "sphinx-autoapi", "recommonmark"] -CHECK_DEPS = ["isort", "flake8", "flake8-quotes", "pep8-naming", "mypy", "black"] +DOCS_DEPS = ["recommonmark", "sphinx", "sphinx-autoapi", "sphinx-rtd-theme"] +CHECK_DEPS = [ + "black", + "flake8", + "flake8-quotes", + "isort[colors]", + "mypy", + "pep8-naming", +] REQUIREMENTS = [ "flask", "flask_sqlalchemy", - "watchdog", - "pyopenssl", + "kbinxml", "lxml", "pycryptodome", - "kbinxml", + "pyopenssl", "sqlalchemy", "sqlalchemy-stubs", + "watchdog", ] EXTRAS = { diff --git a/tox.ini b/tox.ini index 163db74..abcd8f2 100644 --- a/tox.ini +++ b/tox.ini @@ -12,19 +12,20 @@ setenv = PYTHONPATH = {toxinidir} COVERAGE_FILE=.coverage.{envname} commands = - py.test --cov=v8_server --verbose --tb=long {posargs} + py.test --cov=v8_server --verbose --tb=long --durations=5 {posargs} [testenv:coverage] -basepython = python3.8 +basepython = python3 deps = coverage[toml] skip_install = True skipsdist = True commands = /usr/bin/env bash -c "{envpython} -m coverage combine .coverage.*" coverage report + coverage xml [testenv:check] -basepython = python3.8 +basepython = python3 extras = check commands = isort v8_server tests setup.py docs/conf.py --check-only --diff @@ -33,10 +34,10 @@ commands = mypy v8_server setup.py docs/conf.py [testenv:docs] -basepython = python3.8 +basepython = python3 extras = docs commands = sphinx-build {posargs:-E} -b html docs dist/docs -[travis] +[gh-actions] python = - 3.8: check, py38, coverage, docs + 3.8: py38