From af5b38611d25de7edd93206a8f8fcc1ae66f5627 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 14 Dec 2020 13:54:58 +0400 Subject: [PATCH] Switch CI to GitHub Actions --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++ .travis.yml | 24 ------------- ci/travis.sh => ci.sh | 4 +-- setup.py | 4 ++- sphinxcontrib_trio/__init__.py | 26 ++------------ tests/test_sphinxcontrib_trio.py | 2 +- 6 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml rename ci/travis.sh => ci.sh (88%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..41811c4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: CI + +on: + push: + branches-ignore: + - "dependabot/**" + pull_request: + +jobs: + Ubuntu: + name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' + timeout-minutes: 10 + runs-on: 'ubuntu-latest' + strategy: + fail-fast: false + matrix: + python: ['3.6', '3.7', '3.8', '3.9'] + old_sphinx: [''] + extra_name: [''] + include: + - python: '3.9' + old_sphinx: 2.0 + extra_name: ', Sphinx 2.0' + - python: '3.9' + old_sphinx: 2.1 + extra_name: ', Sphinx 2.1' + - python: '3.9' + old_sphinx: 2.2 + extra_name: ', Sphinx 2.2' + - python: '3.9' + old_sphinx: 2.3 + extra_name: ', Sphinx 2.3' + - python: '3.9' + old_sphinx: 2.4 + extra_name: ', Sphinx 2.4' + - python: '3.9' + old_sphinx: 3.0 + extra_name: ', Sphinx 3.0' + - python: '3.9' + old_sphinx: 3.1 + extra_name: ', Sphinx 3.1' + - python: '3.9' + old_sphinx: 3.2 + extra_name: ', Sphinx 3.2' + - python: '3.9' + old_sphinx: 3.3 + extra_name: ', Sphinx 3.3' + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: '${{ matrix.python }}' + - name: Run tests + run: ./ci.sh + env: + OLD_SPHINX: '${{ matrix.old_sphinx}}' + # Should match 'name:' up above + JOB_NAME: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 507cc50..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: python -dist: xenial -matrix: - include: - - python: 3.5 - - python: 3.6 - - python: 3.7 - - python: 3.7 - env: OLD_SPHINX=1.7 - - python: 3.8 - env: OLD_SPHINX=1.8 - - python: 3.8 - env: OLD_SPHINX=2.0 - - python: 3.8 - env: OLD_SPHINX=2.1 - - python: 3.8 - env: OLD_SPHINX=2.2 - - python: 3.8 - env: OLD_SPHINX=2.3 - - python: 3.8 - env: OLD_SPHINX=2.4 - -script: - - ci/travis.sh diff --git a/ci/travis.sh b/ci.sh similarity index 88% rename from ci/travis.sh rename to ci.sh index 1878454..291840c 100755 --- a/ci/travis.sh +++ b/ci.sh @@ -16,8 +16,8 @@ sphinx-build -nW -b html source build popd pip install -Ur test-requirements.txt -# https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash -if [ -n "${OLD_SPHINX+x}" ]; then +# https://serverfault.com/questions/7503/how-to-determine-if-a-bash-variable-is-empty +if [ -n "${OLD_SPHINX}" ]; then pip install "sphinx == ${OLD_SPHINX}.*" fi mkdir empty diff --git a/setup.py b/setup.py index c0c601b..b3add2e 100644 --- a/setup.py +++ b/setup.py @@ -24,8 +24,10 @@ "License :: OSI Approved :: MIT License", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Sphinx :: Extension", "Framework :: Trio", "Framework :: AsyncIO", diff --git a/sphinxcontrib_trio/__init__.py b/sphinxcontrib_trio/__init__.py index 6054df3..6936661 100644 --- a/sphinxcontrib_trio/__init__.py +++ b/sphinxcontrib_trio/__init__.py @@ -61,17 +61,9 @@ from docutils.parsers.rst import directives from sphinx import addnodes -try: - from sphinx.domains.python import PyFunction -except ImportError: - from sphinx.domains.python import PyModulelevel as PyFunction +from sphinx.domains.python import PyFunction from sphinx.domains.python import PyObject -try: - from sphinx.domains.python import PyMethod, PyClassMethod, PyStaticMethod -except ImportError: - from sphinx.domains.python import PyClassmember as PyMethod - from sphinx.domains.python import PyClassmember as PyClassMethod - from sphinx.domains.python import PyClassmember as PyStaticMethod +from sphinx.domains.python import PyMethod, PyClassMethod, PyStaticMethod from sphinx.ext.autodoc import ( FunctionDocumenter, MethodDocumenter, ClassLevelDocumenter, Options, ModuleLevelDocumenter ) @@ -80,12 +72,7 @@ try: from async_generator import isasyncgenfunction except ImportError: - try: - from inspect import isasyncgenfunction - except ImportError: - # This python install has no way to make async generators - def isasyncgenfunction(fn): - return False + from inspect import isasyncgenfunction CM_CODES = set() ACM_CODES = set() @@ -410,11 +397,4 @@ def setup(app): app.add_autodocumenter(ExtendedFunctionDocumenter) app.add_autodocumenter(ExtendedMethodDocumenter) - # A monkey-patch to VariableCommentPicker to make autodoc_member_order = 'bysource' work. - from sphinx.pycode.parser import VariableCommentPicker - if not hasattr(VariableCommentPicker, "visit_AsyncFunctionDef"): # pragma: no branch - VariableCommentPicker.visit_AsyncFunctionDef = ( # type: ignore - VariableCommentPicker.visit_FunctionDef # type: ignore - ) - return {'version': __version__, 'parallel_read_safe': True} diff --git a/tests/test_sphinxcontrib_trio.py b/tests/test_sphinxcontrib_trio.py index af47e63..142badd 100644 --- a/tests/test_sphinxcontrib_trio.py +++ b/tests/test_sphinxcontrib_trio.py @@ -220,7 +220,7 @@ def do_html_test(node, *, expect_match): assert re.search(check, test_content) is not None else: assert re.search(check, test_content) is None - except AssertionError: + except AssertionError: # pragma: nocover print("failed check") print() print(repr(check))