Add shfmt to the validate make target
We need to run on a directory since shell files might have no extension. There are few shell files, so speed should not be an issue. Fixes #1166.
This commit is contained in:
parent
cdb66f5421
commit
b9d13467b9
|
@ -36,6 +36,15 @@ RUN mkdir -p /usr/src/criu \
|
|||
&& cd /usr/src/criu \
|
||||
&& make install-criu
|
||||
|
||||
# install shfmt
|
||||
RUN mkdir -p /go/src/github.com/mvdan \
|
||||
&& cd /go/src/github.com/mvdan \
|
||||
&& git clone https://github.com/mvdan/sh \
|
||||
&& cd sh \
|
||||
&& git checkout -f v0.4.0 \
|
||||
&& go install ./cmd/shfmt \
|
||||
&& rm -rf /go/src/github.com/mvdan
|
||||
|
||||
# setup a playground for us to spawn containers in
|
||||
ENV ROOTFS /busybox
|
||||
RUN mkdir -p ${ROOTFS} \
|
||||
|
|
1
Makefile
1
Makefile
|
@ -119,6 +119,7 @@ clean:
|
|||
|
||||
validate:
|
||||
script/validate-gofmt
|
||||
script/validate-shfmt
|
||||
go vet ./...
|
||||
|
||||
ci: validate localtest
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
badFiles=()
|
||||
while read f; do
|
||||
badFiles+=("$f")
|
||||
done < <(shfmt -l . | grep -v Godeps/)
|
||||
|
||||
if [ ${#badFiles[@]} -eq 0 ]; then
|
||||
echo 'Congratulations! All shell source files are properly formatted.'
|
||||
else
|
||||
{
|
||||
echo "These files are not properly shfmt'd:"
|
||||
for f in "${badFiles[@]}"; do
|
||||
echo " - $f"
|
||||
done
|
||||
echo
|
||||
echo 'Please reformat the above files using "shfmt -w" and commit the result.'
|
||||
echo
|
||||
} >&2
|
||||
false
|
||||
fi
|
Loading…
Reference in New Issue