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.
This commit is contained in:
		
							parent
							
								
									b2d25d4f4d
								
							
						
					
					
						commit
						6c7ba1be0f
					
				
							
								
								
									
										12
									
								
								README.md
								
								
								
								
							
							
						
						
									
										12
									
								
								README.md
								
								
								
								
							|  | @ -49,3 +49,15 @@ Cheat sheet: | ||||||
| - `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) | - `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) | ||||||
| - `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) | - `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) | ||||||
| - edit, `git commit`, `git subtree push --prefix=release-tools git@github.com:<user>/csi-release-tools.git <my-new-or-existing-branch>` - push to a new branch before submitting a PR | - edit, `git commit`, `git subtree push --prefix=release-tools git@github.com:<user>/csi-release-tools.git <my-new-or-existing-branch>` - push to a new branch before submitting a PR | ||||||
|  | 
 | ||||||
|  | verify-shellcheck.sh | ||||||
|  | -------------------- | ||||||
|  | 
 | ||||||
|  | The [verify-shellcheck.sh](./verify-shellcheck.sh) script in this repo | ||||||
|  | is a stripped down copy of the [corresponding | ||||||
|  | script](https://github.com/kubernetes/kubernetes/blob/release-1.14/hack/verify-shellcheck.sh) | ||||||
|  | in the Kubernetes repository. It can be used to check for certain | ||||||
|  | errors shell scripts, like missing quotation marks. The default | ||||||
|  | `test-shellcheck` target in [build.make](./build.make) only checks the | ||||||
|  | scripts in this directory. Components can add more directories to | ||||||
|  | `TEST_SHELLCHECK_DIRS` to check also other scripts. | ||||||
|  |  | ||||||
							
								
								
									
										15
									
								
								build.make
								
								
								
								
							
							
						
						
									
										15
									
								
								build.make
								
								
								
								
							|  | @ -122,3 +122,18 @@ test: test-subtree | ||||||
| test-subtree: | test-subtree: | ||||||
| 	@ echo; echo "### $@:" | 	@ echo; echo "### $@:" | ||||||
| 	./release-tools/verify-subtree.sh release-tools | 	./release-tools/verify-subtree.sh release-tools | ||||||
|  | 
 | ||||||
|  | # Components can extend the set of directories which must pass shellcheck. | ||||||
|  | # The default is to check only the release-tools directory itself. | ||||||
|  | TEST_SHELLCHECK_DIRS=release-tools | ||||||
|  | .PHONY: test-shellcheck | ||||||
|  | test: test-shellcheck | ||||||
|  | test-shellcheck: | ||||||
|  | 	@ echo; echo "### $@:" | ||||||
|  | 	@ ret=0; \ | ||||||
|  | 	for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \ | ||||||
|  | 		echo; \ | ||||||
|  | 		echo "$$dir:"; \ | ||||||
|  | 		./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \ | ||||||
|  | 	done; \ | ||||||
|  | 	return $$ret | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue