-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (56 loc) · 2.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Use one shell for all commands in a target recipe
.ONESHELL:
# Set default goal
.DEFAULT_GOAL := help
# Use bash shell in Make instead of sh
SHELL := /bin/bash
# Charm variables
CHARM_NAME := megaraid-check
CHARM_STORE_URL := cs:~huntdatacenter/megaraid-check
CHARM_HOMEPAGE := https://github.com/huntdatacenter/charm-megaraid-check/
CHARM_BUGS_URL := https://github.com/huntdatacenter/charm-megaraid-check/issues
CHARM_BUILD_DIR := /tmp/charm-builds
CHARM_PATH := $(CHARM_BUILD_DIR)/$(CHARM_NAME)
lint: ## Run linter
tox -e lint
build: ## Build charm
tox -e build
deploy: ## Deploy charm
juju deploy $(CHARM_BUILD_DIR)/$(CHARM_NAME)
upgrade: ## Upgrade charm
juju upgrade-charm $(CHARM_NAME) --path $(CHARM_BUILD_DIR)/$(CHARM_NAME)
force-upgrade: ## Force upgrade charm
juju upgrade-charm $(CHARM_NAME) --path $(CHARM_BUILD_DIR)/$(CHARM_NAME) --force-units
test-xenial-bundle: ## Test Xenial bundle
tox -e test-xenial
test-bionic-bundle: ## Test Bionic bundle
tox -e test-bionic
push: clean build generate-repo-info ## Push charm to stable channel
@echo "Publishing $(CHARM_STORE_URL)"
@export rev=$$(charm push $(CHARM_PATH) $(CHARM_STORE_URL) 2>&1 \
| tee /dev/tty | grep url: | cut -f 2 -d ' ') \
&& charm release --channel stable $$rev \
&& charm grant $$rev --acl read everyone \
&& charm set $$rev extra-info=$$(git rev-parse --short HEAD) \
bugs-url=$(CHARM_BUGS_URL) homepage=$(CHARM_HOMEPAGE)
clean: ## Clean .tox and build
@echo "Cleaning files"
@if [ -d $(CHARM_PATH) ] ; then rm -r $(CHARM_PATH) ; fi
@if [ -d .tox ] ; then rm -r .tox ; fi
# Internal targets
clean-repo:
@if [ -n "$$(git status --porcelain)" ]; then \
echo '!!! Hard resetting repo and removing untracked files !!!'; \
git reset --hard; \
git clean -fdx; \
fi
generate-repo-info:
@if [ -f $(CHARM_PATH)/repo-info ] ; then rm -r $(CHARM_PATH)/repo-info ; fi
@echo "commit: $$(git rev-parse HEAD)" >> $(CHARM_PATH)/repo-info
@echo "commit-short: $$(git rev-parse --short HEAD)" >> $(CHARM_PATH)/repo-info
@echo "branch: $$(git rev-parse --abbrev-ref HEAD)" >> $(CHARM_PATH)/repo-info
@echo "remote: $$(git config --get remote.origin.url)" >> $(CHARM_PATH)/repo-info
@echo "generated: $$(date -u)" >> $(CHARM_PATH)/repo-info
# Display target comments in 'make help'
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)