Closed nightlark closed 3 years ago
for shellcheck you're looking for https://github.com/shellcheck-py/shellcheck-py
for shfmt it should just work -- pre-commit and pre-commit.ci both have native support for go
Thanks, I got shfmt working as a local hook -- I think I had a syntax error the first time I tried, but 2nd try this worked:
- repo: local
hooks:
- id: shfmt
name: shfmt
language: golang
additional_dependencies: [mvdan.cc/sh/v3/cmd/shfmt@v3.3.0]
entry: shfmt -w
types: [shell]
that looks perfect! awesome!
one thing you can do to ~slightly optimize is write entry: shfmt
since args
doesn't really make too much sense for repo: local
when you can just inline it
Awesome, that's really convenient for getting any Go tools to run -- after splitting the clang-format docker hook out to run on its own from GitHub Actions I think this means all our other checks will be runnable on pre-commit.ci
awesome!
We have been using https://github.com/jumanjihouse/pre-commit-hooks running on GitHub Actions using
pre-commit/action
for theshellcheck
andshfmt
hooks. As part of seeing if pre-commit.ci could work we ran into an issue with both of those hooks failing becauseshellcheck
andshfmt
are not installed on the runner image (would be nice if they were added to the default image... but I guess that could get hard to manage).I noticed a previous issue mentioned https://github.com/shellcheck-py/shellcheck-py as an alternate option that can install a copy of
shellcheck
through pip, but I haven't found an equivalent forshfmt
(https://github.com/mvdan/sh) -- how would I go about creating a pre-commit.ci compatible hook? Is there a Go specific way of saying "build this" from source, or would I have to bundle it up into a PyPI package that can be pip installed?