ci: don't hardcode ~/.local/bin when running pre-commit

The pre-commit job failed with

    /root/.local/bin/pre-commit: No such file or directory

even though `pipx install pre-commit` succeeded: `pipx install` writes the
app to PIPX_BIN_DIR, and the runner image no longer uses ~/.local/bin for
it. Run the binary from PATH when pipx put it there, and fall back to
`pipx run pre-commit` otherwise, so the hook still runs regardless of
where pipx exposes its apps.
This commit is contained in:
weaselbot committed 2026-10-27 18:53:07 -04:00
1 parent 507be6f0a2
commit bce971fbd2
1 file changed
+9 -1
+9 -1
View File
@@ -12,7 +12,15 @@ jobs:
run: pipx install pre-commit run: pipx install pre-commit
- name: Run pre-commit - name: Run pre-commit
run: ~/.local/bin/pre-commit run --all-files --show-diff-on-failure # `pipx install` writes the app to PIPX_BIN_DIR, which is not
# necessarily ~/.local/bin and not necessarily on PATH, so don't
# hardcode a path that only some runner images happen to use.
run: |
if command -v pre-commit >/dev/null 2>&1; then
pre-commit run --all-files --show-diff-on-failure
else
pipx run pre-commit run --all-files --show-diff-on-failure
fi
build: build:
strategy: strategy: