-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
101 lines (76 loc) · 2.18 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
95
96
97
98
99
100
101
# Package configuration
PROJECT = code-annotation
COMMANDS = cli/server
DEPENDENCIES = \
github.com/golang/dep/cmd/dep \
github.com/jteeuwen/go-bindata \
golang.org/x/lint/golint
GO_LINTABLE_PACKAGES = $(shell go list ./... | grep -v '/vendor/')
YARN_PRODUCTION ?= true
# Tools
YARN = yarn
GODEP = dep
GOLINT = golint
GOVET = go vet
BINDATA = go-bindata
# ci variables
TRAVIS_BUILD_DIR ?= $(shell pwd)
PKG_OS = linux
DOCKER_OS = linux
DOCKER_ARCH = amd64
# Including ci Makefile
CI_REPOSITORY ?= https://github.com/src-d/ci.git
CI_BRANCH ?= v1
CI_PATH ?= $(shell pwd)/.ci
MAKEFILE := $(CI_PATH)/Makefile.main
$(MAKEFILE):
@git clone --quiet --depth 1 -b $(CI_BRANCH) $(CI_REPOSITORY) $(CI_PATH);
-include $(MAKEFILE)
# Set enviroment variables from .env file
DOT_ENV ?= .env
-include $(DOT_ENV)
export $(shell [ -f "$(DOT_ENV)" ] && sed 's/=.*//' $(DOT_ENV))
# Frontend
dependencies-frontend-development:
$(MAKE) dependencies-frontend YARN_PRODUCTION=false
dependencies-frontend:
$(YARN) install --production=$(YARN_PRODUCTION)
test-frontend: dependencies-frontend-development
$(YARN) test
lint-frontend: dependencies-frontend-development
$(YARN) lint
build-frontend: dependencies-frontend
$(YARN) build
dev-frontend: dependencies-frontend
$(YARN) start
# Backend
dependencies-backend: $(DEPENDENCIES) godep
build-backend: dependencies-backend
$(GO_LINTABLE_PACKAGES):
$(GOLINT) $@
$(GOVET) $@
lint-backend: dependencies-backend $(GO_LINTABLE_PACKAGES)
bindata:
$(BINDATA) \
-pkg assets \
-o ./server/assets/asset.go \
build/static/... \
build/*.json \
build/*.png \
build/*.svg \
build/*.ico \
build/index.html
prepare-build: | build-frontend build-backend bindata
validate-commit: | dependencies-backend no-changes-in-commit
build-app: | prepare-build packages
# Run only server
gorun:
go run cli/server/server.go
## Compiles the assets, and serve the tool through its API
serve: | build-frontend build-backend gorun
.PHONY: dependencies-frontend build-frontend dev-frontend \
dependencies-frontend-development prepare-build build-app \
test-frontend lint-frontend \
dependencies-backend build-backend release-build \
lint-backend bindata \
gorun serve validate-commit