Skip to content

Commit 2d141cb

Browse files
committed
Try nox in ci
1 parent c0128f5 commit 2d141cb

File tree

4 files changed

+200
-12
lines changed

4 files changed

+200
-12
lines changed

.make/base.make

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,25 +401,22 @@ bump-patch: ## Bump application patch version <0.0.X>
401401

402402
.PHONY: check-lint
403403
check-lint: ## Check code linting (black, isort, flake8, docformatter and pylint)
404-
poetry run tox -e black,isort,flake8,docformatter,pylint
405-
406-
.PHONY: check-pylint
407-
check-pylint: ## Check code with pylint
408-
poetry run tox -e pylint
404+
poetry run nox -s check
409405

410406
.PHONY: fix-lint
411407
fix-lint: ## Fix code linting (black, isort, flynt, docformatter)
412-
poetry run tox -e fix
408+
poetry run nox -s fix
413409

414410
.PHONY: precommit
415411
precommit: ## Run Pre-commit on all files manually
416-
poetry run tox -e precommit
412+
poetry run pre-commit run --all-files
413+
417414

418415
## -- Tests targets ------------------------------------------------------------------------------------------------- ##
419416

420417
.PHONY: test
421418
test: ## Run all tests
422-
poetry run tox -e test
419+
poetry run nox -s test
423420

424421
TEST_ARGS ?=
425422
MARKER_TEST_ARGS = -m "$(TEST_ARGS)"
@@ -429,7 +426,7 @@ CUSTOM_TEST_ARGS = "$(TEST_ARGS)"
429426
.PHONY: test-marker
430427
test-marker: ## Run tests using pytest markers. Ex. make test-tag TEST_ARGS="<marker>"
431428
@if [ -n "$(TEST_ARGS)" ]; then \
432-
poetry run tox -e test-custom -- -- $(MARKER_TEST_ARGS); \
429+
poetry run nox -s test-custom -- -- $(MARKER_TEST_ARGS); \
433430
else \
434431
echo "" ; \
435432
echo 'ERROR : Variable TEST_ARGS has not been set, please rerun the command like so :' ; \
@@ -440,7 +437,7 @@ test-marker: ## Run tests using pytest markers. Ex. make test-tag TEST_ARGS="<ma
440437
.PHONY: test-specific
441438
test-specific: ## Run specific tests using the -k option. Ex. make test-specific TEST_ARGS="<name-of-test>"
442439
@if [ -n "$(TEST_ARGS)" ]; then \
443-
poetry run tox -e test-custom -- -- $(SPECIFIC_TEST_ARGS); \
440+
poetry run nox -s test_custom -- -- $(SPECIFIC_TEST_ARGS); \
444441
else \
445442
echo "" ; \
446443
echo 'ERROR : Variable TEST_ARGS has not been set, please rerun the command like so :' ; \
@@ -452,7 +449,7 @@ test-specific: ## Run specific tests using the -k option. Ex. make test-specific
452449
.PHONY: test-custom
453450
test-custom: ## Run tests with custom args. Ex. make test-custom TEST_ARGS="-m 'not offline'"
454451
@if [ -n "$(TEST_ARGS)" ]; then \
455-
poetry run tox -e test-custom -- -- $(CUSTOM_TEST_ARGS); \
452+
poetry run nox -s test_custom -- -- $(CUSTOM_TEST_ARGS); \
456453
else \
457454
echo "" ; \
458455
echo 'ERROR : Variable TEST_ARGS has not been set, please rerun the command like so :' ; \

