Skip to content

Commit

Permalink
Merge pull request #16 from pfw/github-actions-py3
Browse files Browse the repository at this point in the history
Use GitHub Actions and support only Python 3
  • Loading branch information
tseaver authored May 16, 2024
2 parents 75f6c28 + 9019314 commit d195029
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 74 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build and test

on:
push:
branches:
- master
tags:
pull_request:

jobs:
test:
strategy:
matrix:
py:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12-dev"
- "pypy-3.9"
os:
- "ubuntu-20.04"
- "macos-latest"
architecture:
- x64

exclude:
# persistent fails to build on 3.12-dev on MacOS in GitHub
- os: macos-latest
py: "3.12-dev"

include:
# Only run coverage on ubuntu-20.04, except on pypy3
- os: "ubuntu-20.04"
pytest-args: "--cov"
- os: "ubuntu-20.04"
py: "pypy-3.9"
pytest-args: ""


name: "Python: ${{ matrix.py }}-${{ matrix.architecture }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
architecture: ${{ matrix.architecture }}
- run: pip install tox
- name: Running tox
run: tox -e py -- ${{ matrix.pytest-args }}
coverage:
runs-on: ubuntu-20.04
name: Validate coverage
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.7
architecture: x64
- run: pip install tox
- run: tox -e coverage
docs:
runs-on: ubuntu-20.04
name: Build the documentation
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.7
architecture: x64
- run: pip install tox
- run: tox -e docs
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ hypatia/coverage.xml
coverage-py*.xml
coverage.xml
env*/
.venv
.build/
bin/
include/
lib/
build/
*.so
.idea
.envrc
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Hypatia
:target: https://pypi.python.org/pypi/hypatia/
:alt: Latest Version

.. image:: https://travis-ci.org/Pylons/hypatia.png?branch=master
:target: https://travis-ci.org/Pylons/hypatia
.. image:: https://github.com/Pylons/hypatia/workflows/Build%20and%20test/badge.svg?branch=master
:target: https://github.com/Pylons/hypatia/actions/workflows/main.yml
:alt: CI Status

.. image:: https://readthedocs.org/projects/hypatia/badge/?version=latest
:target: http://hypatia.readthedocs.org/en/latest/
Expand Down
2 changes: 1 addition & 1 deletion hypatia/field/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ def test___gt__val_False(self):
self.assertFalse(inst > 1)

def test_suite():
return unittest.TestSuite((
assert unittest.TestSuite((
doctest.DocFileSuite('README.txt', optionflags=doctest.ELLIPSIS),
unittest.makeSuite(FieldIndexTests),
unittest.makeSuite(Test_fwscan_wins),
Expand Down
8 changes: 6 additions & 2 deletions hypatia/query/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,11 @@ def process_Str(self, node, children):
return node.s

def process_Constant(self, node, children):
return node.s
"""
Changed in Python version 3.8: Class ast.Constant is now used for all constants.
Default coverage is run under 3.7 so don't count this line.
"""
return node.s # pragma NO COVER

def process_Num(self, node, children):
return node.n
Expand Down Expand Up @@ -993,7 +997,7 @@ def _print_ast(expr): # pragma NO COVERAGE
tree = ast.parse(expr)

def visit(node, level):
sys.stdout.write('%s%s\n' % (' ' * level + str(node)))
sys.stdout.write('%s%s\n' % (' ' * level, str(node)))
for child in ast.iter_child_nodes(node):
visit(child, level + 1)
visit(tree, 0)
9 changes: 2 additions & 7 deletions hypatia/text/htmlsplitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@

MARKUP = re.compile(r"(<[^<>]*>|&[A-Za-z]+;)")

PY3 = sys.version_info[0] >= 3
if PY3:
WORDS = re.compile(r"\w+")
GLOBS = re.compile(r"\w+[\w*?]*")
else:
WORDS = re.compile(r"(?L)\w+")
GLOBS = re.compile(r"(?L)\w+[\w*?]*")
WORDS = re.compile(r"\w+")
GLOBS = re.compile(r"\w+[\w*?]*")

@implementer(ISplitter)
class HTMLWordSplitter(object):
Expand Down
2 changes: 1 addition & 1 deletion hypatia/text/tests/test_textindexwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
import doctest

def test_suite():
return doctest.DocFileSuite("../textindex.txt")
assert doctest.DocFileSuite("../textindex.txt")
36 changes: 6 additions & 30 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py27,py36,py37,py38,py39,py310,{py2,py3}-cover,coverage,docs
py37,py38,py39,py310,py311,py312,pypy38,pypy39,coverage,docs

[testenv]
commands =
Expand All @@ -9,46 +9,22 @@ commands =
extras =
testing

[testenv:py2-cover]
basepython = python2.7
commands =
#coverage run setup.py -q test -q
pip install -e .[testing]
coverage run --source=hypatia {envbindir}/pytest
coverage xml -o coverage-py2.xml
setenv =
COVERAGE_FILE=.coverage.py2
extras =
testing

[testenv:py3-cover]
basepython = python3.10
[testenv:coverage]
basepython = python3.7
commands =
#coverage run setup.py -q test -q
pip install -e .[testing]
coverage run --source=hypatia {envbindir}/pytest
coverage xml -o coverage-py3.xml
coverage report -m --fail-under=100
setenv =
COVERAGE_FILE=.coverage.py3
COVERAGE_FILE=.coverage
extras =
testing

[testenv:coverage]
basepython =
python2.7
skip_install = true
commands =
coverage erase
coverage combine
coverage xml
coverage report -m --fail-under=100
deps =
coverage
setenv =
COVERAGE_FILE=.coverage

[testenv:docs]
whitelist_externals = make
allowlist_externals = make
commands =
make -C docs {posargs:html} BUILDDIR={envdir} "SPHINXOPTS=-E"
extras =
Expand Down

0 comments on commit d195029

Please sign in to comment.