Skip to content

Commit

Permalink
tests: support nox and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Jun 10, 2021
1 parent ba7a33c commit 74562b6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ ignore = E203, E231, E501, E722, W503, B950
select = C,E,F,W,T,B,B9,I
per-file-ignores =
tests/*: T
noxfile.py: T
11 changes: 11 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ detailed description of best practices for developing Scikit-HEP packages.

[skhep-dev-intro]: https://scikit-hep.org/developer/intro

# Quick run with Nox

If you have nox, this project supports nox. These are the supplied sessions:

```console
nox -s lint
nox -s tests
nox -s docs -- serve
nox -s build
```

# Setting up a development environment

You can set up a development environment by running:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.3
with:
Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: [ubuntu-latest, macos-latest, windows-latest]

include:
- python-version: pypy-3.6
- python-version: pypy-3.7
runs-on: ubuntu-latest


Expand All @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v1

- name: Build sdist and wheel
run: pipx run --spec build pyproject-build
run: pipx run build

- uses: actions/upload-artifact@v2
with:
Expand All @@ -68,5 +68,4 @@ jobs:
- uses: pypa/gh-action-pypi-publish@v1.4.2
if: github.event_name == 'release' && github.event.action == 'published'
with:
user: __token__
password: ${{ secrets.pypi_password }}
65 changes: 65 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import shutil
from pathlib import Path

import nox

ALL_PYTHONS = ["3.6", "3.7", "3.8", "3.9"]

nox.options.sessions = ["lint", "tests"]


DIR = Path(__file__).parent.resolve()


@nox.session
def lint(session):
"""
Run the linter.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")


@nox.session(python=ALL_PYTHONS)
def tests(session):
"""
Run the unit and regular tests.
"""
session.install(".[test]")
session.run("pytest")


@nox.session
def docs(session):
"""
Build the docs. Pass "serve" to serve.
"""

session.install(".[docs]")
session.chdir("docs")
session.run("sphinx-build", "-M", "html", ".", "_build")

if session.posargs:
if "serve" in session.posargs:
print("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
else:
print("Unsupported argument to docs")


@nox.session
def build(session):
"""
Build an SDist and wheel.
"""

build_p = DIR.joinpath("build")
if build_p.exists():
shutil.rmtree(build_p)

dist_p = DIR.joinpath("dist")
if dist_p.exists():
shutil.rmtree(dist_p)

session.install("build")
session.run("python", "-m", "build")

0 comments on commit 74562b6

Please sign in to comment.