forked from tetratelabs/proxy-wasm-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·95 lines (80 loc) · 3.32 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
goimports := golang.org/x/tools/cmd/[email protected]
golangci_lint := github.com/golangci/golangci-lint/cmd/[email protected]
.PHONY: build.example
build.example:
@find ./examples -type f -name "main.go" | grep ${name}\
| xargs -I {} bash -c 'dirname {}' \
| xargs -I {} bash -c 'cd {} && tinygo build -o main.wasm -scheduler=none -target=wasi ./main.go'
.PHONY: build.examples
build.examples:
@find ./examples -mindepth 1 -type f -name "main.go" \
| xargs -I {} bash -c 'dirname {}' \
| xargs -I {} bash -c 'cd {} && tinygo build -o main.wasm -scheduler=none -target=wasi ./main.go'
.PHONY: test
test:
@go test $(shell go list ./... | grep -v e2e)
@go test -tags "proxywasm_timing" ./proxywasm/proxytest
.PHONY: test.examples
test.examples:
@find ./examples -mindepth 1 -type f -name "main.go" \
| xargs -I {} bash -c 'dirname {}' \
| xargs -I {} bash -c 'cd {} && go test ./...'
.PHONY: test.e2e
test.e2e:
@go test -v ./e2e -count=1
.PHONY: test.e2e.single
test.e2e.single:
@go test -v ./e2e -run '/${name}' -count=1
.PHONY: run
run:
@envoy -c ./examples/${name}/envoy.yaml --concurrency 2 --log-format '%v'
.PHONY: lint
lint:
@go run $(golangci_lint) run
.PHONY: format
format:
@find . -type f -name '*.go' | xargs gofmt -s -w
@for f in `find . -name '*.go'`; do \
awk '/^import \($$/,/^\)$$/{if($$0=="")next}{print}' $$f > /tmp/fmt; \
mv /tmp/fmt $$f; \
done
@go run $(goimports) -w -local github.com/tetratelabs/proxy-wasm-go-sdk `find . -name '*.go'`
.PHONY: check
check:
@$(MAKE) format
@go mod tidy
@if [ ! -z "`git status -s`" ]; then \
echo "The following differences will fail CI until committed:"; \
git diff --exit-code; \
fi
# Build docker images of *compat* variant of Wasm Image Specification with built example binaries,
# and push to ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples.
# See https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md for details.
# Only-used in github workflow on the main branch, and not for developers.
.PHONY: wasm_image.build_push
wasm_image.build_push:
@for f in `find ./examples -type f -name "main.go"`; do \
name=`echo $$f | sed -e 's/\\//-/g' | sed -e 's/\.-examples-//g' -e 's/\-main\.go//g'` ; \
ref=ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples:$$name; \
docker build -t $$ref . -f examples/wasm-image.Dockerfile --build-arg WASM_BINARY_PATH=$$(dirname $$f)/main.wasm; \
docker push $$ref; \
done
# Build OCI images of *compat* variant of Wasm Image Specification with built example binaries,
# and push to ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples.
# See https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md for details.
# Only-used in github workflow on the main branch, and not for developers.
# Requires "buildah" CLI.
.PHONY: wasm_image.build_push_oci
wasm_image.build_push_oci:
@for f in `find ./examples -type f -name "main.go"`; do \
name=`echo $$f | sed -e 's/\\//-/g' | sed -e 's/\.-examples-//g' -e 's/\-main\.go//g'` ; \
ref=ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples:$$name-oci; \
buildah bud -f examples/wasm-image.Dockerfile --build-arg WASM_BINARY_PATH=$$(dirname $$f)/main.wasm -t $$ref .; \
buildah push $$ref; \
done
.PHONY: tidy
tidy: ## Runs go mod tidy on every module
@find . -name "go.mod" \
| grep go.mod \
| xargs -I {} bash -c 'dirname {}' \
| xargs -I {} bash -c 'echo "=> {}"; cd {}; go mod tidy -v; '