-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from 12rambau/nox
build: add nox automatic tests
- Loading branch information
Showing
4 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""All the process that can be run using nox. | ||
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder. | ||
""" | ||
import tempfile | ||
from pathlib import Path | ||
|
||
import nox | ||
|
||
|
||
def install_poetry_groups(session: nox.Session, *groups: str) -> None: | ||
"""Install dependencies from poetry groups. | ||
Related to https://github.com/cjolowicz/nox-poetry/issues/663 | ||
""" | ||
with tempfile.NamedTemporaryFile() as requirements: | ||
session.run( | ||
"poetry", | ||
"export", | ||
*[f"--only={group}" for group in groups], | ||
"--format=requirements.txt", | ||
"--without-hashes", | ||
f"--output={requirements.name}", | ||
external=True, | ||
) | ||
print(Path(requirements.name).read_text()) | ||
session.install("-r", requirements.name) | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def lint(session): | ||
"""Apply the pre-commits.""" | ||
session.install("pre-commit") | ||
session.run("pre-commit", "run", "--a", *session.posargs) | ||
|
||
|
||
@nox.session(reuse_venv=True) | ||
def test(session): | ||
"""Run all the test using the environment varialbe of the running machine.""" | ||
session.install(".") | ||
install_poetry_groups(session, "test") | ||
test_files = session.posargs or ["tests"] | ||
session.run("pytest", "--color=yes", *test_files) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters