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

Replace tox with nox #1122

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}
- name: Install Deps
run: python -m pip install -U tox setuptools virtualenv wheel
run: python -m pip install -U nox setuptools virtualenv wheel
- name: Install and Run Tests
run: tox -e terra-main
run: nox -e "test-terra-main-${{ matrix.python-version }}"
if: runner.os != 'macOS'
- name: Install and Run Tests
run: tox -e terra-main
run: nox -e "test-terra-main-${{ matrix.python-version }}"
if: runner.os == 'macOS'
env:
OMP_NUM_THREADS: 1
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U virtualenv setuptools wheel tox
pip install -U virtualenv setuptools wheel nox
sudo apt-get install graphviz pandoc
- name: Build and publish
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U virtualenv setuptools wheel tox
pip install -U virtualenv setuptools wheel nox
sudo apt-get install graphviz pandoc
- name: Build and publish
env:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}
- name: Install Deps
run: python -m pip install -U tox setuptools virtualenv wheel
run: python -m pip install -U nox setuptools virtualenv wheel
- name: Install and Run Tests
run: tox -e py
run: nox -e "test-${{ matrix.python-version }}"
if: runner.os != 'macOS'
- name: Install and Run Tests
run: tox -e py
run: nox -e "test-${{ matrix.python-version }}"
if: runner.os == 'macOS'
env:
OMP_NUM_THREADS: 1
Expand All @@ -69,9 +69,9 @@ jobs:
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}-
- name: Install Deps
run: python -m pip install -U tox
run: python -m pip install -U nox
- name: Run lint
run: tox -elint
run: nox -e lint
docs:
name: docs
runs-on: ubuntu-latest
Expand All @@ -94,10 +94,10 @@ jobs:
${{ runner.os }}-
- name: Install Deps
run: |
python -m pip install -U tox
python -m pip install -U nox
sudo apt-get install -y pandoc graphviz
- name: Build Docs
run: tox -edocs
run: nox -e docs
- name: Compress Artifacts
run: |
mkdir artifacts
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
Expand Down
21 changes: 12 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=invalid-name, wrong-import-position, unused-argument

"""
Sphinx documentation builder.
"""
Expand Down Expand Up @@ -178,42 +180,43 @@
def _get_versions(app, config):
context = config.html_context
start_version = (0, 5, 0)
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True)
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True, check=False)
proc.check_returncode()
current_version = proc.stdout.decode("utf8")
current_version_info = current_version.split(".")
if current_version_info[0] == "0":
version_list = [
"0.%s" % x for x in range(start_version[1], int(current_version_info[1]) + 1)
]
version_list = list(
f"0.{x}" for x in range(start_version[1], int(current_version_info[1]) + 1)
)
else:
# TODO: When 1.0.0 add code to handle 0.x version list
version_list = []
pass
context["version_list"] = version_list
context["version_label"] = _get_version_label(current_version)
context["version_label"] = _get_version_label()


def _get_version_label(current_version):
def _get_version_label():
if not os.getenv("EXPERIMENTS_DEV_DOCS", None):
return release
else:
return "Development"


def setup(app):
"""Set up plugins."""
app.connect("config-inited", _get_versions)
app.connect("autodoc-skip-member", maybe_skip_member)


# Hardcoded list of class variables to skip in autodoc to avoid warnings
# Should come up with better way to address this

from qiskit_experiments.curve_analysis import ParameterRepr
from qiskit_experiments.curve_analysis import SeriesDef


def maybe_skip_member(app, what, name, obj, skip, options):
"""Hardcoded list of class variables to skip in autodoc to avoid warnings.
TODO: Fix class attribute generation to avoid hardcoding.
"""
skip_names = [
"analysis",
"set_run_options",
Expand Down
142 changes: 142 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
"""Configuration file for nox."""

import nox

PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]


@nox.session(python=PYTHON_VERSIONS, tags=["ci"])
def test(session):
"""Run CI tests."""
session.env["QISKIT_SUPPRESS_PACKAGING_WARNINGS"] = "Y"
session.install("-r", "requirements-dev.txt")
session.install("-e", ".")
posargs = {}
if session.posargs:
posargs = session.posargs
session.run("stestr", "run", *posargs)


