support ruff mode Argument

Users can now specify the mode of ruff to be 'check' or 'format' using the mode input.
This commit is contained in:
Yoshihisa Mochihara
2024-03-12 23:34:49 +01:00
parent 42fd10b26e
commit 17a2e52c32
3 changed files with 27 additions and 4 deletions
+16 -1
View File
@@ -9,6 +9,7 @@ from subprocess import run
ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
ARGS = os.getenv("INPUT_ARGS", default="")
MODE = os.getenv("INPUT_MODE", default="")
SRC = os.getenv("INPUT_SRC", default="")
VERSION = os.getenv("INPUT_VERSION", default="")
@@ -21,6 +22,20 @@ if VERSION != "":
req = f"ruff{version_specifier}"
proc = run(["pipx", "run", req, *shlex.split(ARGS), *shlex.split(SRC)])
command = (
["pipx", "run", req, MODE, *shlex.split(ARGS), *shlex.split(SRC)]
if MODE == "check"
else [
"pipx",
"run",
req,
MODE,
"--check",
*shlex.split(ARGS),
*shlex.split(SRC),
]
)
proc = run(command)
sys.exit(proc.returncode)