1
0

shell.mk 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. SH_SOURCES ?= $(shell find . -type f -name '*.sh' -not -path './tmp/*' -and -not -path './vendor/*')
  2. SHELL_BIN ?= $(SHELL)
  3. SHUNIT2_VERSION := 2.1.7
  4. CHECK_TOOLS += shellcheck shfmt
  5. test-shell: testtools dl-shunit2 ## Runs all shell code tests
  6. @echo "--- $@"
  7. for test in $(SH_TESTS); do \
  8. echo; echo "Running: $$test"; $(SHELL_BIN) $$test; done
  9. .PHONY: test-shell
  10. check-shell: shellcheck shfmt ## Checks linting & styling rules for shell code
  11. .PHONY: check-shell
  12. shellcheck: checktools ## Checks shell code for linting rules
  13. @echo "--- $@"
  14. shellcheck --external-sources $(SH_SOURCES)
  15. .PHONY: shellcheck
  16. shfmt: checktools ## Checks shell code for consistent formatting
  17. @echo "--- $@"
  18. shfmt -i 2 -ci -bn -d -l $(SH_SOURCES)
  19. .PHONY: shfmt
  20. clean-shell: ## Cleans up shell project
  21. rm -rf tmp
  22. .PHONY: clean-shell
  23. dl-shunit2: tmp/shunit2 ## Downloads shUnit2
  24. .PHOHY: dl-shunit2
  25. tmp/shunit2: tmp/shunit2-$(SHUNIT2_VERSION)
  26. @echo "--- $@"
  27. ln -snf ./shunit2-$(SHUNIT2_VERSION) tmp/shunit2
  28. tmp/shunit2-$(SHUNIT2_VERSION):
  29. @echo "--- $@"
  30. mkdir -p $@
  31. curl -sSfL https://github.com/kward/shunit2/archive/v$(SHUNIT2_VERSION).tar.gz \
  32. | tar xzf - -C tmp/