-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
91 lines (68 loc) · 3.02 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
ROOT := $(shell pwd)
SOURCEDIR=./
exesuffix=$(go env GOEXE)
AWS_CONTAINERD_LOGGERS_DIR=$(SOURCEDIR)
AWS_CONTAINERD_LOGGERS_BINARY=$(ROOT)/bin/shim-loggers-for-containerd$(exesuffix)
SOURCES=$(shell find $(SOURCEDIR) -name '*.go')
BINPATH:=$(abspath ./bin)
DEPSPATH:=$(abspath ./deps)
.PHONY: all
all: build test
.PHONY: build
build: $(AWS_CONTAINERD_LOGGERS_BINARY)
$(AWS_CONTAINERD_LOGGERS_BINARY):
go build -o $(AWS_CONTAINERD_LOGGERS_BINARY) $(AWS_CONTAINERD_LOGGERS_DIR)
.PHONY: test-unit
test-unit: $(SOURCES)
go test -tags unit -race -timeout 30s -cover $(shell go list ./... | grep -v e2e) --count=1
.PHONY: test-e2e
test-e2e:
go test -tags e2e -timeout 30m ./e2e -test.v -ginkgo.v --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)"
.PHONY: test-e2e-for-awslogs
test-e2e-for-awslogs:
go test -tags e2e -timeout 30m ./e2e -test.v -ginkgo.v --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)" --log-driver "awslogs"
.PHONY: test-e2e-for-fluentd
test-e2e-for-fluentd:
go test -tags e2e -timeout 30m ./e2e -test.v -ginkgo.v --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)" --log-driver "fluentd"
.PHONY: test-e2e-for-splunk
test-e2e-for-splunk:
go test -tags e2e -timeout 30m ./e2e -test.v -ginkgo.v --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)" --log-driver "splunk" --splunk-token ${SPLUNK_TOKEN}
.PHONY: test-benchmark-for-awslogs
test-benchmark-for-awslogs:
cd benchmark/awslogs && go test -tags benchmark,e2e -bench=Awslogs -benchmem --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)"
.PHONY: test-benchmark-for-fluentd
test-benchmark-for-fluentd:
cd benchmark/fluentd && go test -tags benchmark,e2e -bench=Fluentd -benchmem --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)"
.PHONY: test-benchmark-for-splunk
test-benchmark-for-splunk:
cd benchmark/splunk && go test -tags benchmark,e2e -bench=Splunk -benchmem --binary "$(AWS_CONTAINERD_LOGGERS_BINARY)" --splunk-token ${SPLUNK_TOKEN}
.PHONY: coverage
coverage:
go test -tags unit $(shell go list ./... | grep -v e2e) -coverprofile=test-coverage.out
go tool cover -html=test-coverage.out
.PHONY: lint
lint: $(SOURCES)
$(DEPSPATH)/golangci-lint run --build-tags e2e,unit
.PHONY: mdlint
# Install it locally: https://github.com/igorshubovych/markdownlint-cli#installation
# Or see `mdlint-ctr` below or https://github.com/DavidAnson/markdownlint#related.
mdlint:
markdownlint '**/*.md'
.PHONY: mdlint-ctr
# If markdownlint is not installed, you can run markdownlint within a container.
mdlint-ctr:
docker run --rm -v "$(shell pwd):/repo:ro" -w /repo avtodev/markdown-lint:v1 '**/*.md'
.get-deps-stamp:
GO111MODULE=off GOBIN=$(DEPSPATH) go get golang.org/x/tools/cmd/goimports
GOBIN=$(DEPSPATH) go get github.com/golang/mock/[email protected]
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(DEPSPATH) v1.54.0
$(DEPSPATH)/golangci-lint --version
touch .get-deps-stamp
.PHONY: get-deps
get-deps: .get-deps-stamp
.PHONY: clean
clean:
@rm -f $(BINPATH)/*
@rm -f .get-deps-stamp