-
Notifications
You must be signed in to change notification settings - Fork 36
124 lines (111 loc) · 3.78 KB
/
build-and-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- '3.10'
- 3.11
- 3.12.0-rc.1
# 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
astroid-version:
- ''
include:
# Test recent Python on Astroid v2 too (the above natural tests will
# pick up Astroid v3 for these Python versions)
- python-version: '3.8'
astroid-version: '<3'
- python-version: '3.9'
astroid-version: '<3'
- python-version: '3.10'
astroid-version: '<3'
- python-version: '3.11'
astroid-version: '<3'
- python-version: '3.12'
astroid-version: '<3'
env:
ASTTOKENS_SLOW_TESTS: 1
COVERALLS_PARALLEL: true
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
if: matrix.python-version != '2.7'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python 2.7
if: matrix.python-version == '2.7'
run: |
sudo apt-get update
sudo apt-get install python2.7 -y
# Get everything to use this new Python as the default.
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2.7 get-pip.py
sudo ln -sf /usr/bin/pip2 /usr/bin/pip
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
- name: Install dependencies
run: |
pip install --upgrade coveralls pytest setuptools setuptools_scm pep517
pip install .[test] 'astroid${{ matrix.astroid-version }}'
- 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.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
# 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@v3
- 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