This repository has been archived by the owner on Jun 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
121 lines (93 loc) · 3.5 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
NAME:=konfigadm
NETLIFY_ID:=822e0cb8-b16a-430f-a25c-bebeec0c33d0
ifeq ($(VERSION),)
VERSION=$(shell git describe --tags --long)$(shell date +"%H%M%S")
endif
all: test integration
.PHONY: clean
clean:
rm *.img *.vmx *.vmdk *.qcow2 *.ova || true
.PHONY: deps
deps:
command -v go2xunit 2>&1 > /dev/null || go get github.com/tebeka/go2xunit
command -v esc 2>&1 > /dev/null || go get -u github.com/mjibson/esc
.PHONY: linux
linux: pack
GOOS=linux GOARCH=386 go build -o ./.bin/$(NAME) -ldflags "-X \"main.version=$(VERSION)\"" main.go
.PHONY: darwin
darwin: pack
GOOS=darwin go build -o ./.bin/$(NAME)_osx -ldflags "-X \"main.version=$(VERSION)\"" main.go
.PHONY: windows
windows: pack
GOOS=windows go build -o ./.bin/$(NAME).exe -ldflags "-X \"main.version=$(VERSION)\"" main.go
.PHONY: compress
compress:
# upx 3.95 has issues compressing darwin binaries - https://github.com/upx/upx/issues/301
command -v upx 2>&1 > /dev/null || (sudo apt-get update && sudo apt-get install -y xz-utils && wget -nv -O upx.tar.xz https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz; tar xf upx.tar.xz; mv upx-3.96-amd64_linux/upx /usr/bin )
upx ./.bin/$(NAME) ./.bin/$(NAME)_osx ./.bin/$(NAME).exe
.PHONY: install
install:
go build -ldflags '-X main.version=$(VERSION)' -o konfigadm
mv konfigadm /usr/local/bin/konfigadm
.PHONY: test
test: deps pack
mkdir -p test-output
go test -v ./pkg/... ./cmd/... -race -coverprofile=coverage.txt -covermode=atomic | tee unit.out
cat unit.out | go2xunit --fail -output test-output/unit.xml
rm unit.out
.PHONY: integration
integration: linux
./scripts/e2e.sh $(test)
.PHONY: e2e
e2e: linux
./scripts/e2e.sh $(test)
.PHONY: e2e-all
e2e-all: deps linux debian ubuntu20 ubuntu18 ubuntu16 fedora centos
.PHONY: amazonlinux2
amazonlinux2: deps
IMAGE=quay.io/footloose/amazonlinux2:0.6.4 ./scripts/e2e.sh $(test)
.PHONY: debian9
debian9: deps
IMAGE=jrei/systemd-debian:9 ./scripts/e2e.sh $(test)
.PHONY: debian10
debian10: deps
IMAGE=quay.io/footloose/debian10:0.6.4 ./scripts/e2e.sh $(test)
.PHONY: ubuntu16
ubuntu16: deps
IMAGE=quay.io/footloose/ubuntu16.04:0.6.4 ./scripts/e2e.sh $(test)
.PHONY: ubuntu18
ubuntu18: deps
IMAGE=quay.io/footloose/ubuntu18.04:0.6.4 ./scripts/e2e.sh $(test)
.PHONY: ubuntu20
ubuntu20: deps
IMAGE=docker.io/flanksource/ubuntu:20.04 ./scripts/e2e.sh $(test)
.PHONY: fedora29
fedora29: deps
IMAGE=quay.io/footloose/fedora29:0.6.4 ./scripts/e2e.sh $(test)
.PHONY: photon3
photon3: deps
IMAGE=docker.io/tarun18/photon:3.0 ./scripts/e2e.sh $(test)
.PHONY: centos7
centos7: deps
IMAGE=quay.io/footloose/centos7:0.6.4 ./scripts/e2e.sh $(test)
.PHONY: centos8
centos8: deps
IMAGE=quay.io/footloose/centos8:latest ./scripts/e2e.sh $(test)
.PHONY: docs
docs:
command -v mkdocs 2>&1 > /dev/null || pip install mkdocs mkdocs-material
mkdocs build -d build/docs
.PHONY: deploy-docs
deploy-docs: docs
command -v netlify 2>&1 > /dev/null || sudo npm install -g netlify-cli
netlify deploy --site $(NETLIFY_ID) --prod --dir build/docs
.PHONY: pack
pack:
esc --prefix resources/ --ignore "static.go" -o resources/static.go --pkg resources resources
.PHONY: test-env
test-env:
docker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup -v $(PWD):$(PWD) -w $(PWD) --rm -it quay.io/footloose/debian10:0.6.4 /lib/systemd/systemd
.PHONY: lint
lint:
command -v golangci-lint 2>&1 > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
golangci-lint run --verbose --print-resources-usage