@nox.session(python=PYTHON_VERSIONS, tags=["cron"])
def test_terra_main(session):
"""Run CI tests against terra main branch."""
session.env["QISKIT_SUPPRESS_PACKAGING_WARNINGS"] = "Y"
session.install("git+https://github.com/Qiskit/qiskit-terra", "-r", "requirements-dev.txt")
session.install("-e", ".")
posargs = {}
if session.posargs:
posargs = session.posargs
session.run("stestr", "run", *posargs)


@nox.session(tags=["style"])
def black(session):
"""Runs black."""
session.env["QISKIT_SUPPRESS_PACKAGING_WARNINGS"] = "Y"
session.install("-r", "requirements-dev.txt")
session.install("-e", ".")
session.run("black", "qiskit_experiments", "test", "tools", "setup.py", "docs/conf.py")


@nox.session(tags=["docs", "ci"])
def docs(session):
"""Build the full docs."""
session.env["QISKIT_SUPPRESS_PACKAGING_WARNINGS"] = "Y"
session.install("-r", "requirements-dev.txt")
session.install(".")
session.run(
"sphinx-build", "-T", "-W", "--keep-going", "-b", "html", "docs/", "docs/_build/html"
)


@nox.session(tags=["docs"])
def docs_minimal(session):
"""Build the docs without executing code in Jupyter Sphinx cells."""
session.env["QISKIT_DOCS_SKIP_EXECUTE"] = "1"
session.install("-r", "requirements-dev.txt")
session.install(".")
session.run(
"sphinx-build", "-T", "-W", "--keep-going", "-b", "html", "docs/", "docs/_build/html"
)


@nox.session(tags=["docs"])
def docs_parallel(session):
"""Build the full docs in parallel."""
session.install("-r", "requirements-dev.txt")
session.install(".")
session.run(
"sphinx-build",
"-j",
"auto",
"-T",
"-W",
"--keep-going",
"-b",
"html",
"docs/",
"docs/_build/html",
)


@nox.session(tags=["style", "lint", "ci"])
def lint(session):
"""Run black and pylint."""
session.env["QISKIT_SUPPRESS_PACKAGING_WARNINGS"] = "Y"
session.install("-r", "requirements-dev.txt")
session.install("-e", ".")
session.run(
"black", "--check", "qiskit_experiments", "test", "tools", "setup.py", "docs/conf.py"
)
session.run(
"pylint",
"-rn",
"-j",
"0",
"--rcfile=.pylintrc",
"qiskit_experiments/",
"test/",
"tools/",
"docs/conf.py",
)
session.run(
"python",
"tools/verify_headers.py",
)


@nox.session(tags=["lint"])
def lint_incr(session):
"""Runs lint only on changes compared against the main branch."""
session.env["QISKIT_SUPPRESS_PACKAGING_WARNINGS"] = "Y"
session.install("-r", "requirements-dev.txt")
session.install("-e", ".")
session.run(
"black", "--check", "qiskit_experiments", "test", "tools", "setup.py", "docs/conf.py"
)
session.run(
"git",
"fetch",
"-q",
"https://github.com/Qiskit/qiskit-experiments",
":lint_incr_latest",
external=True,
)
session.run(
"python",
"tools/pylint_incr.py",
"-rn",
"-j4",
"-sn",
"--paths",
":/qiskit_experiments/*.py",
":/test/*.py",
":/tools/*.py",
)
session.run(
"python",
"tools/verify_headers.py",
"qiskit_experiments",
"test",
"tools",
)
2 changes: 1 addition & 1 deletion tools/deploy_documentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sudo apt-get install -y ./rclone.deb
RCLONE_CONFIG_PATH=$(rclone config file | tail -1)

# Build the documentation.
tox -edocs
nox -e docs

echo "show current dir: "
pwd
Expand Down
2 changes: 1 addition & 1 deletion tools/deploy_documentation_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sudo apt-get install -y ./rclone.deb
RCLONE_CONFIG_PATH=$(rclone config file | tail -1)

# Build the documentation.
EXPERIMENTS_DEV_DOCS=1 tox -edocs
EXPERIMENTS_DEV_DOCS=1 nox -e docs

echo "show current dir: "
pwd
Expand Down
81 changes: 0 additions & 81 deletions tox.ini

This file was deleted.