Skip to content

Commit 7bbe735

Browse files
authored
CI/CD (#3)
* build: add test-pypi * ci: sybil doctests * ci: add ruff ignores * docs: fix numpy version-dependent string Signed-off-by: nstarman <[email protected]>
1 parent b28a0aa commit 7bbe735

File tree

4 files changed

+81
-12
lines changed

4 files changed

+81
-12
lines changed

.github/workflows/cd.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ jobs:
3131

3232
- uses: hynek/build-and-inspect-python-package@v2
3333

34-
publish:
34+
test-publish:
3535
needs: [dist]
36-
name: Publish to PyPI
37-
environment: pypi
36+
name: Publish to TestPyPI
37+
environment:
38+
name: testpypi
3839
permissions:
3940
id-token: write
4041
runs-on: ubuntu-latest
@@ -49,6 +50,21 @@ jobs:
4950
- uses: pypa/gh-action-pypi-publish@release/v1
5051
if: github.event_name == 'release' && github.event.action == 'published'
5152
with:
52-
# Remember to tell (test-)pypi about this repo before publishing
53-
# Remove this line to publish to PyPI
5453
repository-url: https://test.pypi.org/legacy/
54+
55+
publish:
56+
needs: [test-publish]
57+
name: Publish to PyPI
58+
environment: pypi
59+
permissions:
60+
id-token: write
61+
runs-on: ubuntu-latest
62+
if: github.event_name == 'release' && github.event.action == 'published'
63+
64+
steps:
65+
- uses: actions/download-artifact@v4
66+
with:
67+
name: Packages
68+
path: dist
69+
70+
- uses: pypa/gh-action-pypi-publish@release/v1

conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Doctest configuration."""
2+
3+
import platform
4+
from doctest import ELLIPSIS, NORMALIZE_WHITESPACE
5+
from importlib.util import find_spec
6+
7+
from sybil import Sybil
8+
from sybil.parsers.rest import DocTestParser, PythonCodeBlockParser, SkipParser
9+
10+
# TODO: stop skipping doctests on Windows when there is uniform support for
11+
# numpy 2.0+ scalar repr. On windows it is printed as 1.0 instead of
12+
# `np.float64(1.0)`.
13+
parsers = (
14+
[DocTestParser(optionflags=ELLIPSIS | NORMALIZE_WHITESPACE)]
15+
if platform.system() != "Windows"
16+
else []
17+
) + [
18+
PythonCodeBlockParser(),
19+
SkipParser(),
20+
]
21+
22+
pytest_collect_file = Sybil(
23+
parsers=parsers,
24+
patterns=["*.rst", "*.py"],
25+
).pytest()
26+
27+
28+
# TODO: via separate optional_deps package
29+
HAS_ASTROPY = find_spec("astropy") is not None
30+
HAS_GALA = find_spec("gala") is not None
31+
32+
collect_ignore_glob = []
33+
if not HAS_ASTROPY:
34+
collect_ignore_glob.append("src/unxt/_interop/unxt_interop_astropy/*")
35+
if not HAS_GALA:
36+
collect_ignore_glob.append("src/unxt/_interop/unxt_interop_gala/*")

pyproject.toml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@
4141
"sphinx_autodoc_typehints",
4242
"sphinx_copybutton",
4343
]
44-
test = ["numpy", "pytest >=6", "pytest-cov >=3"]
44+
test = [
45+
"numpy",
46+
"pytest >=6",
47+
"pytest-cov >=3",
48+
"pytest-github-actions-annotate-failures",
49+
"sybil",
50+
]
4551

4652
[project.urls]
4753
"Bug Tracker" = "https://github.com/GalacticDynamics/zeroth/issues"
@@ -59,12 +65,18 @@
5965

6066

6167
[tool.pytest.ini_options]
62-
addopts = ["--showlocals", "--strict-config", "--strict-markers", "-ra"]
68+
addopts = [
69+
"--showlocals",
70+
"--strict-config",
71+
"--strict-markers",
72+
"-p no:doctest", # using sybil
73+
"-ra",
74+
]
6375
filterwarnings = ["error"]
64-
log_cli_level = "INFO"
65-
minversion = "6.0"
66-
testpaths = ["tests"]
67-
xfail_strict = true
76+
log_cli_level = "INFO"
77+
minversion = "6.0"
78+
testpaths = ["tests/", "docs", "src/"]
79+
xfail_strict = true
6880

6981

7082
[tool.coverage]
@@ -93,9 +105,14 @@
93105
[tool.ruff.lint]
94106
extend-select = ["ALL"]
95107
ignore = [
108+
"D203", # 1 blank line required before class docstring
109+
"D213", # Multi-line docstring summary should start at the second line
110+
"FIX002", # Line contains TODO, consider resolving the issue
96111
"ISC001", # Conflicts with formatter
97112
"PLR09", # Too many <...>
98113
"PLR2004", # Magic value used in comparison
114+
"TD002", # Missing author in TODO
115+
"TD003" # Missing issue link on the line following this TODO
99116
]
100117

101118
[tool.ruff.lint.per-file-ignores]

src/zeroth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def zeroth(x: Iterable[T], /) -> T:
3636
'0'
3737
3838
>>> import numpy as np
39-
>>> zeroth(np.array([1, 2, 3]))
39+
>>> int(zeroth(np.array([1, 2, 3])))
4040
1
4141
4242
>>> class ReverseIterable:

0 commit comments

Comments
 (0)