Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests, test Python 3.10, and run on tests on GitHub Actions #298

Merged
merged 4 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-20.04

strategy:
matrix:
python-version:
- 2.7
- 3.7
- 3.8
- 3.9
- '3.10'

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox

- name: Run tox targets for ${{ matrix.python-version }}
run: |
ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}")
TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') tox

- name: Upload coverage data
uses: actions/upload-artifact@v2
with:
name: coverage-data
path: '.coverage.*'

coverage:
name: Coverage
runs-on: ubuntu-20.04
needs: tests
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]

- name: Download data
uses: actions/download-artifact@v2
with:
name: coverage-data

- name: Combine coverage and fail if it's <100%
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=55

- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: html-report
path: htmlcov
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion nodeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ def make_parser():
help='Ignore certificates for package downloads. - UNSAFE -')

parser.add_argument(
metavar='DEST_DIR', dest='env_dir', nargs='?', help='Destination directory')
metavar='DEST_DIR', dest='env_dir', nargs='?',
help='Destination directory')

return parser

Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def read_file(file_name):
author='Eugene Kalinin',
author_email='e.v.kalinin@gmail.com',
install_requires=['setuptools'],
python_requires=(
">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*"
),
description="Node.js virtual environment builder",
long_description=ldesc,
py_modules=['nodeenv'],
Expand All @@ -49,8 +52,10 @@ def read_file(file_name):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries :: Python Modules'
Expand Down
4 changes: 2 additions & 2 deletions tests/nodeenv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def test_smoke_n_system_special_chars(tmpdir):
])


@pytest.yield_fixture
@pytest.fixture
def mock_index_json():
# retrieved 2019-12-31
with open(os.path.join(HERE, 'nodejs_index.json'), 'rb') as f:
with mock.patch.object(nodeenv, 'urlopen', return_value=f):
yield


@pytest.yield_fixture
@pytest.fixture
def cap_logging_info():
with mock.patch.object(nodeenv.logger, 'info') as mck:
yield mck
Expand Down
4 changes: 2 additions & 2 deletions tests/test_install_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_write(tmpdir, name, content_var):
bin_dir.join(n).write(n)

with mock.patch.object(sys, 'argv', ['nodeenv', str(tmpdir)]):
opts = nodeenv.parse_args()[0]
opts = nodeenv.parse_args()
nodeenv.install_activate(str(tmpdir), opts)

content = getattr(nodeenv, content_var)
Expand All @@ -70,7 +70,7 @@ def test_python_virtualenv(tmpdir, name, content_var):
bin_dir.join(n).write(n)

with mock.patch.object(sys, 'argv', ['nodeenv', '-p']):
opts = nodeenv.parse_args()[0]
opts = nodeenv.parse_args()
nodeenv.install_activate(str(tmpdir), opts)

content = getattr(nodeenv, content_var)
Expand Down
15 changes: 2 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
[tox]
# These should match the travis env list
envlist = py27,py36,py37,pypy
# These should match the GitHub Actions env list
envlist = py27,py37,py38,py39,py310

[testenv]
install_command = pip install {opts} {packages}
deps = -rrequirements-dev.txt
setenv =
LANG=en_US.UTF-8
commands =
coverage erase
coverage run -p -m pytest {posargs:tests}
# Needed because we subprocess to ourselves
coverage combine
coverage report --show-missing --fail-under 55 # TODO: 100
flake8 --extend-ignore=E127 nodeenv.py tests setup.py

[testenv:venv]
envdir = venv-nodeenv
commands =

[testenv:docs]
deps =
{[testenv]deps}
sphinx
changedir = docs
commands = sphinx-build -b html -d build/doctrees source build/html

[pytest]
markers =
integration: tests that take a little bit longer