forked from aws/amazon-ecs-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (108 loc) · 4.43 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Copyright 2015-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
ROOT := $(shell pwd)
all: build
SOURCEDIR := ./ecs-cli
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
LOCAL_BINARY := bin/local/ecs-cli
LINUX_BINARY := bin/linux-amd64/ecs-cli
DARWIN_BINARY := bin/darwin-amd64/ecs-cli
WINDOWS_BINARY := bin/windows-amd64/ecs-cli.exe
LOCAL_PATH := $(ROOT)/scripts:${PATH}
DEP_RELEASE_TAG := v0.5.4
GO_RELEASE_TAG := 1.13
.PHONY: build
build: $(LOCAL_BINARY)
$(LOCAL_BINARY): $(SOURCES)
./scripts/build_binary.sh ./bin/local
@echo "Built ecs-cli"
.PHONY: test
test:
env -i PATH=$$PATH GOPATH=$$(go env GOPATH) GOROOT=$$(go env GOROOT) GOCACHE=$$(go env GOCACHE) \
go test -race -timeout=120s -cover ./ecs-cli/modules/...
.PHONY: integ-test
integ-test: integ-test-build integ-test-run-with-coverage
# Builds the ecs-cli.test binary.
# This binary is the same as regular ecs-cli but it additionally gives coverage stats to stdout after each execution.
.PHONY: integ-test-build
integ-test-build:
@echo "Installing dependencies..."
go get github.com/wadey/gocovmerge
@echo "Building ecs-cli.test..."
env -i PATH=$$PATH GOPATH=$$(go env GOPATH) GOROOT=$$(go env GOROOT) GOCACHE=$$(go env GOCACHE) \
go test -coverpkg ./ecs-cli/modules/... -c -tags testrunmain -o ./bin/local/ecs-cli.test ./ecs-cli
# Run our integration tests using the ecs-cli.test binary.
.PHONY: integ-test-run
integ-test-run:
@echo "Running integration tests..."
go test -timeout 60m -tags integ -v ./ecs-cli/integ/e2e/...
# Run `integ-test-run` and merge each coverage file from our e2e tests to one file and calculate the total coverage.
.PHONY: integ-test-run-with-coverage
integ-test-run-with-coverage: integ-test-run
@echo "Code coverage"
gocovmerge $$TMPDIR/coverage* > $$TMPDIR/all.out
go tool cover -func=$$TMPDIR/all.out
rm $$TMPDIR/coverage* $$TMPDIR/all.out
.PHONY: generate
generate: $(SOURCES)
PATH=$(LOCAL_PATH) go generate ./ecs-cli/modules/...
.PHONY: generate-deps
generate-deps:
DEP_RELEASE_TAG=$DEP_RELEASE_TAG
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
go get github.com/golang/mock/mockgen
go get golang.org/x/tools/cmd/goimports
.PHONY: windows-build
windows-build: $(WINDOWS_BINARY)
.PHONY: docker-build
docker-build:
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
--env ECS_RELEASE=$(ECS_RELEASE) \
golang:$(GO_RELEASE_TAG) make $(LINUX_BINARY)
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
--env ECS_RELEASE=$(ECS_RELEASE) \
golang:$(GO_RELEASE_TAG) make $(DARWIN_BINARY)
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
--env ECS_RELEASE=$(ECS_RELEASE) \
golang:$(GO_RELEASE_TAG) make $(WINDOWS_BINARY)
.PHONY: docker-test
docker-test:
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--workdir=/usr/src/app/src/github.com/aws/amazon-ecs-cli \
--env GOPATH=/usr/src/app \
--env ECS_RELEASE=$(ECS_RELEASE) \
golang:$(GO_RELEASE_TAG) make test
.PHONY: supported-platforms
supported-platforms: $(LINUX_BINARY) $(DARWIN_BINARY) $(WINDOWS_BINARY)
$(WINDOWS_BINARY): $(SOURCES)
@mkdir -p ./bin/windows-amd64
TARGET_GOOS=windows GOARCH=amd64 ./scripts/build_binary.sh ./bin/windows-amd64
mv ./bin/windows-amd64/ecs-cli ./bin/windows-amd64/ecs-cli.exe
@echo "Built ecs-cli.exe for windows"
$(LINUX_BINARY): $(SOURCES)
@mkdir -p ./bin/linux-amd64
TARGET_GOOS=linux GOARCH=amd64 ./scripts/build_binary.sh ./bin/linux-amd64
@echo "Built ecs-cli for linux"
$(DARWIN_BINARY): $(SOURCES)
@mkdir -p ./bin/darwin-amd64
TARGET_GOOS=darwin GOARCH=amd64 ./scripts/build_binary.sh ./bin/darwin-amd64
@echo "Built ecs-cli for darwin"
.PHONY: clean
clean:
rm -rf ./bin/ ||: