-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (69 loc) · 2.89 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
BINARY = utask
MAIN_LOCATION = ./cmd
TEST_LOCATION = ./...
# timeout for go test is here to prevent tests running infinitely if one runResolution leads to a step that never recovers (e.g. missing push on a stepChan)
# 15 seconds per unit tests should be enough
TEST_CMD = go test -count=1 -timeout 15s -v -cover -p 1 ${TEST_LOCATION}
TEST_CMD_COV = ${TEST_CMD} -covermode=count -coverprofile=coverage.out
SOURCE_FILES = $(shell find ./ -type f -name "*.go" | grep -v _test.go)
VERSION := $(shell git describe --exact-match --abbrev=0 --tags $(git rev-list --tags --max-count=1) 2> /dev/null)
ifndef VERSION
VERSION = $(shell git describe --abbrev=3 --tags $(git rev-list --tags --max-count=1))-dev
endif
LAST_COMMIT = `git rev-parse HEAD`
VERSION_PKG = github.com/ovh/utask
DOCKER = 0
DOCKER_OPT =
define goreleaser
VERSION_PKG=${VERSION_PKG} LASTCOMMIT=${LAST_COMMIT} VERSION=${VERSION} goreleaser --rm-dist $(1)
endef
define build_binary
GO111MODULE=on go build -ldflags "-X ${VERSION_PKG}.Commit=${LAST_COMMIT} -X ${VERSION_PKG}.Version=${VERSION}" \
-o $(1) ${MAIN_LOCATION}/$(1)
@[ ${DOCKER} -eq 0 ] || $(call docker_build,$(1))
endef
define docker_build
docker build ${DOCKER_OPT} -f ${MAIN_LOCATION}/$(1)/Dockerfile .
endef
all: ${BINARY}
${BINARY}: $(SOURCE_FILES) go.mod
$(call build_binary,${BINARY})
docker:
@echo docker build enabled!
$(eval DOCKER=1)
clean:
rm -f ${BINARY}
re: clean all
release:
bash hack/generate-install-script.sh
release-utask-lib:
cd ui/dashboard/projects/utask-lib && npm version $(VERSION) --allow-same-version
cd ui/dashboard && npm ci && ng build --prod utask-lib
npm publish ui/dashboard/dist/utask-lib --access public
test:
# moving to another location to go get some packages, otherwise it will include those packages as dependencies in go.mod
cd ${HOME} && go get github.com/jstemmer/go-junit-report github.com/stretchr/testify/assert
GO111MODULE=on DEV=true bash hack/test.sh ${TEST_CMD} 2>&1 | go-junit-report > report.xml
test-travis:
# moving to another location to go get some packages, otherwise it will include those packages as dependencies in go.mod
cd ${HOME} && go get golang.org/x/tools/cmd/cover github.com/mattn/goveralls
hack/test.sh ${TEST_CMD_COV}
test-docker:
cd ${HOME} && go get golang.org/x/tools/cmd/cover github.com/mattn/goveralls
DEV=true bash hack/test-docker.sh ${TEST_CMD}
run-test-stack:
bash hack/test.sh bash hack/interactive.sh
run-test-stack-docker:
bash hack/test-docker.sh bash hack/interactive.sh
run-goreleaser:
export BINDIR=${GOPATH}/bin; go install github.com/goreleaser/[email protected]
rm -rf .cache
ifneq (,$(findstring -dev,$(VERSION)))
@echo Run Goreleaser in snapshot mod
$(call goreleaser,--snapshot)
else
@echo Run Goreleaser in release mod
$(call goreleaser)
endif
package:
.PHONY: all clean test re package release test test-travis test-docker run-test-stack run-test-stack-docker run-goreleaser docker