noxfile.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
from pathlib import Path
2+
3+
import nox
4+
5+
nox.options.reuse_existing_virtualenvs = True # Reuse virtual environments
6+
nox.options.sessions = ["precommit"]
7+
8+
9+
def get_paths(session):
10+
package_path = Path(session.bin).parent.parent.parent
11+
return {
12+
"all": [
13+
package_path / "geospatial_tools",
14+
package_path / "tests",
15+
package_path / "scripts",
16+
],
17+
"module": [
18+
package_path / "geospatial_tools",
19+
package_path / "scripts",
20+
],
21+
}
22+
23+
24+
#
25+
# Sessions
26+
#
27+
28+
29+
@nox.session()
30+
def pylint(session):
31+
paths = get_paths(session)
32+
session.run("poetry", "run", "pylint", *paths["module"], external=True)
33+
34+
35+
@nox.session()
36+
def flake8(session):
37+
paths = get_paths(session)
38+
session.run("poetry", "run", "flake8", *paths["all"], external=True)
39+
40+
41+
@nox.session()
42+
def docformatter(session):
43+
paths = get_paths(session)
44+
session.run(
45+
"poetry",
46+
"run",
47+
"docformatter",
48+
"--config",
49+
f"{paths['all'][0].parent}/pyproject.toml",
50+
*paths["all"],
51+
external=True,
52+
)
53+
54+
55+
@nox.session()
56+
def check(session):
57+
paths = get_paths(session)
58+
session.run("poetry", "run", "black", "--check", *paths["all"], external=True)
59+
session.run("poetry", "run", "isort", *paths["all"], "--check", external=True)
60+
session.run("poetry", "run", "flynt", *paths["all"], external=True)
61+
session.run(
62+
"poetry",
63+
"run",
64+
"docformatter",
65+
"--config",
66+
f"{paths['all'][0].parent}/pyproject.toml",
67+
*paths["all"],
68+
external=True,
69+
)
70+
session.run("poetry", "run", "flake8", *paths["all"], external=True)
71+
session.run("poetry", "run", "pylint", *paths["module"], external=True)
72+
73+
74+
@nox.session()
75+
def fix(session):
76+
paths = get_paths(session)
77+
session.run("poetry", "run", "black", *paths["all"], external=True)
78+
session.run("poetry", "run", "isort", *paths["all"], external=True)
79+
session.run("poetry", "run", "flynt", *paths["all"], external=True)
80+
session.run(
81+
"poetry",
82+
"run",
83+
"docformatter",
84+
"--in-place",
85+
"--config",
86+
f"{paths['all'][0].parent}/pyproject.toml",
87+
*paths["all"],
88+
external=True,
89+
)
90+
91+
92+
@nox.session()
93+
def precommit(session):
94+
session.run("poetry", "run", "pre-commit", "run", "--all-files", external=True)
95+
96+
97+
@nox.session()
98+
def black(session):
99+
paths = get_paths(session)
100+
session.run("poetry", "run", "black", "--check", *paths["all"], external=True)
101+
102+
103+
@nox.session()
104+
def isort(session):
105+
paths = get_paths(session)
106+
session.run("poetry", "run", "isort", *paths["all"], "--check", external=True)
107+
108+
109+
@nox.session()
110+
def flynt(session):
111+
paths = get_paths(session)
112+
session.run("poetry", "run", "flynt", *paths["all"], external=True)
113+
114+
115+
@nox.session()
116+
def test(session):
117+
session.run("poetry", "run", "pytest", external=True)
118+
119+
120+
@nox.session()
121+
def test_custom(session):
122+
session.run(
123+
"poetry", "run", "pytest", external=True, *session.posargs
124+
) # Pass additional arguments directly to pytest
125+
126+
127+
@nox.session()
128+
def test_nb(session):
129+
session.run(
130+
"poetry",
131+
"run",
132+
"pytest",
133+
"--nbval",
134+
"tests/test_notebooks/",
135+
"--nbval-sanitize-with=tests/test_notebooks/sanitize_file.cfg",
136+
external=True,
137+
)

poetry.lock

Lines changed: 54 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ flake8-pyproject = "^1.2.3"
4242
docformatter = {extras = ["tomli"], version = "^1.7.5"}
4343
nbval = "^0.11.0"
4444
black = "^24.8.0"
45+
nox = "^2024.4.15"
4546

4647
[tool.poetry.group.lab.dependencies]
4748
jupyterlab = "^4.0.10"

0 commit comments

Comments
 (0)