Skip to content

Commit e2aef95

Browse files
authored
ci: Run CI, tox test for all supported python versions #536
- Include python 3.7, 3.8, and 3.9 as well to the Github CI actions. - Configure tox to run tests on python3.7-python3.12 (skip if python interpreters are not found on local environments). - Add "Contributing" section to docs/development, suggesting how to run tests locally. - Unify the way how we specify pytest options (`-s -vv`) into tox.ini. - Bump up `python_requires` to 3.7 in the package spec. - Make sure to use `nvim --clean` to against flaky tests. No SHADA and swapfiles should be used.
1 parent 6cf8fc1 commit e2aef95

File tree

6 files changed

+65
-18
lines changed

6 files changed

+65
-18
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ concurrency:
99
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.repository_owner == 'neovim' && github.sha || github.ref_name }}
1010
cancel-in-progress: true
1111

12-
env:
13-
PYTEST_ADDOPTS: '-vv'
14-
1512
jobs:
1613
lint:
1714
runs-on: ubuntu-latest
@@ -24,17 +21,30 @@ jobs:
2421
- name: install dependencies
2522
run: python3 -m pip install tox tox-gh-actions
2623
- name: checkqa
27-
env:
28-
TOXENV: 'checkqa,docs'
29-
run: tox
24+
run: tox run -e checkqa,docs
3025

3126
test:
3227
strategy:
3328
fail-fast: false
3429
matrix:
35-
python: ['3.10', '3.11', '3.12-dev']
30+
python-version: ['3.10', '3.11', '3.12-dev']
3631
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
3732
include:
33+
- os: ubuntu-20.04
34+
python-version: '3.7'
35+
NIGHTLY: nvim-linux64.tar.gz
36+
NVIM_BIN_PATH: nvim-linux64/bin
37+
EXTRACT: tar xzf
38+
- os: ubuntu-latest
39+
python-version: '3.8'
40+
NIGHTLY: nvim-linux64.tar.gz
41+
NVIM_BIN_PATH: nvim-linux64/bin
42+
EXTRACT: tar xzf
43+
- os: ubuntu-latest
44+
python-version: '3.9'
45+
NIGHTLY: nvim-linux64.tar.gz
46+
NVIM_BIN_PATH: nvim-linux64/bin
47+
EXTRACT: tar xzf
3848
- os: ubuntu-latest
3949
NIGHTLY: nvim-linux64.tar.gz
4050
NVIM_BIN_PATH: nvim-linux64/bin
@@ -54,7 +64,7 @@ jobs:
5464
- uses: actions/setup-python@v4
5565
with:
5666
cache: 'pip'
57-
python-version: ${{ matrix.python }}
67+
python-version: ${{ matrix.python-version }}
5868

5969
- name: install neovim
6070
run: |
@@ -71,7 +81,9 @@ jobs:
7181
run: echo "$(pwd)/${{ matrix.NVIM_BIN_PATH }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
7282

