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

chore: move tests from tox to nox #330

Merged
merged 1 commit into from
Sep 2, 2021
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
8 changes: 1 addition & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ jobs:
python-version: 3.8
architecture: x64

- name: Install/fetch dependencies
run: |
set -exuo pipefail
pip install --upgrade pip setuptools
pip install tox

- name: Run linter
run: tox -e lint
run: pipx run nox -s lint
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,5 @@ jobs:
python-version: ${{ matrix.python }}
architecture: x64

- name: Install/fetch dependencies
run: |
set -exuo pipefail
pip install --upgrade pip setuptools
./tests/install.sh

- name: Run tests
run: ./tests/travis.sh
run: pipx run nox -s tests-${{ matrix.python }}
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ services:
notifications:
email: false

before_install:
- pip install --upgrade pip setuptools

install:
- ./tests/install.sh

- pip install nox
script:
- tests/travis.sh
- nox -s tests-3.8

cache:
directories:
Expand Down
75 changes: 75 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import os
import sys

from pathlib import Path

import nox


RUNNING_CI = "TRAVIS" in os.environ or "GITHUB_ACTIONS" in os.environ


@nox.session(reuse_venv=True)
def lint(session: nox.Session) -> str:
"""
Run linters on the codebase.
"""
session.install("flake8", "mypy")
session.run("flake8", "auditwheel")
session.run("mypy", "auditwheel")


@nox.session()
def coverage(session: nox.Session) -> str:
"""
Run coverage using unit tests.
"""
session.install("-r", "test-requirements.txt", "pytest-cov")
session.run(
"python",
"-m",
"pytest",
"tests/unit",
"--cov=auditwheel",
"--cov-report=term-missing"
)


def _docker_images(session):
tmp_dir = Path(session.create_tmp())
script = tmp_dir / "list_images.py"
images_file = tmp_dir / "images.lst"
script.write_text(
fr"""
from pathlib import Path
from tests.integration.test_manylinux import MANYLINUX_IMAGES
images = "\n".join(MANYLINUX_IMAGES.values())
Path(r"{images_file}").write_text(images)
"""
)
session.run("python", str(script), silent=True)
return images_file.read_text().splitlines()


@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
def tests(session: nox.Session) -> str:
"""
Run tests.
"""
posargs = session.posargs
session.install("-r", "test-requirements.txt", "-e", ".")
if RUNNING_CI:
session.install("pytest-cov", "codecov")
posargs.extend(["--cov", "auditwheel", "--cov-branch"])
# pull manylinux images that will be used.
# this helps passing tests which would otherwise timeout.
for image in _docker_images(session):
session.run("docker", "pull", image, external=True)

session.run("pytest", "-s", *posargs)
if RUNNING_CI:
session.run("auditwheel", "lddtree", sys.executable)
try:
session.run("codecov")
except nox.command.CommandFailed:
pass # Ignore failures from codecov tool
3 changes: 0 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
pytest>=3.4
pytest-cov
jsonschema
pypatchelf
flake8
pretend
docker
pyelftools
mypy
9 changes: 0 additions & 9 deletions tests/install.sh

This file was deleted.

7 changes: 0 additions & 7 deletions tests/travis.sh

This file was deleted.

15 changes: 0 additions & 15 deletions tox.ini

This file was deleted.