mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-05-20 07:50:13 +02:00
initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"""GitHub Action for Ruff."""
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
|
||||
ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
|
||||
ARGS = os.getenv("INPUT_ARGS", default="")
|
||||
SRC = os.getenv("INPUT_SRC", default="")
|
||||
VERSION = os.getenv("INPUT_VERSION", default="")
|
||||
|
||||
version_specifier = ""
|
||||
if VERSION != "":
|
||||
if not re.match(r"v?\d\.\d{1,3}\.\d{1,3}$", VERSION):
|
||||
print("VERSION does not match expected pattern")
|
||||
sys.exit(1)
|
||||
version_specifier = f"=={VERSION}"
|
||||
|
||||
req = f"ruff{version_specifier}"
|
||||
|
||||
proc = run(["pipx", "run", req, *shlex.split(ARGS), *shlex.split(SRC)])
|
||||
|
||||
sys.exit(proc.returncode)
|
||||
Reference in New Issue
Block a user