-
-
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.
- split tools into submodules - use pluggy to register them as plugins
- Loading branch information
Showing
9 changed files
with
92 additions
and
67 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
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,5 @@ | ||
from mk.tools import Tool | ||
|
||
|
||
class MakeTool(Tool): | ||
name = "make" |
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,5 @@ | ||
from mk.tools import Tool | ||
|
||
|
||
class NpmTool(Tool): | ||
name = "npm" |
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,20 @@ | ||
import os | ||
import subprocess | ||
from typing import List, Optional | ||
|
||
from mk.tools import Action, Tool | ||
|
||
|
||
class PreCommitTool(Tool): | ||
name = "pre-commit" | ||
|
||
def run(self, action: Optional[str] = None): | ||
subprocess.run(["pre-commit", "run", "-a"], check=True) | ||
|
||
def is_present(self, path: str) -> bool: | ||
if os.path.isfile(os.path.join(path, ".pre-commit-config.yaml")): | ||
return True | ||
return False | ||
|
||
def actions(self) -> List[Action]: | ||
return [Action(name="lint", tool=self)] |
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,44 @@ | ||
import os | ||
import subprocess | ||
from configparser import ConfigParser | ||
from typing import List, Optional | ||
|
||
from mk.tools import Action, Tool | ||
|
||
|
||
class ToxTool(Tool): | ||
name = "tox" | ||
|
||
def is_present(self, path: str) -> bool: | ||
if os.path.isfile(os.path.join(path, "tox.ini")): | ||
return True | ||
return False | ||
|
||
def actions(self) -> List[Action]: | ||
# -a is not supported by tox4! | ||
actions: List[Action] = [] | ||
cp = ConfigParser() | ||
tox_cfg = subprocess.check_output(["tox", "--showconfig"], universal_newlines=True) | ||
cp.read_string(tox_cfg) | ||
for section in cp.sections(): | ||
if section.startswith("testenv:"): | ||
_, env_name = section.split(":") | ||
# we ignore hidden envs like implicit .pkg: | ||
if not env_name.startswith("."): | ||
actions.append( | ||
Action( | ||
name=env_name, | ||
tool=self, | ||
description=cp[section]["description"], | ||
args=[env_name], | ||
) | ||
) | ||
|
||
return actions | ||
|
||
def run(self, action: Optional[str] = None) -> None: | ||
if not action: | ||
cmd = ["tox"] | ||
else: | ||
cmd = ["tox", "-e", action] | ||
subprocess.run(cmd, check=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