Skip to content

Commit

Permalink
tox -> nox
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Dec 19, 2022
1 parent 9d9ad8e commit 0402a46
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 165 deletions.
95 changes: 21 additions & 74 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/[email protected]
- name: Run nox
run: nox

packaging:
needs: ci
Expand All @@ -112,23 +59,23 @@ jobs:
run: python -m pip install build
- name: Create packages
run: python -m build .
- name: Set up nox
uses: wntrblm/[email protected]
- 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
101 changes: 101 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion sphinx_json_schema_spec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
87 changes: 0 additions & 87 deletions tox.ini

This file was deleted.

0 comments on commit 0402a46

Please sign in to comment.