Skip to content

Commit 5f3fa5c

Browse files
committed
Add shfmt and shellcheck
1 parent e7e4b51 commit 5f3fa5c

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ all: fmt lint test
22

33
.SILENT:
44

5-
.PHONY: *
6-
7-
.ONESHELL:
8-
SHELL = bash
9-
.SHELLFLAGS = -ceuo pipefail
10-
115
include ci/fmt.mk
126
include ci/lint.mk
137
include ci/test.mk

ci/ensure_fmt.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
main() {
6+
local files
7+
mapfile -t files < <(git ls-files --other --modified --exclude-standard)
8+
if [[ ${files[*]} == "" ]]; then
9+
return
10+
fi
11+
12+
echo "Files need generation or are formatted incorrectly:"
13+
for f in "${files[@]}"; do
14+
echo " $f"
15+
done
16+
17+
echo
18+
echo "Please run the following locally:"
19+
echo " make fmt"
20+
exit 1
21+
}
22+
23+
main "$@"

ci/fmt.mk

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
fmt: modtidy gofmt goimports prettier
1+
fmt: modtidy gofmt goimports prettier shfmt
22
ifdef CI
3-
if [[ $$(git ls-files --other --modified --exclude-standard) != "" ]]; then
4-
echo "Files need generation or are formatted incorrectly:"
5-
git -c color.ui=always status | grep --color=no '\e\[31m'
6-
echo "Please run the following locally:"
7-
echo " make fmt"
8-
exit 1
9-
fi
3+
./ci/ensure_fmt.sh
104
endif
115

126
modtidy: gen
@@ -23,3 +17,6 @@ prettier:
2317

2418
gen:
2519
stringer -type=opcode,MessageType,StatusCode -output=stringer.go
20+
21+
shfmt:
22+
shfmt -i 2 -w -s -sr $$(git ls-files "*.sh")

ci/image/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
FROM golang:1
22

33
RUN apt-get update
4-
RUN apt-get install -y chromium npm
4+
RUN apt-get install -y chromium npm shellcheck
5+
6+
ARG SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_amd64
7+
RUN curl -L $SHFMT_URL > /usr/local/bin/shfmt && chmod +x /usr/local/bin/shfmt
58

69
ENV GOFLAGS="-mod=readonly"
7-
ENV PAGER=cat
810
ENV CI=true
911
ENV MAKEFLAGS="--jobs=16 --output-sync=target"
1012

ci/lint.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lint: govet golint
1+
lint: govet golint govet-wasm golint-wasm shellcheck
22

33
govet:
44
go vet ./...
@@ -11,3 +11,6 @@ golint:
1111

1212
golint-wasm:
1313
GOOS=js GOARCH=wasm golint -set_exit_status ./...
14+
15+
shellcheck:
16+
shellcheck $$(git ls-files "*.sh")

0 commit comments

Comments
 (0)