ci.mk 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright (c) 2015, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. .PHONY: ci ci-setup distclean-kerl
  4. KERL ?= $(CURDIR)/kerl
  5. export KERL
  6. KERL_URL ?= https://raw.githubusercontent.com/yrashk/kerl/master/kerl
  7. OTP_GIT ?= https://github.com/erlang/otp
  8. CI_INSTALL_DIR ?= $(HOME)/erlang
  9. CI_OTP ?=
  10. ifeq ($(strip $(CI_OTP)),)
  11. ci::
  12. else
  13. ci:: $(addprefix ci-,$(CI_OTP))
  14. ci-prepare: $(addprefix $(CI_INSTALL_DIR)/,$(CI_OTP))
  15. ci-setup::
  16. ci_verbose_0 = @echo " CI " $(1);
  17. ci_verbose = $(ci_verbose_$(V))
  18. define ci_target
  19. ci-$(1): $(CI_INSTALL_DIR)/$(1)
  20. $(verbose) $(MAKE) --no-print-directory clean;
  21. $(ci_verbose) \
  22. PATH="$(CI_INSTALL_DIR)/$(1)/bin:$(PATH)" \
  23. CI_OTP_RELEASE="$(1)" \
  24. CT_OPTS="-label $(1)" \
  25. $(MAKE) ci-setup tests
  26. endef
  27. $(foreach otp,$(CI_OTP),$(eval $(call ci_target,$(otp))))
  28. define ci_otp_target
  29. ifeq ($(wildcard $(CI_INSTALL_DIR)/$(1)),)
  30. $(CI_INSTALL_DIR)/$(1): $(KERL)
  31. $(KERL) build git $(OTP_GIT) $(1) $(1)
  32. $(KERL) install $(1) $(CI_INSTALL_DIR)/$(1)
  33. endif
  34. endef
  35. $(foreach otp,$(CI_OTP),$(eval $(call ci_otp_target,$(otp))))
  36. $(KERL):
  37. $(gen_verbose) $(call core_http_get,$(KERL),$(KERL_URL))
  38. $(verbose) chmod +x $(KERL)
  39. help::
  40. $(verbose) printf "%s\n" "" \
  41. "Continuous Integration targets:" \
  42. " ci Run '$(MAKE) tests' on all configured Erlang versions." \
  43. "" \
  44. "The CI_OTP variable must be defined with the Erlang versions" \
  45. "that must be tested. For example: CI_OTP = OTP-17.3.4 OTP-17.5.3"
  46. distclean:: distclean-kerl
  47. distclean-kerl:
  48. $(gen_verbose) rm -rf $(KERL)
  49. endif