-
Notifications
You must be signed in to change notification settings - Fork 14
/
makefile
94 lines (77 loc) · 2.75 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
VERSION := $(shell cat VERSION)
PKG:= kcl-lang.io/cli
LDFLAGS := -X $(PKG)/pkg/version.version=$(VERSION)
TAGS := rpc
COVER_FILE ?= coverage.out
SOURCE_PATHS ?= ./pkg/...
MAIN_FILE := ./cmd/kcl/main.go
GO ?= go
.PHONY: run
run:
go run $(MAIN_FILE) run ./examples/kubernetes.k
.PHONY: format
format:
test -z "$$(find . -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)" || \
test -z "$$(find . -type f -o -name '*.go' -exec gofmt -w {} + | tee /dev/stderr)"
.PHONY: lint
lint:
scripts/update-gofmt.sh
scripts/verify-gofmt.sh
scripts/verify-govet.sh
.PHONY: build
build: lint
mkdir -p bin/
go build -o bin/kcl -ldflags="$(LDFLAGS)" $(MAIN_FILE)
.PHONY: test
test:
go test -v ./...
.PHONY: e2e-test
e2e-test:
./examples/test.sh
go test -gcflags=all=-l -timeout=20m `go list ./cmd/...` -coverprofile $(COVER_FILE) ${TEST_FLAGS} -v
.PHONY: cover
cover: ## Generates coverage report
go test -gcflags=all=-l -timeout=20m `go list $(SOURCE_PATHS)` -coverprofile $(COVER_FILE) ${TEST_FLAGS} -v
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: bootstrap
bootstrap:
go mod download
command -v golint || GO111MODULE=off go get -u golang.org/x/lint/golint
.PHONY: docker-run-release
docker-run-release: export pkg=/go/src/github.com/kcl-lang/cli
docker-run-release:
git checkout main
git push
docker run -it --rm -e GITHUB_TOKEN -v $(shell pwd):$(pkg) -w $(pkg) golang:1.23 make bootstrap release
.PHONY: dist
dist: export COPYFILE_DISABLE=1 #teach OSX tar to not put ._* files in tar archive
dist: export CGO_ENABLED=0
dist:
rm -rf build/kcl/* release/*
mkdir -p build/kcl/bin release/
cp -f README.md LICENSE build/kcl
GOOS=linux GOARCH=amd64 $(GO) build -o build/kcl/bin/kcl -trimpath -ldflags="$(LDFLAGS)" -tags="$(TAGS)" $(MAIN_FILE)
tar -C build/ -zcvf $(CURDIR)/release/kcl-linux-amd64.tgz kcl/
GOOS=linux GOARCH=arm64 $(GO) build -o build/kcl/bin/kcl -trimpath -ldflags="$(LDFLAGS)" -tags="$(TAGS)" $(MAIN_FILE)
tar -C build/ -zcvf $(CURDIR)/release/kcl-linux-arm64.tgz kcl/
GOOS=darwin GOARCH=amd64 $(GO) build -o build/kcl/bin/kcl -trimpath -ldflags="$(LDFLAGS)" -tags="$(TAGS)" $(MAIN_FILE)
tar -C build/ -zcvf $(CURDIR)/release/kcl-macos-amd64.tgz kcl/
GOOS=darwin GOARCH=arm64 $(GO) build -o build/kcl/bin/kcl -trimpath -ldflags="$(LDFLAGS)" -tags="$(TAGS)" $(MAIN_FILE)
tar -C build/ -zcvf $(CURDIR)/release/kcl-macos-arm64.tgz kcl/
rm build/kcl/bin/kcl
GOOS=windows GOARCH=amd64 $(GO) build -o build/kcl/bin/kcl.exe -trimpath -ldflags="$(LDFLAGS)" -tags="$(TAGS)" $(MAIN_FILE)
tar -C build/ -zcvf $(CURDIR)/release/kcl-windows-amd64.tgz kcl/
.PHONY: release
release: lint dist
scripts/release.sh v$(VERSION)
.PHONY: tag
tag:
scripts/tag.sh v$(VERSION)
.PHONY: e2e
e2e: ## Run e2e test
scripts/e2e/e2e.sh
.PHONY: e2e-init
e2e-init:
scripts/e2e/e2e-init.sh $(TS)