Skip to content

Commit 6c7ba1b

Browse files
committed
build.make: integrate shellcheck into "make test"
By default this only tests the scripts inside the "release-tools" directory, which is useful when making experimental changes to them in a component that uses csi-release-tools. But a component can also enable checking for other directories.
1 parent b2d25d4 commit 6c7ba1b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,15 @@ Cheat sheet:
4949
- `git subtree add --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - add release tools to a repo which does not have them yet (only once)
5050
- `git subtree pull --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - update local copy to latest upstream (whenever upstream changes)
5151
- edit, `git commit`, `git subtree push --prefix=release-tools [email protected]:<user>/csi-release-tools.git <my-new-or-existing-branch>` - push to a new branch before submitting a PR
52+
53+
verify-shellcheck.sh
54+
--------------------
55+
56+
The [verify-shellcheck.sh](./verify-shellcheck.sh) script in this repo
57+
is a stripped down copy of the [corresponding
58+
script](https://github.com/kubernetes/kubernetes/blob/release-1.14/hack/verify-shellcheck.sh)
59+
in the Kubernetes repository. It can be used to check for certain
60+
errors shell scripts, like missing quotation marks. The default
61+
`test-shellcheck` target in [build.make](./build.make) only checks the
62+
scripts in this directory. Components can add more directories to
63+
`TEST_SHELLCHECK_DIRS` to check also other scripts.

build.make

+15
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,18 @@ test: test-subtree
122122
test-subtree:
123123
@ echo; echo "### $@:"
124124
./release-tools/verify-subtree.sh release-tools
125+
126+
# Components can extend the set of directories which must pass shellcheck.
127+
# The default is to check only the release-tools directory itself.
128+
TEST_SHELLCHECK_DIRS=release-tools
129+
.PHONY: test-shellcheck
130+
test: test-shellcheck
131+
test-shellcheck:
132+
@ echo; echo "### $@:"
133+
@ ret=0; \
134+
for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \
135+
echo; \
136+
echo "$$dir:"; \
137+
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
138+
done; \
139+
return $$ret

0 commit comments

Comments
 (0)