forked from headlamp-k8s/headlamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
185 lines (150 loc) · 4.82 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
GO111MODULE=on
export GO111MODULE
SERVER_EXE_EXT ?=
DOCKER_CMD ?= docker
DOCKER_REPO ?= ghcr.io/headlamp-k8s
DOCKER_EXT_REPO ?= docker.io/headlamp
DOCKER_IMAGE_NAME ?= headlamp
DOCKER_PLUGINS_IMAGE_NAME ?= plugins
DOCKER_IMAGE_VERSION ?= $(shell git describe --tags --always --dirty)
DOCKER_PLATFORM ?= local
ifeq ($(OS), Windows_NT)
SERVER_EXE_EXT = .exe
endif
ifeq ($(OS), Windows_NT)
UNIXSHELL = false
ifdef BASH_VERSION
UNIXSHELL = true
endif
ifdef BASH_VERSION
UNIXSHELL = true
endif
else
UNIXSHELL = true
endif
all: backend frontend
tools/golangci-lint: backend/go.mod backend/go.sum
GOBIN=`pwd`/backend/tools go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54
backend-lint: tools/golangci-lint
cd backend && ./tools/golangci-lint run
frontend/build:
make frontend
.PHONY: app
app-build: frontend/build
cd app && npm install && node ./scripts/setup-plugins.js && npm run build
app: app-build
cd app && npm run package -- --win --linux --mac
app-win: app-build
cd app && npm run package -- --win
app-win-msi: app-build
cd app && npm run package-msi
app-linux: app-build
cd app && npm run package -- --linux
app-mac: app-build
cd app && npm run package -- --mac
.PHONY: backend
backend:
cd backend && go build -o ./headlamp-server${SERVER_EXE_EXT} ./cmd
.PHONY: backend-test
backend-test:
cd backend && go test -v -p 1 ./...
.PHONY: backend-coverage
backend-coverage:
cd backend && go test -v -p 1 -coverprofile=coverage.out ./...
cd backend && go tool cover -func=coverage.out
.PHONY: backend-coverage-html
backend-coverage-html:
cd backend && go test -v -p 1 -coverprofile=coverage.out ./...
cd backend && go tool cover -html=coverage.out
.PHONY: backend-format
backend-format:
cd backend && go fmt ./cmd/ ./pkg/**
frontend-install:
cd frontend && npm install
frontend-install-ci:
cd frontend && npm ci
.PHONY: frontend
frontend: frontend-install
cd frontend && npm run build
.PHONY: frontend-build
frontend-build:
cd frontend && npm run build
.PHONY: frontend-build-storybook
frontend-build-storybook:
cd frontend && npm run build-storybook
run-backend:
@echo "**** Warning: Running with Helm and dynamic-clusters endpoints enabled. ****"
ifeq ($(UNIXSHELL),true)
HEADLAMP_BACKEND_TOKEN=headlamp HEADLAMP_CONFIG_ENABLE_HELM=true HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true ./backend/headlamp-server -dev -proxy-urls https://artifacthub.io/* -enable-dynamic-clusters
else
@echo "**** Running on Windows without bash or zsh. ****"
@cmd /c "set HEADLAMP_BACKEND_TOKEN=headlamp&& set HEADLAMP_CONFIG_ENABLE_HELM=true&& set HEADLAMP_CONFIG_ENABLE_DYNAMIC_CLUSTERS=true&& backend\headlamp-server -dev -proxy-urls https://artifacthub.io/*" -enable-dynamic-clusters
endif
run-frontend:
ifeq ($(UNIXSHELL),true)
cd frontend && nice -16 npm start
else
cd frontend && npm start
endif
frontend-lint:
cd frontend && npm run lint -- --max-warnings 0 && npm run format-check
frontend-fixlint:
cd frontend && npm run lint -- --fix && npm run format
.PHONY: frontend-tsc
frontend-tsc:
cd frontend && npm run tsc
.PHONY: frontend-i18n-check
frontend-i18n-check:
@echo "Checking translations. If this fails use: 'npm run i18n'"
cd frontend && npm run i18n -- --fail-on-update
frontend-test:
cd frontend && npm run test -- --coverage
plugins-test:
cd plugins/headlamp-plugin && npm install && ./test-headlamp-plugin.js
cd plugins/headlamp-plugin && ./test-plugins-examples.sh
cd plugins/headlamp-plugin/plugin-management && node ./plugin-management.e2e.js
cd plugins/headlamp-plugin/plugin-management && npx jest ./plugin-management.test.js
# IMAGE_BASE can be used to specify a base final image.
# IMAGE_BASE=debian:latest make image
image:
@if [ -n "${IMAGE_BASE}" ]; then \
BUILD_ARG="--build-arg IMAGE_BASE=${IMAGE_BASE}"; \
else \
BUILD_ARG=""; \
fi; \
$(DOCKER_CMD) buildx build \
--pull \
--platform=$(DOCKER_PLATFORM) \
$$BUILD_ARG \
-t $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) -f \
Dockerfile \
.
.PHONY: build-plugins-container
build-plugins-container:
$(DOCKER_CMD) buildx build \
--pull \
--platform=linux/amd64 \
-t $(DOCKER_REPO)/$(DOCKER_PLUGINS_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) -f \
Dockerfile.plugins \
.
docker-ext:
$(eval LATEST_TAG=$(shell git tag --list --sort=version:refname 'v*' | tail -1 | sed 's/^.//'))
$(DOCKER_CMD) buildx build \
--platform=linux/amd64,linux/arm64 \
--push \
-t $(DOCKER_EXT_REPO)/$(DOCKER_IMAGE_NAME)-docker-extension:${LATEST_TAG} \
-t $(DOCKER_EXT_REPO)/$(DOCKER_IMAGE_NAME)-docker-extension:latest -f \
./docker-extension/Dockerfile \
./docker-extension
.PHONY: docs
docs:
cd frontend && npm install && npm run build-typedoc
.PHONY: storybook
storybook:
cd frontend && npm install && npm run storybook
i18n:
cd app && npm run i18n
cd frontend && npm run i18n
.PHONY: helm-template-test
helm-template-test:
charts/headlamp/tests/test.sh