-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add nox tool support * Add integration test for nox --------- Co-authored-by: Sorin Sbarnea <[email protected]>
- Loading branch information
Showing
6 changed files
with
76 additions
and
2 deletions.
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
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,18 @@ | ||
build | ||
conda_tests-3.10 | ||
conda_tests-3.7 | ||
conda_tests-3.8 | ||
conda_tests-3.9 | ||
cover | ||
docs | ||
install | ||
lint | ||
lint2 | ||
test | ||
tests-3.10 | ||
tests-3.11 | ||
tests-3.12 | ||
tests-3.7 | ||
tests-3.8 | ||
tests-3.9 | ||
uninstall |
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,47 @@ | ||
""" | ||
Implementation of the nox tool support. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import json | ||
import logging | ||
from pathlib import Path | ||
|
||
from packaging.version import Version | ||
|
||
from mk.exec import run_or_fail | ||
from mk.tools import Action, Tool | ||
|
||
# This is the first version to support --json | ||
_MINIMUM_NOX_VERSION = Version("2023.04.22") | ||
|
||
|
||
class NoxTool(Tool): | ||
name = "nox" | ||
|
||
def is_present(self, path: Path) -> bool: | ||
return (path / "noxfile.py").is_file() | ||
|
||
def actions(self) -> list[Action]: | ||
actions: list[Action] = [] | ||
version: str = run_or_fail(["nox", "--version"], tee=False).stderr.strip() | ||
if Version(version) < _MINIMUM_NOX_VERSION: | ||
logging.warning( | ||
"Failed to retrieve nox sessions: " | ||
"nox version %s is too old. Minimum supported version is %s.", | ||
version, | ||
_MINIMUM_NOX_VERSION, | ||
) | ||
return [] | ||
results = run_or_fail(["nox", "--list", "--json"], tee=False) | ||
data = json.loads(results.stdout) | ||
actions = [ | ||
Action(session["session"], tool=self, description=session["description"]) | ||
for session in data | ||
] | ||
return actions | ||
|
||
def run(self, action: Action | None = None) -> None: | ||
cmd = ["nox"] if not action else ["nox", "-s", action.name] | ||
run_or_fail(cmd, tee=True) |
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