diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8273fd0..d557919 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,8 @@ on: release: types: [published] schedule: - # Daily at 3:21 - - cron: "21 3 * * *" + # Daily at 3:11 + - cron: "11 3 * * *" jobs: pre-commit: @@ -25,78 +25,25 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest] - python-version: - - name: pypy-3.9 - toxenv: pypy3-build - - name: pypy-3.9 - toxenv: pypy3-safety - - name: pypy-3.9 - toxenv: pypy3-tests - - name: 3.7 - toxenv: py37-build - - name: 3.7 - toxenv: py37-safety - - name: 3.7 - toxenv: py37-tests - - name: 3.8 - toxenv: py38-build - - name: 3.8 - toxenv: py38-safety - - name: 3.8 - toxenv: py38-tests - - name: 3.9 - toxenv: py39-build - - name: 3.9 - toxenv: py39-safety - - name: 3.9 - toxenv: py39-tests - - name: "3.10" - toxenv: py310-build - - name: "3.10" - toxenv: py310-safety - - name: "3.10" - toxenv: py310-tests - - name: "3.11" - toxenv: py311-build - - name: "3.11" - toxenv: py311-safety - - name: "3.11" - toxenv: py311-tests - - name: "3.11" - toxenv: docs-dirhtml - - name: "3.11" - toxenv: docs-doctest - - name: "3.11" - toxenv: docs-linkcheck - - name: "3.11" - toxenv: docs-spelling - - name: "3.11" - toxenv: docs-style - - name: "3.11" - toxenv: readme - - name: "3.11" - toxenv: secrets - - name: "3.11" - toxenv: style steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version.name }} - name: Install dependencies run: > sudo apt-get update && sudo apt-get install -y libenchant-2-dev libxml2-dev libxslt-dev - if: runner.os == 'Linux' && startsWith(matrix.python-version.toxenv, 'docs-') + if: runner.os == 'Linux' - name: Install dependencies run: brew install enchant - if: runner.os == 'macOS' && startsWith(matrix.python-version.toxenv, 'docs-') - - name: Install tox - run: python -m pip install tox - - name: Run tox - run: python -m tox -e "${{ matrix.python-version.toxenv }}" + if: runner.os == 'macOS' + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Set up nox + uses: wntrblm/nox@2022.11.21 + - name: Run nox + run: nox packaging: needs: ci @@ -112,23 +59,23 @@ jobs: run: python -m pip install build - name: Create packages run: python -m build . + - name: Set up nox + uses: wntrblm/nox@2022.11.21 - uses: actions/upload-artifact@v3 with: name: dist path: dist - - name: Publish package + - name: Publish to PyPI if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.pypi_password }} - - name: Create Release Notes + - name: Create a Release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: actions/github-script@v6 + uses: softprops/action-gh-release@v1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - await github.request(`POST /repos/${{ github.repository }}/releases`, { - tag_name: "${{ github.ref }}", - generate_release_notes: true - }); + files: | + shiv/bowtie + dist/* + generate_release_notes: true diff --git a/.gitignore b/.gitignore index 68bc17f..1fa73ba 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,5 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +_cache/ diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..286f7c4 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,101 @@ +from pathlib import Path + +import nox + +ROOT = Path(__file__).parent +DOCS = ROOT / "docs" +PACKAGE = ROOT / "sphinx_json_schema_spec" + + +nox.options.sessions = [] + + +def session(default=True, **kwargs): + def _session(fn): + if default: + nox.options.sessions.append(kwargs.get("name", fn.__name__)) + return nox.session(**kwargs)(fn) + + return _session + + +@session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"]) +def tests(session): + session.install("-r", str(ROOT / "test-requirements.txt")) + session.run("pytest", "--verbosity=3") + + +@session(tags=["build"]) +def build(session): + session.install("build") + tmpdir = session.create_tmp() + session.run("python", "-m", "build", str(ROOT), "--outdir", tmpdir) + + +@session(tags=["style"]) +def readme(session): + session.install("build", "twine") + tmpdir = session.create_tmp() + session.run("python", "-m", "build", str(ROOT), "--outdir", tmpdir) + session.run("python", "-m", "twine", "check", tmpdir + "/*") + + +@session(tags=["style"]) +def style(session): + session.install( + "flake8", + "flake8-broken-line", + "flake8-bugbear", + "flake8-commas", + "flake8-quotes", + "flake8-tidy-imports", + ) + session.run("python", "-m", "flake8", str(PACKAGE), __file__) + + +@session() +def typing(session): + session.install("mypy", "types-docutils", "types-lxml", str(ROOT)) + session.run("python", "-m", "mypy", str(PACKAGE)) + + +@session(tags=["docs"]) +@nox.parametrize( + "builder", + [ + nox.param(name, id=name) + for name in [ + "dirhtml", + "doctest", + "linkcheck", + "man", + "spelling", + ] + ], +) +def docs(session, builder): + session.install("-r", str(DOCS / "requirements.txt")) + tmpdir = Path(session.create_tmp()) + argv = ["-n", "-T", "-W"] + if builder != "spelling": + argv += ["-q"] + session.run( + "python", + "-m", + "sphinx", + "-b", + builder, + str(DOCS), + str(tmpdir / builder), + *argv, + ) + + +@session(tags=["docs", "style"], name="docs(style)") +def docs_style(session): + session.install( + "doc8", + "pygments", + "pygments-github-lexers", + ) + session.run("python", "-m", "doc8", "--max-line-length", "1000", str(DOCS)) diff --git a/pyproject.toml b/pyproject.toml index 7e945c2..45d9c5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ source = "vcs" [project] name = "sphinx_json_schema_spec" -description = "" +description = "Sphinx support for the JSON Schema specifications" readme = "README.rst" requires-python = ">=3.7" license = {text = "MIT"} @@ -22,11 +22,11 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python", diff --git a/sphinx_json_schema_spec/__init__.py b/sphinx_json_schema_spec/__init__.py index 1f7c82e..288e287 100644 --- a/sphinx_json_schema_spec/__init__.py +++ b/sphinx_json_schema_spec/__init__.py @@ -8,7 +8,7 @@ try: from importlib import metadata except ImportError: - import importlib_metadata as metadata + import importlib_metadata as metadata # type: ignore from docutils import nodes from lxml import html diff --git a/tox.ini b/tox.ini deleted file mode 100644 index f83fe10..0000000 --- a/tox.ini +++ /dev/null @@ -1,87 +0,0 @@ -[tox] -envlist = - {py37,py38,py39,py310,py311,pypy3}-{build,tests} - readme - safety - secrets - style - docs-{dirhtml,doctest,linkcheck,spelling,style} -skipsdist = True - -[testenv] -passenv = CI -setenv = - coverage: MAYBE_COVERAGE = coverage run -m - coverage: COVERAGE_RCFILE={toxinidir}/.coveragerc - coverage: COVERAGE_DEBUG_FILE={envtmpdir}/coverage-debug - coverage: COVERAGE_FILE={envtmpdir}/coverage-data -changedir = {envtmpdir} -args_are_paths = false -commands = - build: {envpython} -m build {toxinidir} --outdir {envtmpdir}/dist - - tests,safety: {envpython} -m pip install {toxinidir} - - tests,coverage: {envpython} -m {env:MAYBE_COVERAGE:} pytest {posargs:{toxinidir}/sphinx_json_schema_spec/} - tests: {envpython} -m doctest {toxinidir}/README.rst - - coverage: {envpython} -m coverage report --show-missing - coverage: {envpython} -m coverage html --directory={envtmpdir}/htmlcov - - safety: {envpython} -m safety check -deps = - build: build - safety: safety - tests,coverage: pytest - coverage: coverage - -[testenv:bandit] -deps = bandit -commands = {envpython} -m bandit --recursive sphinx_json_schema_spec - -[testenv:readme] -deps = - build - twine -commands = - {envpython} -m build --outdir {envtmpdir}/dist {toxinidir} - {envpython} -m twine check {envtmpdir}/dist/* - -[testenv:secrets] -deps = detect-secrets -commands = {envbindir}/detect-secrets scan {toxinidir} - -[testenv:style] -deps = - flake8 - flake8-broken-line - flake8-bugbear - flake8-commas - flake8-quotes - flake8-tidy-imports -commands = - {envpython} -m flake8 {posargs} --max-complexity 10 {toxinidir}/sphinx_json_schema_spec {toxinidir}/docs - -[testenv:docs-dirhtml] -commands = {envpython} -m sphinx -b dirhtml {toxinidir}/docs/ {envtmpdir}/build {posargs:-a -n -q -T -W} -deps = - -r{toxinidir}/docs/requirements.txt - -[testenv:docs-doctest] -commands = {envpython} -m sphinx -b doctest {toxinidir}/docs/ {envtmpdir}/build {posargs:-a -n -q -T -W} -deps = {[testenv:docs-dirhtml]deps} - -[testenv:docs-linkcheck] -commands = {envpython} -m sphinx -b linkcheck {toxinidir}/docs/ {envtmpdir}/build {posargs:-a -n -q -T -W} -deps = {[testenv:docs-dirhtml]deps} - -[testenv:docs-spelling] -commands = {envpython} -m sphinx -b spelling {toxinidir}/docs/ {envtmpdir}/build {posargs:-a -n -T -W} -deps = {[testenv:docs-dirhtml]deps} - -[testenv:docs-style] -commands = doc8 --config {toxinidir}/pyproject.toml {posargs} {toxinidir}/docs -deps = - doc8 - pygments - pygments-github-lexers