Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ########################################################
  2. # Makefile for OpenShift: Atomic Quick Installer
  3. #
  4. # useful targets (not all implemented yet!):
  5. # make clean -- Clean up garbage
  6. # make ci ------------------- Execute CI steps (for travis or jenkins)
  7. ########################################################
  8. # > VARIABLE = value
  9. #
  10. # Normal setting of a variable - values within it are recursively
  11. # expanded when the variable is USED, not when it's declared.
  12. #
  13. # > VARIABLE := value
  14. #
  15. # Setting of a variable with simple expansion of the values inside -
  16. # values within it are expanded at DECLARATION time.
  17. ########################################################
  18. NAME := oo-install
  19. VENV := $(NAME)env
  20. TESTPACKAGE := oo-install
  21. SHORTNAME := ooinstall
  22. # This doesn't evaluate until it's called. The -D argument is the
  23. # directory of the target file ($@), kinda like `dirname`.
  24. ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $<
  25. MANPAGES := docs/man/man1/atomic-openshift-installer.1
  26. # slipped into the manpage template before a2x processing
  27. VERSION := 1.4
  28. # YAMLFILES: Skipping all '/files/' folders due to conflicting yaml file definitions
  29. YAMLFILES = $(shell find ../ -name $(VENV) -prune -o -name .tox -prune -o \( -name '*.yml' -o -name '*.yaml' \) ! -path "*/files/*" -print 2>&1)
  30. PYFILES = $(shell find ../ -name $(VENV) -prune -o -name ooinstall.egg-info -prune -o -name test -prune -o -name .tox -prune -o -name "*.py" -print)
  31. sdist: clean
  32. python setup.py sdist
  33. rm -fR $(SHORTNAME).egg-info
  34. clean:
  35. @find . -type f -regex ".*\.py[co]$$" -delete
  36. @find . -type f \( -name "*~" -or -name "#*" \) -delete
  37. @rm -fR build dist rpm-build MANIFEST htmlcov .coverage cover ooinstall.egg-info oo-install
  38. @rm -fR $(VENV)
  39. # To force a rebuild of the docs run 'touch' on any *.in file under
  40. # docs/man/man1/
  41. docs: $(MANPAGES)
  42. # Regenerate %.1.asciidoc if %.1.asciidoc.in has been modified more
  43. # recently than %.1.asciidoc.
  44. %.1.asciidoc: %.1.asciidoc.in
  45. sed "s/%VERSION%/$(VERSION)/" $< > $@
  46. # Regenerate %.1 if %.1.asciidoc or VERSION has been modified more
  47. # recently than %.1. (Implicitly runs the %.1.asciidoc recipe)
  48. %.1: %.1.asciidoc
  49. $(ASCII2MAN)
  50. viewcover:
  51. xdg-open cover/index.html
  52. # Conditional virtualenv building strategy taken from this great post
  53. # by Marcel Hellkamp:
  54. # http://blog.bottlepy.org/2012/07/16/virtualenv-and-makefiles.html
  55. $(VENV): $(VENV)/bin/activate
  56. $(VENV)/bin/activate: test-requirements.txt
  57. @echo "#############################################"
  58. @echo "# Creating a virtualenv"
  59. @echo "#############################################"
  60. test -d $(VENV) || virtualenv $(VENV)
  61. . $(VENV)/bin/activate && pip install setuptools==17.1.1
  62. . $(VENV)/bin/activate && pip install -r test-requirements.txt
  63. touch $(VENV)/bin/activate
  64. # If there are any special things to install do it here
  65. # . $(VENV)/bin/activate && INSTALL STUFF
  66. ci-unittests: $(VENV)
  67. @echo "#############################################"
  68. @echo "# Running Unit Tests in virtualenv"
  69. @echo "#############################################"
  70. . $(VENV)/bin/activate && tox -e py27-unit
  71. . $(VENV)/bin/activate && tox -e py35-unit
  72. @echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'"
  73. ci-pylint: $(VENV)
  74. @echo "#############################################"
  75. @echo "# Running PyLint Tests in virtualenv"
  76. @echo "#############################################"
  77. . $(VENV)/bin/activate && python -m pylint --rcfile ../git/.pylintrc $(PYFILES)
  78. ci-yamllint: $(VENV)
  79. @echo "#############################################"
  80. @echo "# Running yamllint Tests in virtualenv"
  81. @echo "#############################################"
  82. @. $(VENV)/bin/activate && yamllint -c ../git/.yamllint $(YAMLFILES)
  83. ci-list-deps: $(VENV)
  84. @echo "#############################################"
  85. @echo "# Listing all pip deps"
  86. @echo "#############################################"
  87. . $(VENV)/bin/activate && pip freeze
  88. ci-flake8: $(VENV)
  89. @echo "#############################################"
  90. @echo "# Running Flake8 Compliance Tests in virtualenv"
  91. @echo "#############################################"
  92. . $(VENV)/bin/activate && tox -e py27-flake8
  93. . $(VENV)/bin/activate && tox -e py35-flake8
  94. ci-tox:
  95. . $(VENV)/bin/activate && tox
  96. ci: ci-list-deps ci-tox ci-pylint ci-yamllint
  97. @echo
  98. @echo "##################################################################################"
  99. @echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'"
  100. @echo "To clean your test environment run 'make clean'"
  101. @echo "Other targets you may run with 'make': 'ci-pylint', 'ci-tox', 'ci-unittests', 'ci-flake8', 'ci-yamllint'"