Skip to content

Commit

Permalink
feat: consume new env variable to prevent running on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJFelix authored Sep 30, 2024
1 parent a834eb5 commit 7ff21a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
SRC = os.getenv("INPUT_SRC", default="")
VERSION = os.getenv("INPUT_VERSION", default="")
CHANGED_FILES = os.getenv("CHANGED_FILES", "")
IS_CHANGED_FILES_ENABLED = os.getenv("IS_CHANGED_FILES_ENABLED", default="false")

version_specifier = ""
if VERSION != "":
Expand All @@ -25,6 +26,11 @@
# If `CHANGED_FILES` is not empty, split it into a list; otherwise, use `SRC`.
files_to_check = shlex.split(CHANGED_FILES or SRC)

# If IS_CHANGED_FILES_ENABLED is true and CHANGED_FILES was empty, there were no files to check
# Short circuit to prevent ruff from running on all files because it got no file argument
if IS_CHANGED_FILES_ENABLED == "true" and not CHANGED_FILES:
sys.exit(0)

proc = run(["pipx", "run", req, *shlex.split(ARGS), *files_to_check])

sys.exit(proc.returncode)

0 comments on commit 7ff21a6

Please sign in to comment.