-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
59 lines (43 loc) · 1.74 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
VERSION ?= $(shell git describe --tags --long)
ALIAS ?= $(VERSION)
CMDS := $(wildcard cmd/*)
DEPLOY_CONTAINERS := $(wildcard deployment/containers/*)
DOCKER_REPOSITORY ?= demonware
DOCKER_BASE := $(DOCKER_REPOSITORY)
DOCKER_TEST_IMAGE ?= $(DOCKER_BASE)/test-ipvs-controllers:$(VERSION)
DOCKER_IMAGE_FQ = $(DOCKER_BASE)/$(basename $(*)):$(VERSION)
DOCKER_IMAGE_ALIAS ?= $(DOCKER_BASE)/$(basename $(*)):$(ALIAS)
.PHONY: images build clean test test-junit test-coverage-html test-image deployment-containers
images: docker deployment-containers
build: $(patsubst cmd/%, target/cmd/%, $(CMDS))
clean:
rm -f target/*
target/cmd:
mkdir -p $@
target/cmd/%: target/cmd
CGO_ENABLED=0 GOOS=linux go build -tags netgo -o $@ cmd/$*/*.go
deployment-containers: $(patsubst deployment/containers/%, deployment-containers/%, $(DEPLOY_CONTAINERS))
deployment-containers/%:
docker build -t $(DOCKER_IMAGE_FQ) deployment/containers/$*
docker: $(patsubst cmd/%, docker/%, $(CMDS))
docker/%:
docker build --build-arg CMD=$(*) -t $(DOCKER_IMAGE_FQ) .
test:
go test -v ./... -cover
test-junit:
go test -v ./... -cover 2>&1 | go-junit-report > /tmp/report.xml
test-coverage-html:
go test ./... -coverprofile=c.out || true
go tool cover -html=c.out -o /tmp/coverage-index.html
coverage:
mkdir coverage
test-image: coverage
docker build -t ${DOCKER_TEST_IMAGE} -f Dockerfile.test .
docker rm ipvs-test-results || true
docker create --name ipvs-test-results ${DOCKER_TEST_IMAGE}
docker cp ipvs-test-results:/tmp/report.xml coverage/test-report.xml
docker cp ipvs-test-results:/tmp/coverage-index.html coverage/index.html
docker rm ipvs-test-results
docker rmi ${DOCKER_TEST_IMAGE}
push/%:
docker push $(DOCKER_IMAGE_FQ)