This repository has been archived by the owner on Mar 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathMakefile
93 lines (74 loc) · 2.05 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
SHELL := /bin/bash
TARGET := awslambdaproxy
VERSION := $(shell cat VERSION)
OS := linux
ARCH := amd64
PACKAGE := github.com/dan-v/$(TARGET)
.PHONY: \
clean \
tools \
test \
coverage \
vet \
lint \
fmt \
build \
lambda-build \
server-build-linux \
server-build-osx \
doc \
release \
docker-build \
docker-release \
all: tools fmt build lint vet test release
print-%:
@echo $* = $($*)
clean:
rm -Rf artifacts
rm -vf $(CURDIR)/coverage.*
tools:
go get golang.org/x/lint/golint
go get github.com/axw/gocov/gocov
go get github.com/matm/gocov-html
test:
go test -v ./...
coverage:
gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null
gocov report $(CURDIR)/coverage.out
if test -z "$$CI"; then \
gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \
if which open &>/dev/null; then \
open $(CURDIR)/coverage.html; \
fi; \
fi
vet:
go vet -v ./...
lint:
golint $(go list ./... | grep -v /vendor/)
fmt:
go fmt ./...
lambda-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o artifacts/lambda/main ./pkg/lambda
zip -jr artifacts/lambda artifacts/lambda
go-bindata -nocompress -pkg server -o pkg/server/bindata.go artifacts/lambda.zip
mv artifacts/lambda.zip artifacts/lambda-$(VERSION).zip
server-build-linux:
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags \
"-X $(PACKAGE)/cmd/awslambdaproxy.version=$(VERSION)" \
-v -o $(CURDIR)/artifacts/server/$(OS)/$(TARGET) ./cmd/main.go
server-build-osx:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags \
"-X $(PACKAGE)/cmd/awslambdaproxy.version=$(VERSION)" \
-v -o $(CURDIR)/artifacts/server/darwin/$(TARGET) ./cmd/main.go
build: lambda-build server-build-linux
build-osx: lambda-build server-build-osx
doc:
godoc -http=:8080 -index
release:
mkdir -p ./artifacts
zip -jr ./artifacts/$(TARGET)-$(OS)-$(VERSION).zip ./artifacts/server/$(OS)/$(TARGET)
docker:
docker build . -t vdan/awslambdaproxy:$(VERSION) -t vdan/awslambdaproxy:latest
docker-release:
docker push vdan/awslambdaproxy:$(VERSION)
docker push vdan/awslambdaproxy:latest