-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (46 loc) · 1.72 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
NAME = s3proxy
REMOTE_NAME = ${REGISTRY}${NAME}
GOPATH ?= ${HOME}/go
VERSION ?= 1.4.5
LDFLAGS=-ldflags "-X main.version=${VERSION}"
GOFILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
default: build
build: clean
go build -v ${LDFLAGS} -o ${NAME}
clean:
if [ -f "${NAME}" ] ; then rm ${NAME} ; fi
lint:
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.59.1 golangci-lint run -v
fmtcheck: tools.goimports
@echo "--> checking code formatting with 'goimports' tool"
@goimports -d $(GOFILES)
@! goimports -l $(GOFILES) | grep -vF 'Nope nope nope'
fmt: tools.goimports
goimports -w $(GOFILES)
test:
go test -v ./...
integration-test: docker-build-image
docker-compose -f ./test/docker-compose.yml up -d minio rsyslog createbuckets
docker run --rm --net=s3proxy-network -i mirakl/${NAME}-build go test -v ./test -tags=integration
docker-compose -f ./test/docker-compose.yml down
end2end-test: docker-build-image
docker-compose -f ./test/docker-compose.yml up -d
docker run --rm --net=s3proxy-network -i mirakl/${NAME}-build go test -v ./test -tags=end2end
docker-compose -f ./test/docker-compose.yml down
docker-image: check-version
docker build . -t mirakl/${NAME}:${VERSION} -t ${REMOTE_NAME}:${VERSION} -t ${REMOTE_NAME}:latest --build-arg VERSION=${VERSION}
docker-build-image:
docker build . -t mirakl/${NAME}-build --target app-builder
docker-image-push: docker-image
docker push ${REMOTE_NAME}:${VERSION}
docker push ${REMOTE_NAME}:latest
check-version:
ifndef VERSION
$(error VERSION is undefined)
endif
tools.goimports:
@command -v goimports >/dev/null ; if [ $$? -ne 0 ]; then \
echo "--> installing goimports"; \
go install golang.org/x/tools/cmd/goimports@latest; \
fi
.PHONY: test