-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
43 lines (34 loc) · 1.34 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
CONTAINER_ENGINE?=podman
EXECUTABLE:=log-exploration-api
PACKAGE:=github.com/ViaQ/log-exploration-api
IMAGE_PUSH_REGISTRY:=quay.io/openshift-logging/$(EXECUTABLE)
VERSION:=${shell git describe --tags --always}
BUILDTIME := ${shell date -u '+%Y-%m-%d_%H:%M:%S'}
LDFLAGS:= -s -w -X '${PACKAGE}/pkg/version.Version=${VERSION}' \
-X '${PACKAGE}/pkg/version.BuildTime=${BUILDTIME}'
BUILD_DIR:=./bin
.PHONY: build test clean image image-publish
fmt:
@echo gofmt
find pkg cmd test -name '*.go' | xargs gofmt -s -l -w
lint:
golangci-lint run -c golangci.yaml
build: test
mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 GOOS=linux go build -ldflags "${LDFLAGS}" -o $(BUILD_DIR)/$(EXECUTABLE) cmd/apiserver/main.go
test: fmt
go test ./pkg/... -coverprofile=coverage.out
test-cover: fmt
go test ./pkg/... -coverprofile=coverage.out && go tool cover -html=coverage.out
clean:
rm -rf $(BUILD_DIR)/
image: build
$(CONTAINER_ENGINE) build . -t ${IMAGE_PUSH_REGISTRY}:${VERSION}
image-publish: image
$(CONTAINER_ENGINE) push ${IMAGE_PUSH_REGISTRY}:${VERSION}
test-e2e:
podman run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.13.0
chmod +x test/e2e/populate_indices.sh
test/e2e/populate_indices.sh
go test -v test/e2e/*.go
podman stop elasticsearch || true && podman rm elasticsearch || true