Skip to content

Commit cee2152

Browse files
authored
build: use nox for github actions (#30)
2 parents 1e57eb6 + 0b6c2f7 commit cee2152

File tree

7 files changed

+78
-47
lines changed

7 files changed

+78
-47
lines changed

.github/workflows/unit.yaml

+45-18
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,65 @@ jobs:
1414
python-version: "3.10"
1515
- uses: pre-commit/[email protected]
1616

17-
build:
17+
mypy:
1818
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.10"
24+
- name: Install nox
25+
run: pip install nox
26+
- name: Check static typing
27+
run: nox -s mypy
28+
29+
build:
30+
needs: [lint, mypy]
1931
strategy:
2032
fail-fast: false
2133
matrix:
22-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
34+
os: [ubuntu-latest]
35+
python-version: ["3.9", "3.10", "3.11"]
2336
include:
2437
- os: macos-latest
25-
python-version: "3.11"
38+
python-version: "3.10"
2639
- os: windows-latest
27-
python-version: "3.11"
28-
40+
python-version: "3.10"
41+
runs-on: ${{ matrix.os }}
2942
steps:
3043
- uses: actions/checkout@v3
31-
32-
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v4
44+
- uses: actions/setup-python@v4
3445
with:
3546
python-version: ${{ matrix.python-version }}
36-
37-
- name: Install dependencies
38-
run: pip install .[test,dev]
39-
40-
- name: Check static typing
41-
run: mypy sphinxcontrib
42-
47+
- name: Install nox
48+
run: pip install nox
4349
- name: test with pytest
44-
run: pytest --color=yes --cov --cov-report=xml tests
50+
run: nox -s test
4551

46-
- name: coverage
47-
run: coverage xml
52+
docs:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: actions/setup-python@v4
57+
with:
58+
python-version: "3.10"
59+
- name: Install nox
60+
run: pip install nox
61+
- name: Build docs
62+
run: nox -s docs
4863

64+
coverage:
65+
needs: [build]
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v3
69+
- uses: actions/setup-python@v4
70+
with:
71+
python-version: "3.10"
72+
- name: Install nox and coverage
73+
run: pip install nox
74+
- name: test with pytest
75+
run: nox -s test
4976
- name: codecov
5077
uses: codecov/codecov-action@v3
5178
with:

noxfile.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder.
44
"""
5+
from pathlib import Path
56

67
import nox
78

@@ -11,27 +12,28 @@ def docs(session):
1112
"""Build the documentation."""
1213
session.install(".[doc]")
1314
b = session.posargs[0] if session.posargs else "html"
14-
session.run("sphinx-build", f"-b={b}", "-a", "-E", "docs", f"docs/_build/{b}")
15+
dst = Path(__file__).parent / "docs" / "_build" / b
16+
session.run("sphinx-build", f"-b={b}", "-a", "-E", "docs", str(dst))
1517

1618

1719
@nox.session(reuse_venv=True)
1820
def lint(session):
1921
"""Apply the pre-commits."""
2022
session.install("pre-commit")
21-
session.run("pre-commit", "run", "-a", *session.posargs)
23+
session.run("pre-commit", "run", "--all-files")
2224

2325

2426
@nox.session(reuse_venv=True)
2527
def mypy(session):
2628
"""Run a mypy check of the lib."""
27-
session.install(".[dev]")
29+
session.install("mypy")
2830
test_files = session.posargs or ["sphinxcontrib"]
2931
session.run("mypy", *test_files)
3032

3133

3234
@nox.session(reuse_venv=True)
3335
def test(session):
3436
"""Run all the test using the environment varialbe of the running machine."""
35-
session.install(".[test]")
36-
test_files = session.posargs or ["tests"]
37-
session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
37+
session.install("--verbose", ".[test]")
38+
# session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
39+
session.run("sphinx-build", "--bug-report")

pyproject.toml

+15-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,21 @@ content-type = "text/x-rst"
4040
repository = "https://github.com/sphinx-contrib/icon"
4141

4242
[project.optional-dependencies]
43-
dev = ["nox", "pre-commit", "mypy"]
44-
test = ["pytest", "beautifulsoup4", "pytest-regressions", "pytest-cov"]
45-
doc = ["pydata-sphinx-theme==0.13.0rc3", "sphinx-design", "sphinx-copybutton"]
43+
dev = [
44+
"nox",
45+
"pre-commit",
46+
]
47+
test = [
48+
"pytest",
49+
"beautifulsoup4",
50+
"pytest-regressions",
51+
"pytest-cov"
52+
]
53+
doc = [
54+
"pydata-sphinx-theme",
55+
"sphinx-design",
56+
"sphinx-copybutton"
57+
]
4658

4759
[tool.setuptools]
4860
include-package-data = false

setup.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
from pathlib import Path
23

34
from pynpm import NPMPackage
@@ -8,6 +9,10 @@
89

910
ROOT = Path(__file__).parent
1011

12+
# create a global variable to check if we are on windows
13+
# to pilot the shell option to run the tests
14+
is_windows = platform.system() == "Windows"
15+
1116

1217
def update_package_data(distribution) -> None:
1318
"""Update package_data to catch changes during setup."""
@@ -43,7 +48,8 @@ def finalize_options(self):
4348

4449
def run(self):
4550
"""Run the command."""
46-
NPMPackage(ROOT / "sphinxcontrib" / "icon" / "package.json").install()
51+
package = ROOT / "sphinxcontrib" / "icon" / "package.json"
52+
NPMPackage(str(package), shell=is_windows).install()
4753
update_package_data(self.distribution)
4854

4955

sphinxcontrib/icon/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
2222
font_handler = Fontawesome()
2323

2424
# install html related files
25+
raise Exception(str(font_handler.css_file.resolve()))
2526
app.add_css_file(str(font_handler.css_file.resolve()))
2627
app.add_js_file(str(font_handler.js_file.resolve()))
2728

sphinxcontrib/icon/font_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def add_latex_font_files(self, app: Sphinx) -> None:
4343
dst = Path(app.builder.outdir) / f.name
4444
logger.info(f"Writing: {f.name}")
4545
ensuredir(app.builder.outdir)
46-
copyfile(str(f.resolve()), str(dst.resolve()))
46+
copyfile(str(f), str(dst))
4747

4848
def add_latex_font(self, app: Sphinx, config: Config) -> None:
4949
"""Add the fontawesome fontfamily in the preamble of the .tex file."""

sphinxcontrib/icon/package-lock.json

+1-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)