A declarative host provisioning system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Copyright 2017 AT&T Intellectual Property. All other rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. BUILD_DIR := $(shell mkdir -p build && mktemp -d -p build)
  15. DOCKER_REGISTRY ?= quay.io
  16. IMAGE_NAME ?= drydock
  17. IMAGE_PREFIX ?= airshipit
  18. IMAGE_TAG ?= dev
  19. HELM := $(shell realpath $(BUILD_DIR))/helm
  20. UBUNTU_BASE_IMAGE ?=
  21. PROXY ?= http://proxy.foo.com:8000
  22. NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
  23. USE_PROXY ?= false
  24. PUSH_IMAGE ?= false
  25. # use this variable for image labels added in internal build process
  26. LABEL ?= org.airshipit.build=community
  27. COMMIT ?= $(shell git rev-parse HEAD)
  28. IMAGE ?= ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
  29. GO_BUILDER ?= docker.io/golang:1.10-stretch
  30. export
  31. # Build all docker images for this project
  32. .PHONY: images
  33. images: build_drydock
  34. # Run an image locally and exercise simple tests
  35. .PHONY: run_images
  36. run_images: run_drydock
  37. # Run tests
  38. .PHONY: tests
  39. tests: pep8 security docs unit_tests test_baclient
  40. # Install external (not managed by tox/pip) dependencies
  41. external_dep: requirements-host.txt requirements-host-test.txt
  42. sudo ./hostdeps.sh
  43. touch external_dep
  44. # Run unit and Postgres integration tests in coverage mode
  45. .PHONY: coverage_test
  46. coverage_test: build_drydock
  47. tox -re cover
  48. # Run just unit tests
  49. .PHONY: unit_tests
  50. unit_tests: external_dep
  51. tox -re py35 $(TESTS)
  52. # Run just DB integration tests
  53. .PHONY: db_integration_tests
  54. db_integration_tests: external_dep
  55. tox -re integration $(TESTS)
  56. # Freeze full set of Python requirements
  57. .PHONY: req_freeze
  58. req_freeze:
  59. tox -re freeze
  60. # Run the drydock container and exercise simple tests
  61. .PHONY: run_drydock
  62. run_drydock: build_drydock
  63. tools/drydock_image_run.sh
  64. # It seems CICD expects the target 'drydock' to
  65. # build the chart
  66. .PHONY: drydock
  67. drydock: charts
  68. # Create tgz of the chart
  69. .PHONY: charts
  70. charts: helm-init
  71. $(HELM) dep up charts/drydock
  72. $(HELM) package charts/drydock
  73. # Perform Linting
  74. .PHONY: lint
  75. lint: pep8 helm_lint
  76. # Dry run templating of chart
  77. .PHONY: dry-run
  78. dry-run: helm-init
  79. $(HELM) template --set manifests.secret_ssh_key=true --set conf.ssh.private_key=foo charts/drydock
  80. # Initialize local helm config
  81. .PHONY: helm-init
  82. helm-init: helm-install
  83. tools/helm_tk.sh $(HELM)
  84. # Install helm binary
  85. .PHONY: helm-install
  86. helm-install:
  87. tools/helm_install.sh $(HELM)
  88. # Make targets intended for use by the primary targets above.
  89. .PHONY: build_drydock
  90. build_drydock: external_dep build_baclient
  91. export; tools/drydock_image_build.sh
  92. ifeq ($(PUSH_IMAGE), true)
  93. docker push $(IMAGE)
  94. endif
  95. # Make target for building bootaction signal client
  96. .PHONY: build_baclient
  97. build_baclient: external_dep
  98. docker run -tv $(shell realpath go):/work -v $(shell realpath $(BUILD_DIR)):/build -e GOPATH=/work $(GO_BUILDER) go build -o /build/baclient baclient
  99. # Make target for testing bootaction signal client
  100. .PHONY: test_baclient
  101. test_baclient: external_dep
  102. docker run -tv $(shell realpath go):/work -e GOPATH=/work $(GO_BUILDER) go test -v baclient
  103. .PHONY: docs
  104. docs: clean drydock_docs
  105. .PHONY: security
  106. security: external_dep
  107. tox -e bandit
  108. .PHONY: drydock_docs
  109. drydock_docs: external_dep render_diagrams genpolicy genconfig
  110. tox -e docs
  111. .PHONY: render_diagrams
  112. render_diagrams:
  113. plantuml -v -tpng -o ../source/images docs/diagrams/*.uml
  114. .PHONY: genpolicy
  115. genpolicy:
  116. tox -e genpolicy
  117. .PHONY: genconfig
  118. genconfig:
  119. tox -e genconfig
  120. .PHONY: clean
  121. clean:
  122. rm -rf build
  123. rm -rf docs/build
  124. rm -rf charts/drydock/charts
  125. rm -rf charts/drydock/requirements.lock
  126. .PHONY: pep8
  127. pep8: external_dep
  128. tox -e pep8
  129. .PHONY: helm_lint
  130. helm_lint: helm-init
  131. $(HELM) lint charts/drydock