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

Add nox for running tests in an isolated environment #140

Merged
merged 2 commits into from
Nov 10, 2023
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
16 changes: 16 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set -e

PLATFORM=$(python -c 'import sys; print(sys.platform)')

RED="\033[31;1m"
MAGENTA="\033[35m"
NORMAL="\033[0m"
Expand All @@ -9,6 +11,8 @@ prun() { echo -e "\n$RED\$ $@ $NORMAL\n" ; "$@" ; }
prun cd example_pkg

prun spin --version

pip install meson-python ninja
prun spin build

# Test spin run
Expand Down Expand Up @@ -40,4 +44,16 @@ PYTHONPATH=./tmp spin test

prun spin sdist
prun spin example

pip install sphinx
prun spin docs

## Platform specialized tests

if [[ $PLATFORM == linux ]]; then
prun spin gdb -c 'import example_pkg; example_pkg.echo("hi")' -- --eval "run" --batch
fi

# if [[ $PLATFORM == darwin ]]; then

# if [[ $PLATFORM =~ ^win.* ]]; then
29 changes: 2 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y gdb
- name: Install
- name: Tests
run: |
pip install -e .
pip install pytest meson-python ninja build sphinx
- name: Library tests
env:
PYTHONPATH: "."
run: |
pytest --pyargs spin

- name: Functional tests (Linux)
if: matrix.os == 'ubuntu-latest'
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
run: |
source .github/workflows/test.sh
spin gdb -c 'import example_pkg; example_pkg.echo("hi")' -- --eval "run" --batch

- name: Functional tests (MacOS)
if: matrix.os == 'macos-latest'
shell: bash
run: source .github/workflows/test.sh

- name: Functional tests (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: source .github/workflows/test.sh
pipx run nox --forcecolor -s tests
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ sudo pacman -S noto-fonts-emoji
fc-cache -f -v
```

## For contributors

`spin` development happens on GitHub at [scientific-python/spin](https://github.com/scientific-python/spin).
`spin` tests are invoked using:

```
nox -s tests
```

## History

The `dev.py` tool was [proposed for SciPy](https://github.com/scipy/scipy/issues/15489) by Ralf Gommers and [implemented](https://github.com/scipy/scipy/pull/15959) by Sayantika Banik, Eduardo Naufel Schettino, and Ralf Gommers (also see [Sayantika's blog post](https://labs.quansight.org/blog/the-evolution-of-the-scipy-developer-cli)).
Expand Down
11 changes: 11 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import nox


@nox.session
def tests(session: nox.Session) -> None:
"""
Run the unit and regular tests.
"""
session.install(".", "pytest", "build")
session.run("pytest", "spin", *session.posargs)
session.run("bash", ".github/workflows/test.sh", external=True)
2 changes: 1 addition & 1 deletion spin/cmds/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@click.command()
def sdist():
"""📦 Build a source distribution in `dist/`"""
run(["python", "-m", "build", ".", "--sdist"])
run(["pyproject-build", ".", "--sdist"])