-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
164 lines (131 loc) · 5.01 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Copyright 2014 Canonical Ltd.
# Makefile for the JIMM service.
export GO111MODULE=on
export DOCKER_BUILDKIT=1
PROJECT := github.com/canonical/jimm
GIT_COMMIT := $(shell git rev-parse --verify HEAD)
GIT_VERSION := $(shell git describe --abbrev=0 --dirty)
GO_VERSION := $(shell go list -f {{.GoVersion}} -m)
ARCH := $(shell dpkg --print-architecture)
default: build
build: version/commit.txt version/version.txt
go build -tags version $(PROJECT)/...
build/server: version/commit.txt version/version.txt
go build -tags version ./cmd/jimmsrv
lint:
golangci-lint run --timeout 5m
check: version/commit.txt version/version.txt lint
go test -timeout 30m $(PROJECT)/... -cover
clean:
go clean $(PROJECT)/...
-$(RM) version/commit.txt version/version.txt
-$(RM) jimmsrv
-$(RM) -r jimm-release/
-$(RM) jimm-*.tar.xz
certs:
@cd local/traefik/certs; ./certs.sh; cd -
test-env: sys-deps
@docker compose up --force-recreate -d --wait
test-env-cleanup:
@docker compose down -v --remove-orphans
dev-env-setup: sys-deps certs
@make version/commit.txt && make version/version.txt
dev-env: dev-env-setup
@docker compose --profile dev up -d --force-recreate --wait
dev-env-cleanup:
@docker compose --profile dev down -v --remove-orphans
qa-microk8s:
@./local/jimm/qa-microk8s.sh
qa-lxd:
@./local/jimm/qa-lxd.sh
integration-test-env: dev-env-setup
@JIMM_VERSION=$(JIMM_VERSION) docker compose --profile test up -d --force-recreate --wait
# Reformat all source files.
format:
gofmt -w -l .
# Reformat and simplify source files.
simplify:
gofmt -w -l -s .
# Generate version information
version/commit.txt:
git rev-parse --verify HEAD > version/commit.txt
version/version.txt:
if [ -z "$(GIT_VERSION)" ]; then \
echo "dev" > version/version.txt; \
else \
echo $(GIT_VERSION) > version/version.txt; \
fi
jimm-image:
docker build --target deploy-env \
--build-arg="GIT_COMMIT=$(GIT_COMMIT)" \
--build-arg="VERSION=$(GIT_VERSION)" \
--build-arg="GO_VERSION=$(GO_VERSION)" \
--build-arg="ARCH=$(ARCH)" \
--tag jimm:latest .
jimm-snap:
mkdir -p ./snap
cp ./snaps/jimm/snapcraft.yaml ./snap/
snapcraft
jimmctl-snap:
mkdir -p ./snap
cp -R ./snaps/jimmctl/* ./snap/
snapcraft
jaas-snap:
mkdir -p ./snap
cp -R ./snaps/jaas/* ./snap/
snapcraft
push-microk8s: jimm-image
docker tag jimm:latest localhost:32000/jimm:latest
docker push localhost:32000/jimm:latest
rock:
-rm *.rock
-ln -s ./rocks/jimm.yaml ./rockcraft.yaml
rockcraft pack
-rm ./rockcraft.yaml
load-rock:
$(eval jimm_version := $(shell cat ./rocks/jimm.yaml | yq ".version"))
@sudo /snap/rockcraft/current/bin/skopeo --insecure-policy copy oci-archive:jimm_${jimm_version}_amd64.rock docker-daemon:jimm:latest
define check_dep
if ! which $(1) > /dev/null; then\
echo "$(2)";\
else\
echo "Detected $(1)";\
fi
endef
# Install packages required to develop JIMM and/or run tests.
APT_BASED := $(shell command -v apt-get >/dev/null; echo $$?)
sys-deps:
ifeq ($(APT_BASED),0)
# golangci-lint is necessary for linting.
@$(call check_dep,golangci-lint,Missing Golangci-lint - install from https://golangci-lint.run/welcome/install/ or 'sudo snap install golangci-lint --classic')
# Go acts as the test runner.
@$(call check_dep,go,Missing Go - install from https://go.dev/doc/install or 'sudo snap install go --classic')
# Git is useful to have.
@$(call check_dep,git,Missing Git - install with 'sudo apt install git')
# GCC is required for the compilation process.
@$(call check_dep,gcc,Missing gcc - install with 'sudo apt install build-essential')
# yq is necessary for some scripts that process controller-info yaml files.
@$(call check_dep,yq,Missing yq - install with 'sudo snap install yq')
# Microk8s is required if you want to start a Juju controller on Microk8s.
@$(call check_dep,microk8s,Missing microk8s - install with 'sudo snap install microk8s --channel=1.30-strict/stable')
# Docker is required to start the test dependencies in containers.
@$(call check_dep,docker,Missing Docker - install from https://docs.docker.com/engine/install/ or 'sudo snap install docker')
# juju-db is required for tests that use Juju's test fixture, requiring MongoDB.
@$(call check_dep,juju-db.mongo,Missing juju-db - install with 'sudo snap install juju-db --channel=4.4/stable')
else
@echo sys-deps runs only on systems with apt-get
@echo on OS X with homebrew try: brew install bazaar mongodb
endif
help:
@echo -e 'JIMM - list of make targets:\n'
@echo 'make - Build the package.'
@echo 'make check - Run tests.'
@echo 'make install - Install the package.'
@echo 'make server - Start the JIMM server.'
@echo 'make clean - Remove object files from package source directories.'
@echo 'make sys-deps - Install the development environment system packages.'
@echo 'make format - Format the source files.'
@echo 'make simplify - Format and simplify the source files.'
@echo 'make rock - Build the JIMM rock.'
@echo 'make load-rock - Load the most recently built rock into your local docker daemon.'
.PHONY: build check install release clean format server simplify sys-deps help