-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (56 loc) · 1.96 KB
/
Copy pathMakefile
File metadata and controls
65 lines (56 loc) · 1.96 KB
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
# Definitions
ROOT := $(PWD)
GO_HTML_COV := ./coverage.html
GO_TEST_OUTFILE := ./c.out
GOLANG_DOCKER_IMAGE := golang:1.15
GOLANG_DOCKER_CONTAINER := goesquerydsl-container
CC_TEST_REPORTER_ID := ${CC_TEST_REPORTER_ID}
CC_PREFIX := github.com/mottaquikarim/esquerydsl
# Format according to gofmt: https://github.com/cytopia/docker-gofmt
# Usage:
# make fmt
# make fmt path=src/elastic/index_setup.go
fmt:
ifdef path
docker run --rm -v ${ROOT}:/data cytopia/gofmt -s -w ${path}
else
docker run --rm -v ${ROOT}:/data cytopia/gofmt -s -w .
endif
# Deletes container if exists
# Usage:
# make clean
clean:
docker rm -f ${GOLANG_DOCKER_CONTAINER} || true
# Usage:
# make test
test:
docker run -w /app -v ${ROOT}:/app ${GOLANG_DOCKER_IMAGE} go test ./... -coverprofile=${GO_TEST_OUTFILE}
docker run -w /app -v ${ROOT}:/app ${GOLANG_DOCKER_IMAGE} go tool cover -html=${GO_TEST_OUTFILE} -o ${GO_HTML_COV}
# custom logic for code climate, gross but necessary
_before-cc:
# download CC test reported
docker run -w /app -v ${ROOT}:/app ${GOLANG_DOCKER_IMAGE} \
/bin/bash -c \
"curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter"
# update perms
docker run -w /app -v ${ROOT}:/app ${GOLANG_DOCKER_IMAGE} chmod +x ./cc-test-reporter
# run before build
docker run -w /app -v ${ROOT}:/app \
-e CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} \
${GOLANG_DOCKER_IMAGE} ./cc-test-reporter before-build
_after-cc:
# handle custom prefix
$(eval PREFIX=${CC_PREFIX})
ifdef prefix
$(eval PREFIX=${prefix})
endif
# upload data to CC
docker run -w /app -v ${ROOT}:/app \
-e CC_TEST_REPORTER_ID=${CC_TEST_REPORTER_ID} \
${GOLANG_DOCKER_IMAGE} ./cc-test-reporter after-build --prefix ${PREFIX}
# this runs tests with cc reporting built in
test-ci: _before-cc test _after-cc
# Usage:
# make lint
lint:
docker run --rm -v ${ROOT}:/data cytopia/golint .