Skip to content

Commit 2d44247

Browse files
authored
ci: add testing, fix issues (#12)
* ci: add testing, fix issues * ci: fix test * ci: drop windows for now (only cpp and pure work) * ci: restructure, patch issues with caching
1 parent 79ddb0d commit 2d44247

File tree

15 files changed

+75
-340
lines changed

15 files changed

+75
-340
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
checks:
11+
runs-on: ${{ matrix.runs-on }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
runs-on: [ubuntu-latest, macos-latest]
16+
17+
name: Check on ${{ matrix.runs-on }}
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: excitedleigh/[email protected]
22+
- run: nox --force-color

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ docs/_build
5656
# build output (testing)
5757
skbuild/cmake_test_compile/*
5858
*.env
59+
60+
# Generated manifests
61+
MANIFEST

noxfile.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import nox
2+
from pathlib import Path
3+
import shutil
4+
5+
hello_list = "hello-pure", "hello-cpp", "hello-pybind11", "hello-cython"
6+
7+
8+
@nox.session
9+
@nox.parametrize("module", hello_list + ("pen2-cython",))
10+
def dist(session, module):
11+
session.cd(f"projects/{module}")
12+
session.install("build")
13+
14+
# Cleanup bad caching
15+
skbuild = Path("_skbuild")
16+
if skbuild.exists():
17+
shutil.rmtree(skbuild)
18+
19+
# Builds SDist and wheel
20+
session.run("pyproject-build")
21+
22+
23+
@nox.session
24+
@nox.parametrize("module", hello_list)
25+
def test(session, module):
26+
session.cd(f"projects/{module}")
27+
session.install("pytest", "pytest-cov")
28+
29+
# Cleanup bad caching
30+
skbuild = Path("_skbuild")
31+
if skbuild.exists():
32+
shutil.rmtree(skbuild)
33+
34+
session.install(".")
35+
session.run("pytest")

projects/hello-cpp/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "scikit-build", "cmake>=3.18", "ninja"]

projects/hello-cpp/test_hello_cpp.py renamed to projects/hello-cpp/tests/test_hello_cpp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def test_hello(capfd):
55
hello.hello("World")
66
captured = capfd.readouterr()
7-
assert captured.out == "Hello, World!"
7+
assert captured.out == "Hello, World!\n"
88

99

1010
def test_elevation():

projects/hello-cython/hello/_hello.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
cpdef void hello(str strArg):
33
"Prints back 'Hello <param>', for example example: hello.hello('you')"
4-
print("Hello, {}!)".format(strArg))
4+
print("Hello, {}!".format(strArg))
55

66
cpdef long elevation():
77
"Returns elevation of Nevado Sajama."
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "scikit-build", "cmake>=3.18", "ninja", "cython"]

projects/hello-cython/test_hello_cython.py renamed to projects/hello-cython/tests/test_hello_cython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def test_hello(capfd):
55
hello.hello("World")
66
captured = capfd.readouterr()
7-
assert captured.out == "Hello, World!"
7+
assert captured.out == "Hello, World!\n"
88

99

1010
def test_elevation():

projects/hello-pure/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "scikit-build", "cmake>=3.18", "ninja"]

projects/hello-pure/test_hello_pure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def test_hello(capfd):
55
hello.hello("World")
66
captured = capfd.readouterr()
7-
assert captured.out == "Hello, World!"
7+
assert captured.out == "Hello, World!\n"
88

99

1010
def test_elevation():

0 commit comments

Comments
 (0)