forked from knative/func
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (61 loc) · 2.49 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
REPO := quay.io/boson/faas
BIN := faas
DARWIN=$(BIN)_darwin_amd64
LINUX=$(BIN)_linux_amd64
WINDOWS=$(BIN)_windows_amd64.exe
CODE := $(shell find . -name '*.go')
DATE := $(shell date -u +"%Y%m%dT%H%M%SZ")
HASH := $(shell git rev-parse --short HEAD 2>/dev/null)
VTAG := $(shell git tag --points-at HEAD)
VERS := $(shell [ -z $(VTAG) ] && echo 'tip' || echo $(VTAG) )
build: all
all: $(BIN)
cross-platform: $(DARWIN) $(LINUX) $(WINDOWS)
darwin: $(DARWIN) ## Build for Darwin (macOS)
linux: $(LINUX) ## Build for Linux
windows: $(WINDOWS) ## Build for Windows
$(BIN): $(CODE) ## Build using environment defaults
env CGO_ENABLED=0 go build -ldflags "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" ./cmd/$(BIN)
$(DARWIN):
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $(DARWIN) -ldflags "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" ./cmd/$(BIN)
$(LINUX):
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(LINUX) -ldflags "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" ./cmd/$(BIN)
$(WINDOWS):
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $(WINDOWS) -ldflags "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" ./cmd/$(BIN)
test: test-binary test-node test-quarkus test-go
test-binary:
go test -race -cover -coverprofile=coverage.out ./...
test-node:
cd templates/node/events && npm install && npm test && rm -rf node_modules
cd templates/node/http && npm install && npm test && rm -rf node_modules
test-quarkus:
cd templates/quarkus/events && mvn test
cd templates/quarkus/http && mvn test
test-go:
cd templates/go/events && go test
cd templates/go/http && go test
image: Dockerfile
docker build -t $(REPO):latest \
-t $(REPO):$(VERS) \
-t $(REPO):$(HASH) \
-t $(REPO):$(DATE)-$(VERS)-$(HASH) .
push: image
docker push $(REPO):$(VERS)
docker push $(REPO):$(HASH)
docker push $(REPO):$(DATE)-$(VERS)-$(HASH)
latest:
# push the local 'latest' tag as the new public latest version
# (run by CI only for releases)
docker push $(REPO):latest
bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.27.0
check: bin/golangci-lint
./bin/golangci-lint run
release: build test
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
git-chglog --next-tag $(VTAG) -o CHANGELOG.md
git commit -am "release: $(VTAG)"
git tag $(VTAG)
clean:
rm -f $(BIN) $(WINDOWS) $(LINUX) $(DARWIN)
-rm -f coverage.out