7383
- name: install dependencies
74-
run: python3 -m pip install tox tox-gh-actions
84+
run: |
85+
python3 -m pip install -U pip
86+
python3 -m pip install tox tox-gh-actions
7587
7688
- name: test with tox
7789
run: |
@@ -80,4 +92,4 @@ jobs:
8092
nvim --version
8193
which -a python3
8294
python3 --version
83-
tox
95+
tox run

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ See the [Python Plugin API](http://pynvim.readthedocs.io/en/latest/usage/python-
4848
Development
4949
-----------
5050

51-
Use (and activate) a local virtualenv.
51+
Use (and activate) a local virtualenv, for example:
5252

5353
python3 -m virtualenv venv
5454
source venv/bin/activate

docs/development.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ If you change the code, you need to run::
66
pip3 install .
77

88
for the changes to have effect.
9+
910
Alternatively you could execute Neovim with the ``$PYTHONPATH`` environment variable::
1011

1112
PYTHONPATH=/path/to/pynvim nvim
@@ -25,7 +26,7 @@ directory added to ``sys.path``.
2526

2627
If you want to test a different version than ``nvim`` in ``$PATH`` use::
2728

28-
NVIM_CHILD_ARGV='["/path/to/nvim", "-u", "NONE", "--embed", "--headless"]' pytest
29+
NVIM_CHILD_ARGV='["/path/to/nvim", "--clean", "--embed", "--headless"]' pytest
2930

3031
Alternatively, if you want to see the state of nvim, you could use::
3132

@@ -36,6 +37,24 @@ Alternatively, if you want to see the state of nvim, you could use::
3637
But note you need to restart Neovim every time you run the tests!
3738
Substitute your favorite terminal emulator for ``xterm``.
3839

40+
Contributing
41+
------------
42+
43+
Before submitting any pull requests, please run linters and tests if possible.
44+
45+
In the CI we run `flake8` and `mypy`:
46+
47+
flake8 pynvim test
48+
mypy pynvim test
49+
50+
If you have `tox`_, you can test with multiple python versions locally:
51+
52+
tox run # run on all available python environments
53+
tox run -e py311,checkqa # run on python3.11, and linters
54+
tox run --parallell # run everything in parallel
55+
56+
.. _`tox`: https://tox.wiki/
57+
3958
Troubleshooting
4059
---------------
4160

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
] + pytest_runner,
1515

1616
tests_require = [
17-
'pytest>=3.4.0',
17+
'pytest',
1818
]
1919

2020
extras_require = {
@@ -43,7 +43,7 @@
4343
packages=['pynvim', 'pynvim.api', 'pynvim.msgpack_rpc',
4444
'pynvim.msgpack_rpc.event_loop', 'pynvim.plugin',
4545
'neovim', 'neovim.api'],
46-
python_requires=">=3.6",
46+
python_requires=">=3.7",
4747
install_requires=install_requires,
4848
setup_requires=setup_requires,
4949
tests_require=tests_require,

test/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ def vim() -> pynvim.Nvim:
1414
listen_address = os.environ.get('NVIM_LISTEN_ADDRESS')
1515
if child_argv is None and listen_address is None:
1616
child_argv = json.dumps([
17-
"nvim", "-u", "NONE", "--embed", "--headless",
17+
"nvim",
18+
"--clean", # no config and plugins (-u NONE), no SHADA
19+
"-n", # no swap file
20+
"--embed",
21+
"--headless",
1822
"-c", "let g:python3_host_prog='python3'", # workaround neovim/neovim#25316
1923
])
2024

tox.ini

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
# https://tox.wiki/en/stable/config.html
2+
# Note: to run individual jobs locally, do "tox run -e py310,311"
3+
14
[tox]
5+
min_version = 4.0
26
envlist =
3-
py{310,311}-asyncio
7+
py{37,38,39,310,311,312}-asyncio
48
checkqa
9+
skip_missing_interpreters =
10+
true
511

612
[gh-actions]
13+
# https://github.com/ymyzk/tox-gh-actions
714
python =
15+
3.7: py37
16+
3.8: py38
17+
3.9: py39
818
3.10: py310
919
3.11: py311
20+
3.12: py312
1021
pypy3: pypy3
1122

1223
[testenv]
@@ -17,9 +28,9 @@ deps =
1728
# pyuv: pyuv
1829
# setenv =
1930
# cov: PYTEST_ADDOPTS=--cov=. {env:PYTEST_ADDOPTS:}
20-
passenv = PYTEST_ADDOPTS
31+
# passenv = PYTEST_ADDOPTS
2132
commands =
22-
python -m pytest {posargs}
33+
python3 -m pytest --color yes -s -vv {posargs}
2334

2435
[testenv:checkqa]
2536
deps =
@@ -30,6 +41,7 @@ deps =
3041
pep8-naming
3142
msgpack-types
3243
ignore_errors = true
44+
# see also: docs/development.rst
3345
commands =
3446
flake8 {posargs:pynvim test}
3547
mypy --show-error-codes {posargs:pynvim test}

0 commit comments

Comments
 (0)