github.com/tetratelabs/proxy-wasm-go-sdk@v0.23.1-0.20240517021853-021aa9cf78e8/Makefile (about) 1 goimports := golang.org/x/tools/cmd/goimports@v0.7.0 2 golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 3 4 5 .PHONY: build.example 6 build.example: 7 @find ./examples -type f -name "main.go" | grep ${name}\ 8 | xargs -I {} bash -c 'dirname {}' \ 9 | xargs -I {} bash -c 'cd {} && tinygo build -o main.wasm -scheduler=none -target=wasi ./main.go' 10 11 12 .PHONY: build.examples 13 build.examples: 14 @find ./examples -mindepth 1 -type f -name "main.go" \ 15 | xargs -I {} bash -c 'dirname {}' \ 16 | xargs -I {} bash -c 'cd {} && tinygo build -o main.wasm -scheduler=none -target=wasi ./main.go' 17 18 .PHONY: test 19 test: 20 @go test $(shell go list ./... | grep -v e2e) 21 @go test -tags "proxywasm_timing" ./proxywasm/proxytest 22 23 .PHONY: test.examples 24 test.examples: 25 @find ./examples -mindepth 1 -type f -name "main.go" \ 26 | xargs -I {} bash -c 'dirname {}' \ 27 | xargs -I {} bash -c 'cd {} && go test ./...' 28 29 .PHONY: test.e2e 30 test.e2e: 31 @go test -v ./e2e -count=1 32 33 .PHONY: test.e2e.single 34 test.e2e.single: 35 @go test -v ./e2e -run '/${name}' -count=1 36 37 .PHONY: run 38 run: 39 @envoy -c ./examples/${name}/envoy.yaml --concurrency 2 --log-format '%v' 40 41 .PHONY: lint 42 lint: 43 @go run $(golangci_lint) run 44 45 .PHONY: format 46 format: 47 @find . -type f -name '*.go' | xargs gofmt -s -w 48 @for f in `find . -name '*.go'`; do \ 49 awk '/^import \($$/,/^\)$$/{if($$0=="")next}{print}' $$f > /tmp/fmt; \ 50 mv /tmp/fmt $$f; \ 51 done 52 @go run $(goimports) -w -local github.com/tetratelabs/proxy-wasm-go-sdk `find . -name '*.go'` 53 54 .PHONY: check 55 check: 56 @$(MAKE) format 57 @go mod tidy 58 @if [ ! -z "`git status -s`" ]; then \ 59 echo "The following differences will fail CI until committed:"; \ 60 git diff --exit-code; \ 61 fi 62 63 # Build docker images of *compat* variant of Wasm Image Specification with built example binaries, 64 # and push to ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples. 65 # See https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md for details. 66 # Only-used in github workflow on the main branch, and not for developers. 67 .PHONY: wasm_image.build_push 68 wasm_image.build_push: 69 @for f in `find ./examples -type f -name "main.go"`; do \ 70 name=`echo $$f | sed -e 's/\\//-/g' | sed -e 's/\.-examples-//g' -e 's/\-main\.go//g'` ; \ 71 ref=ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples:$$name; \ 72 docker build -t $$ref . -f examples/wasm-image.Dockerfile --build-arg WASM_BINARY_PATH=$$(dirname $$f)/main.wasm; \ 73 docker push $$ref; \ 74 done 75 76 # Build OCI images of *compat* variant of Wasm Image Specification with built example binaries, 77 # and push to ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples. 78 # See https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md for details. 79 # Only-used in github workflow on the main branch, and not for developers. 80 # Requires "buildah" CLI. 81 .PHONY: wasm_image.build_push_oci 82 wasm_image.build_push_oci: 83 @for f in `find ./examples -type f -name "main.go"`; do \ 84 name=`echo $$f | sed -e 's/\\//-/g' | sed -e 's/\.-examples-//g' -e 's/\-main\.go//g'` ; \ 85 ref=ghcr.io/tetratelabs/proxy-wasm-go-sdk-examples:$$name-oci; \ 86 buildah bud -f examples/wasm-image.Dockerfile --build-arg WASM_BINARY_PATH=$$(dirname $$f)/main.wasm -t $$ref .; \ 87 buildah push $$ref; \ 88 done 89 90 .PHONY: tidy 91 tidy: ## Runs go mod tidy on every module 92 @find . -name "go.mod" \ 93 | grep go.mod \ 94 | xargs -I {} bash -c 'dirname {}' \ 95 | xargs -I {} bash -c 'echo "=> {}"; cd {}; go mod tidy -v; '