forked from meshery/meshery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
624 lines (531 loc) · 23.4 KB
/
Copy pathMakefile
File metadata and controls
624 lines (531 loc) · 23.4 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# Copyright Meshery Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include install/Makefile.core.mk
include install/Makefile.show-help.mk
#-----------------------------------------------------------------------------
# Install artifact generation
#-----------------------------------------------------------------------------
.PHONY: providers-propagate providers-check
## Propagate remote providers defined in install/providers.env to every generated install artifact.
providers-propagate:
python3 install/scripts/sync-provider-urls.py
## Verify that the install artifacts are in sync with the list of remote providers in install/providers.env.
providers-check:
python3 install/scripts/sync-provider-urls.py --check
#-----------------------------------------------------------------------------
# Docker-based Builds
#-----------------------------------------------------------------------------
.PHONY: docker-build docker-local-cloud docker-cloud docker-playground-build docker-testing-env-build docker-testing-env
## Build Meshery Server and UI container.
docker-build:
# `make docker-build` builds Meshery inside of a multi-stage Docker container.
# This method does NOT require that you have Go, NPM, etc. installed locally.
DOCKER_BUILDKIT=1 docker build -f install/docker/Dockerfile -t meshery/meshery --build-arg TOKEN=$(GLOBAL_TOKEN) --build-arg GIT_COMMITSHA=$(GIT_COMMITSHA) --build-arg GIT_VERSION=$(GIT_VERSION) --build-arg RELEASE_CHANNEL=${RELEASE_CHANNEL} .
## Build Meshery Server and UI container in Playground mode.
docker-playground-build:
# `make docker-playground-build` builds Meshery inside of a multi-stage Docker container.
# This method does NOT require that you have Go, NPM, etc. installed locally.
DOCKER_BUILDKIT=1 docker build -f install/docker/Dockerfile -t meshery/meshery --build-arg TOKEN=$(GLOBAL_TOKEN) --build-arg GIT_COMMITSHA=$(GIT_COMMITSHA) --build-arg GIT_VERSION=$(GIT_VERSION) --build-arg RELEASE_CHANNEL=${RELEASE_CHANNEL} --build-arg PROVIDER=$(LOCAL_PROVIDER) --build-arg PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) --build-arg PLAYGROUND=true .
## Build Meshery Server and UI container for e2e testing.
docker-testing-env-build:
# `make docker-build` builds Meshery inside of a multi-stage Docker container.
# This method does NOT require that you have Go, NPM, etc. installed locally.
DOCKER_BUILDKIT=1 docker build -f install/docker/testing/Dockerfile -t meshery/meshery-testing-env --build-arg GIT_VERSION=$(GIT_VERSION) .
## Meshery Cloud for user authentication.
## Runs Meshery in a container locally and points to locally-running
docker-local-cloud:
(docker rm -f meshery) || true
docker run --name meshery -d \
--link meshery-cloud:meshery-cloud \
-e PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_LOCAL) \
-e DEBUG=true \
-e ADAPTER_URLS=$(ADAPTER_URLS) \
-e KEYS_PATH=$(KEYS_PATH) \
-p 9081:8080 \
meshery/meshery ./meshery
## Runs Meshery in a container locally and points to remote
## Remote Provider for user authentication.
docker-cloud:
(docker rm -f meshery) || true
docker run --name meshery -d \
-e PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
-e DEBUG=true \
-e ADAPTER_URLS=$(ADAPTER_URLS) \
-e KEYS_PATH=$(KEYS_PATH) \
-v meshery-config:/home/appuser/.meshery/config \
-v $(HOME)/.kube:/home/appuser/.kube:ro \
-p 9081:8080 \
meshery/meshery ./meshery
## Runs Meshery in a container locally and points to remote
## Remote Provider for user authentication.
docker-testing-env:
docker run --rm --name mesherytesting -d \
-e PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
-e DEBUG=true \
-e ADAPTER_URLS=$(ADAPTER_URLS) \
-e KEYS_PATH=$(KEYS_PATH) \
-v meshery-config:/home/appuser/.meshery/config \
-v $(HOME)/.kube:/home/appuser/.kube:ro \
-p 9081:8080 \
meshery/meshery-testing-env ./meshery
#-----------------------------------------------------------------------------
# Meshery Server Native Builds
#-----------------------------------------------------------------------------
.PHONY: server server-local server-skip-compgen server-no-content golangci proto-build error build-server server-binary server-binary-local
run-local: server-local error
## Build and run Meshery Server on your local machine
## and point to (expect) a locally running Remote Provider
## for user authentication.
server-local: dep-check
cd server; cd cmd; go clean; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_LOCAL) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
OTEL_CONFIG=$(OTEL_CONFIG) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go
## Build Meshery Server on your local machine.
build-server: dep-check
cd server; cd cmd; go mod tidy; cd "../.."
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
GOPROXY=https://proxy.golang.org,direct GO111MODULE=on go build ./server/cmd/main.go ./server/cmd/error.go
chmod +x ./main
## Running the meshery server using binary.
server-binary:
cd server/cmd; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
../../main; cd ../../
## Running the meshery server using binary with local provider.
server-binary-local:
cd server/cmd; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_LOCAL) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
../../main; cd ../../
## Build and run Meshery Server on your local machine
## and point to Remote Provider in staging environment
server-stg: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_STAGING) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server on your local machine.
server: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=$(PORT) \
DEBUG=true \
USE_GO_POLICY_ENGINE=$(USE_GO_POLICY_ENGINE) \
OTEL_CONFIG=$(OTEL_CONFIG) \
PROVIDER_CAPABILITIES_FILEPATH=$(PROVIDER_CAPABILITIES_FILEPATH) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server with some Meshery Adapters on your local machine.
server-with-adapters: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server on your local machine.
## Disable deployment of the Meshery Operator to your Kubernetes cluster(s).
server-without-operator: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DISABLE_OPERATOR=true \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server with no Kubernetes components on your local machine.
server-skip-compgen:
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
SKIP_COMP_GEN=true \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server on your local machine.
## Do not generate and register Kubernetes models.
server-without-k8s: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
REGISTER_STATIC_K8S=false \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
server-remote-provider: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER=$(REMOTE_PROVIDER) \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
server-local-provider: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER=$(LOCAL_PROVIDER) \
PROVIDER_BASE_URLS=$(MESHERY_CLOUD_DEV) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Build and run Meshery Server with no seed content.
server-no-content:
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
SKIP_DOWNLOAD_CONTENT=true \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
server-playground: dep-check
cd server; cd cmd; go mod tidy; \
BUILD="$(GIT_VERSION)" \
PROVIDER=$(REMOTE_PROVIDER) \
PROVIDER_BASE_URLS=$(REMOTE_PROVIDER_URLS) \
PORT=9081 \
DEBUG=true \
ADAPTER_URLS=$(ADAPTER_URLS) \
APP_PATH=$(APPLICATIONCONFIGPATH) \
PLAYGROUND=true \
KEYS_PATH=$(KEYS_PATH) \
go run main.go error.go;
## Lint check Meshery Server.
golangci: error dep-check
golangci-lint run --config=.github/.golangci.yml --timeout=10m
## Build Meshery's protobufs.
proto-build:
# see https://developers.google.com/protocol-buffers/docs/reference/go-generated
# see https://grpc.io/docs/languages/go/quickstart/
export PATH=$(PATH):$(GOBIN)
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
protoc --proto_path=server/meshes --go_out=server/meshes --go_opt=paths=source_relative --go-grpc_out=server/meshes --go-grpc_opt=paths=source_relative meshops.proto
## Analyze error codes
error: dep-check
go run github.com/meshery/meshkit/cmd/errorutil -d . analyze -i ./server/helpers -o ./server/helpers --skip-dirs mesheryctl
## Runs meshkit error utility to update error codes for meshery server only.
error-util:
go run github.com/meshery/meshkit/cmd/errorutil -d . --skip-dirs mesheryctl update -i ./server/helpers/ -o ./server/helpers
## Build Meshery UI; Build and run Meshery Server on your local machine.
ui-server: ui-meshery-build ui-provider-build server
## Build Meshery UI, Server, and point to locally hosted Remote Provider
ui-server-local: ui-meshery-build ui-provider-build server-local
#-----------------------------------------------------------------------------
# Meshery UI Native Builds.
#-----------------------------------------------------------------------------
.PHONY: ui-setup ui ui-meshery-build ui-provider ui-lint ui-provider ui-meshery ui-build ui-provider-build ui-provider-test
## Install dependencies for building Meshery UI.
ui-setup: dep-check-node
cd ui; npm i; cd ..
cd provider-ui; npm i; cd ..
## Clean Install dependencies for building Meshery UI.
ui-setup-ci: dep-check-node
cd ui; npm ci; cd ..
## Run Meshery UI on your local machine. Listen for changes.
ui: dep-check-node
cd ui; npm run dev; cd ..;
## Run Meshery Provider UI on your local machine. Listen for changes.
ui-provider: dep-check-node
cd provider-ui; npm i; npm run dev; cd ..
## Lint check Meshery UI and Provider UI on your local machine.
ui-lint: dep-check-node
cd ui; npm i eslint; npx eslint . --fix; cd ..
## Lint check Meshery Provider UI on your local machine.
ui-provider-lint: dep-check-node
cd provider-ui && npm i eslint && npx eslint .
## Test Meshery Provider UI on your local machine.
ui-provider-test: dep-check-node
cd provider-ui; npm run test; cd ..
## Builds all Meshery UIs on your local machine.
ui-build: ui-setup wasm-engine
cd ui; npm run lint:fix || echo "Warning: Lint issues detected in ui but continuing build"; npm run build; cd ..
cd provider-ui; npm run lint:fix || echo "Warning: Lint issues detected in provider-ui but continuing build"; npm run build; cd ..
## Build only Meshery UI on your local machine.
ui-meshery-build: dep-check-node wasm-engine
cd ui; npm run build; cd ..
## Builds only the provider user interface on your local machine
ui-provider-build:
cd provider-ui; npm i; npm run build; cd ..
## Run Meshery End-to-End Integration Tests against your local Meshery UI (runs in non-interactive mode).
ui-integration-tests: ui-setup
cd ui; npm run ci-test-integration; cd ..
#-----------------------------------------------------------------------------
# Meshery Docs
#-----------------------------------------------------------------------------
#Incorporating Make docs commands from the Docs Makefile
.PHONY: docs docs-setup docs-build docs-build-production site docs-docker docs-mesheryctl check-go
## Alias target to run Meshery Docs in watch mode.
site: docs
## Alias target to run Meshery Docs once without file watching.
site-serve: docs-serve
## Install docs dependencies.
docs-setup:
cd docs; npm install
## Run Meshery Docs in watch mode.
docs:
@$(MAKE) -C docs site
## Run Meshery Docs once without file watching.
docs-serve:
@$(MAKE) -C docs serve
## Clean build cache and run Meshery Docs in watch mode.
docs-clean:
@$(MAKE) -C docs clean
## Build Meshery Docs on your local machine.
docs-build:
@$(MAKE) -C docs build
## Build Meshery Docs for production. BASE_URL is optional.
## Example: make docs-build-production BASE_URL=https://example.com
docs-build-production:
@$(MAKE) -C docs build-production BASE_URL="$(BASE_URL)"
## Run Meshery Docs in a Docker container. Listen for changes.
docs-docker:
cd docs; docker run --rm --name meshery-docs -p 1313:1313 -v `pwd`:/src -w /src ghcr.io/gohugoio/hugo:v0.163.3 server -D -F --bind 0.0.0.0
## Build Meshery CLI docs
docs-mesheryctl:
cd mesheryctl; make docs;
## Validate Go is installed.
check-go:
@echo "Checking if Go is installed..."
@command -v go > /dev/null || (echo "Go is not installed. Please install it before proceeding."; exit 1)
@echo "Go is installed."
#-----------------------------------------------------------------------------
# Meshery Helm Charts
#-----------------------------------------------------------------------------
.PHONY: helm-docs helm-operator-docs helm-meshery-docs helm-operator-lint helm-lint
## Generate all Meshery Helm Chart documentation in markdown format.
helm-docs: helm-operator-docs helm-meshery-docs
## Generate Meshery Operator Helm Chart documentation in markdown format.
helm-operator-docs: dep-check
GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
$(GOPATH)/bin/helm-docs -c install/kubernetes/helm/meshery-operator
## Generate Meshery Server and Adapters Helm Chart documentation in markdown format.
helm-meshery-docs: dep-check
GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
$(GOPATH)/bin/helm-docs -c install/kubernetes/helm/meshery
## Lint all of Meshery's Helm Charts
helm-lint: helm-operator-lint helm-meshery-lint
## Lint Meshery Operator Helm Chart
helm-operator-lint:
helm lint install/kubernetes/helm/meshery-operator --with-subcharts
## Lint Meshery Server and Adapter Helm Charts
helm-meshery-lint:
helm lint install/kubernetes/helm/meshery --with-subcharts
#-----------------------------------------------------------------------------
# Meshery APIs
#-----------------------------------------------------------------------------
.PHONY: graphql-build
## Build Meshery GraphQl API specifications
graphql-build: dep-check
cd server; cd internal/graphql; go run -mod=mod github.com/99designs/gqlgen generate
## testing
test-setup-ui:
cd ui; npx playwright install chromium --with-deps; cd ..
test-ui:
touch .env
@set -a; source .env; set +a; cd ui; npm run test:e2e ; cd ..
test-e2e-ci:
touch .env
@set -a; source .env; cd ui; set +a; npm run test:e2e:ci ; cd ..
#-----------------------------------------------------------------------------
# Rego Policies
#-----------------------------------------------------------------------------
.PHONY: policy-test policy-lint
## Format and lint Rego policy files
policy-lint:
@echo "Formatting Rego files..."
@opa fmt --write .
@echo "Linting Rego files..."
@regal lint --config-file ./server/policies/.regal/config.yaml ./models/meshery-core/0.7.2/v1.0.0/policies
## Run Rego policy unit tests using OPA and Go test runner
policy-test:
@echo "Running OPA Rego policy tests..."
@cd server/policies && go test -v ./...
## Build the Go relationship engine as a wasm binary for browser/extension use
.PHONY: wasm-engine
wasm-engine: dep-check-go
@echo "Building Go relationship engine wasm..."
@cd server/policies/wasm && \
go mod tidy && \
GOOS=js GOARCH=wasm go build -trimpath -ldflags="-s -w" -o policy_engine.wasm .
@cp -f "$$(go env GOROOT)/lib/wasm/wasm_exec.js" server/policies/wasm/wasm_exec.js
@echo "Patching wasm_exec.js to add process.env polyfill..."
@tmp=server/policies/wasm/wasm_exec.js.tmp && \
awk '{ \
print; \
if (index($$0, "chdir() { throw enosys(); },") > 0) { \
print "\t\t\tenv: {},"; \
found = 1; \
} \
} END { exit(found ? 0 : 1) }' server/policies/wasm/wasm_exec.js > "$$tmp" && \
mv "$$tmp" server/policies/wasm/wasm_exec.js || { \
rm -f "$$tmp"; \
echo "Failed to patch server/policies/wasm/wasm_exec.js"; \
exit 1; \
}
@mkdir -p ui/public/static/wasm
@cp -f server/policies/wasm/policy_engine.wasm ui/public/static/wasm/policy_engine.wasm
@cp -f server/policies/wasm/wasm_exec.js ui/public/static/wasm/wasm_exec.js
@if command -v wasm-opt >/dev/null 2>&1; then \
raw=$$(wc -c < server/policies/wasm/policy_engine.wasm); \
wasm-opt -Oz --enable-bulk-memory \
server/policies/wasm/policy_engine.wasm \
-o server/policies/wasm/policy_engine.wasm; \
opt=$$(wc -c < server/policies/wasm/policy_engine.wasm); \
gz=$$(gzip -9 -c server/policies/wasm/policy_engine.wasm | wc -c); \
printf "wasm-opt: %d -> %d bytes (gzip -9: %d)\n" $$raw $$opt $$gz; \
else \
echo "wasm-opt not found (brew install binaryen) — skipping size optimization"; \
fi
@echo "Wrote server/policies/wasm/{policy_engine.wasm,wasm_exec.js}"
@echo "Copied ui/public/static/wasm/{policy_engine.wasm,wasm_exec.js}"
#-----------------------------------------------------------------------------
# Testing - MeshSync Integration Tests (Go)
#-----------------------------------------------------------------------------
## Runs MeshSync integration tests check dependencies script (if docker, kind, kubectl, helm are present)
server-integration-tests-meshsync-check-dependencies:
./server/integration-tests/meshsync/infrastructure/setup.sh check_dependencies
server-integration-tests-meshsync-setup-cluster:
./server/integration-tests/meshsync/infrastructure/setup.sh setup_cluster
server-integration-tests-meshsync-setup-connection:
./server/integration-tests/meshsync/infrastructure/setup.sh setup_connection
## Runs MeshSync integration tests set up script (runs creates a test kind cluster, deploys operator to it)
## docker compose exposes nats on default ports to host, so they must be available
server-integration-tests-meshsync-setup: server-integration-tests-meshsync-setup-cluster server-integration-tests-meshsync-setup-connection
server-integration-tests-meshsync-cleanup-cluster:
./server/integration-tests/meshsync/infrastructure/setup.sh cleanup_cluster
server-integration-tests-meshsync-cleanup-connection:
./server/integration-tests/meshsync/infrastructure/setup.sh cleanup_connection
## Runs MeshSync integration tests clean up (stops docker compose and deletes test cluster)
server-integration-tests-meshsync-cleanup: server-integration-tests-meshsync-cleanup-connection server-integration-tests-meshsync-cleanup-cluster
## Runs MeshSync integration tests code itself
server-integration-tests-meshsync-run:
RUN_INTEGRATION_TESTS=true \
PATH_TO_SQL_FILE="../../../meshery-integration-test-meshsync-mesherydb.sql" \
go test -v -count=1 -run Integration ./server/integration-tests/meshsync
## Runs MeshSync integration tests full cycle (docker build, setup, run, cleanup)
server-integration-tests-meshsync: docker-build server-integration-tests-meshsync-setup server-integration-tests-meshsync-run server-integration-tests-meshsync-cleanup
#-----------------------------------------------------------------------------
# Testing - UI
#-----------------------------------------------------------------------------
.PHONY: ui-test-setup ui-test ui-test-e2e-full ui-test-e2e-local
## Install Playwright dependencies for UI tests
ui-test-setup: dep-check-node
cd ui; npx playwright install chromium --with-deps; cd ..
## Run Meshery UI End-to-End Tests
ui-test: dep-check-node
touch .env
@set -a; source .env; set +a; cd ui; npm run test:e2e ; cd ..
## Run Meshery UI End-to-End Tests in CI environment (Local and Remote Providers)
ui-test-e2e-full: dep-check-node
touch .env
@set -a; source .env; cd ui; set +a; npm run test:e2e:ci:full ; cd ..
## Run Meshery UI End-to-End Tests in CI environment (Local Provider)
ui-test-e2e-local: dep-check-node
touch .env
@set -a; source .env; cd ui; set +a; npm run test:e2e:ci:local ; cd ..
#-----------------------------------------------------------------------------
# Testing - Meshery CLI
#-----------------------------------------------------------------------------
.PHONY: mesheryctl-tests
### Run all Mesheryctl integration tests (Golang)
mesheryctl-tests-int:
cd mesheryctl && go test ./...
#-----------------------------------------------------------------------------
# Dependencies
#-----------------------------------------------------------------------------
.PHONY: dep-check dep-check-go dep-check-node
#.SILENT: dep-check
INSTALLED_GO_VERSION=$(shell go version)
NODE_PRIMARY_MAJOR=22
NODE_PRIMARY_MINOR=13
NODE_FALLBACK_MAJOR=24
REQUIRED_NODE_VERSION=^$(NODE_PRIMARY_MAJOR).$(NODE_PRIMARY_MINOR).0 || >=$(NODE_FALLBACK_MAJOR)
dep-check: dep-check-go
dep-check-go:
ifeq (,$(findstring $(GOVERSION), $(INSTALLED_GO_VERSION)))
# Only send a warning.
@echo "Dependency missing: go$(GOVERSION). Ensure 'go$(GOVERSION).x' is installed and available in your 'PATH'"
@echo "GOVERSION: " $(GOVERSION)
@echo "INSTALLED_GO_VERSION: " $(INSTALLED_GO_VERSION)
# Force error and stop.
# $(error Found $(INSTALLED_GO_VERSION). \
# Required golang version is: 'go$(GOVERSION).x'. \
# Ensure go '$(GOVERSION).x' is installed and available in your 'PATH'.)
endif
dep-check-node:
@node_version="$$(node --version 2>/dev/null || true)"; \
if [ -z "$$node_version" ]; then \
echo "Dependency missing: node. Ensure Node.js '$(REQUIRED_NODE_VERSION)' is installed and available in your 'PATH'"; \
exit 1; \
fi; \
node_version="$${node_version#v}"; \
node_major="$${node_version%%.*}"; \
node_minor="$${node_version#*.}"; \
node_minor="$${node_minor%%.*}"; \
if ! { [ "$$node_major" -eq "$(NODE_PRIMARY_MAJOR)" ] && [ "$$node_minor" -ge "$(NODE_PRIMARY_MINOR)" ]; } && [ "$$node_major" -lt "$(NODE_FALLBACK_MAJOR)" ]; then \
echo "Dependency mismatch: Found node v$$node_version. Required Node.js version is '$(REQUIRED_NODE_VERSION)'."; \
exit 1; \
fi