ci: don't hardcode ~/.local/bin when running pre-commit
CI / pre-commit (pull_request) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 59s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m44s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m50s
CI / pre-commit (pull_request) Successful in 54s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 59s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 52s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m44s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m50s
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:
1 parent
507be6f0a2
commit
bce971fbd2
1 file changed
+9
-1
@@ -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:
|
||||||
|
|||||||
Reference in new issue
Block a user