-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (47 loc) · 1.81 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
# Copyright The Linux Foundation and each contributor to CommunityBridge.
# SPDX-License-Identifier: MIT
SERVICE = ledger
BUILD_TIME=`date +%FT%T%z`
VERSION := $(shell sh -c 'git describe --always --tags')
BRANCH := $(shell sh -c 'git rev-parse --abbrev-ref HEAD')
COMMIT := $(shell sh -c 'git rev-parse --short HEAD')
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.branch=$(BRANCH) -X main.buildDate=$(BUILD_TIME)"
BUILD_TAGS=-tags aws_lambda
LINT_TOOL=$(shell go env GOPATH)/bin/golangci-lint
GO_PKGS=$(shell go list ./... | grep -v /vendor/ | grep -v /node_modules/)
GO_FILES=$(shell find . -type f -name '*.go' -not -path './vendor/*')
setup_dev:
go get -u github.com/go-swagger/go-swagger/cmd/swagger
go get -u github.com/golang/dep/cmd/dep
sudo curl -fsSL -o /usr/local/bin/dbmate https://github.com/amacneil/dbmate/releases/download/v1.7.0/dbmate-linux-amd64
sudo chmod +x /usr/local/bin/dbmate
setup_deploy:
yarn install --frozen-lockfile
setup: setup_dev setup_deploy
clean:
rm -rf ./gen ./bin
validate:
swagger validate swagger/$(SERVICE).yaml
swagger: clean
mkdir gen
swagger -q generate server -t gen -f swagger/$(SERVICE).yaml --exclude-main -A $(SERVICE) --keep-spec-order
up:
dbmate up
test: up
go test -p 1 -race -cover ./...
run:
go run main.go
deps:
dep ensure -v
build: swagger deps lint
env GOOS=linux GOARCH=amd64 go build -tags aws_lambda -o bin/$(SERVICE) -a $(LDFLAGS) .
chmod +x bin/$(SERVICE)
$(LINT_TOOL):
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.19.0
qc: $(LINT_TOOL)
$(LINT_TOOL) run --config=.golangci.yaml ./...
lint: qc
rebuild: swagger qc build run
.PHONY: setup clean qc swagger up build test run setup_deploy setup_dev
deploy: clean build
sls deploy --verbose