1
+ SHELL =bash -x
1
2
built_at := $(shell date +% s)
2
3
git_commit := $(shell git describe --dirty --always)
3
4
@@ -20,8 +21,10 @@ install-build-deps: ## Install dependencies (packages and tools)
20
21
21
22
# #@ Build
22
23
23
- .PHONY : build
24
- build : generate-bindata-assets generate-kubernetes-types # # Build eksctl
24
+ gofiles = $(shell $1 | xargs go list -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}')
25
+ godeps = $(call gofiles,go list -f '{{join .Deps "\n"}}' $1)
26
+
27
+ eksctl : $(call godeps,./cmd/...) # # Build main binary
25
28
CGO_ENABLED=0 time go build -v -ldflags " -X $( version_pkg) .gitCommit=$( git_commit) -X $( version_pkg) .builtAt=$( built_at) " ./cmd/eksctl
26
29
27
30
# #@ Testing & CI
@@ -50,11 +53,11 @@ lint: ## Run linter over the codebase
50
53
time " $( GOBIN) /gometalinter" ./pkg/... ./cmd/... ./integration/...
51
54
52
55
.PHONY : test
53
- test : # # Run unit test (and re-generate code under test)
56
+ test :
54
57
$(MAKE ) lint
55
- $(MAKE ) generate-aws-mocks-test generate-bindata-assets-test generate-kubernetes-types-test
58
+ $(MAKE ) check-generated-sources-up-to-date
56
59
$(MAKE ) unit-test
57
- $(MAKE ) build -integration-test
60
+ $(MAKE ) eksctl -integration-test
58
61
59
62
.PHONY : unit-test
60
63
unit-test : # # Run unit test only
@@ -64,14 +67,12 @@ unit-test: ## Run unit test only
64
67
unit-test-race : # # Run unit test with race detection
65
68
CGO_ENABLED=1 time go test -race ./pkg/... ./cmd/... $(UNIT_TEST_ARGS )
66
69
67
- .PHONY : build-integration-test
68
- build-integration-test : # # Build integration test binary
69
- time go test -tags integration ./integration/... -c -o ./eksctl-integration-test
70
+ eksctl-integration-test : $(call gofiles,go list -f '{{join .Deps "\n"}}' `go list -tags integration -f '{{join .XTestImports " "}}' ./integration/...`) # # Build integration test binary
71
+ time go test -tags integration ./integration/... -c -o $@
70
72
71
73
.PHONY : integration-test
72
- integration-test : build build-integration-test # # Run the integration tests (with cluster creation and cleanup)
73
- cd integration; ../eksctl-integration-test -test.timeout 60m \
74
- $(INTEGRATION_TEST_ARGS )
74
+ integration-test : eksctl eksctl-integration-test # # Run the integration tests (with cluster creation and cleanup)
75
+ cd integration; ../eksctl-integration-test -test.timeout 60m $(INTEGRATION_TEST_ARGS )
75
76
76
77
.PHONY : integration-test-container
77
78
integration-test-container : eksctl-image # # Run the integration tests inside a Docker container
@@ -91,7 +92,7 @@ integration-test-container-pre-built: ## Run the integration tests inside a Dock
91
92
92
93
TEST_CLUSTER ?= integration-test-dev
93
94
.PHONY : integration-test-dev
94
- integration-test-dev : build build -integration-test # # Run the integration tests without cluster teardown. For use when developing integration tests.
95
+ integration-test-dev : eksctl eksctl -integration-test # # Run the integration tests without cluster teardown. For use when developing integration tests.
95
96
./eksctl utils write-kubeconfig \
96
97
--auto-kubeconfig \
97
98
--name=$(TEST_CLUSTER )
@@ -111,54 +112,55 @@ delete-integration-test-dev-cluster: build ## Delete the test cluster for use wh
111
112
112
113
# #@ Code Generation
113
114
114
- .PHONY : generate-bindata-assets
115
- generate-bindata-assets : # # Generate bindata assets (node bootstrap config files & add-on manifests)
116
- chmod g-w ./pkg/nodebootstrap/assets/*
117
- env GOBIN=$(GOBIN ) time go generate ./pkg/nodebootstrap ./pkg/addons/default
115
+ AWS_SDK_MOCKS =$(wildcard pkg/eks/mocks/* API.go)
116
+
117
+ GENERATED_FILES =pkg/addons/default/assets.go \
118
+ pkg/nodebootstrap/assets.go \
119
+ pkg/apis/eksctl.io/v1alpha5/zz_generated.deepcopy.go \
120
+ pkg/ami/static_resolver_ami.go \
121
+ site/content/usage/20-schema.md \
122
+ $(AWS_SDK_MOCKS )
123
+
124
+ .PHONY : regenerate-sources
125
+ # TODO: generate-ami is broken (see https://github.com/weaveworks/eksctl/issues/949 ), include it when fixed
126
+ regenerate-sources : $(GENERATED_FILES ) # generate-ami ## Re-generate all the automatically-generated source files
127
+
128
+ .PHONY : check-generated-files-up-to-date
129
+ check-generated-sources-up-to-date : regenerate-sources
130
+ git diff --quiet -- $(GENERATED_FILES ) || (git --no-pager diff $( GENERATED_FILES) ; exit 1)
118
131
119
- .PHONY : generate-bindata-assets-test
120
- generate-bindata-assets-test : generate-bindata-assets # # Test if generated bindata assets are checked-in
121
- git diff --exit-code ./pkg/nodebootstrap/assets.go > /dev/null || (git --no-pager diff ./pkg/nodebootstrap/assets.go; exit 1)
122
- git diff --exit-code ./pkg/addons/default/assets.go > /dev/null || (git --no-pager diff ./pkg/addons/default/assets.go; exit 1)
132
+ pkg/addons/default/assets.go : $(wildcard pkg/addons/default/assets/* )
133
+ env GOBIN=$(GOBIN ) time go generate ./$(@D )
134
+
135
+ pkg /nodebootstrap/assets.go : $(wildcard pkg/nodebootstrap/assets/* )
136
+ chmod g-w $^
137
+ env GOBIN=$(GOBIN ) time go generate ./$(@D )
123
138
124
139
.license-header : LICENSE
125
140
@# generate-groups.sh can't find the lincense header when using Go modules, so we provide one
126
141
printf " /*\n%s\n*/\n" " $$ (cat LICENSE)" > $@
127
142
128
- .PHONY : generate-kubernetes-types
129
- generate-kubernetes-types : .license-header # # Generate Kubernetes API helpers
143
+ pkg/apis/eksctl.io/v1alpha5/zz_generated.deepcopy.go : $(call godeps,./pkg/apis/...) .license-header # # Generate Kubernetes API helpers
130
144
time go mod download k8s.io/code-generator # make sure the code-generator is present
131
145
time env GOPATH=
" $$ (go env GOPATH)" bash
" $$ (go env GOPATH)/pkg/mod/k8s.io/[email protected] /generate-groups.sh" \
132
- deepcopy,defaulter pkg/apis ./pkg/apis eksctl.io:v1alpha5 --go-header-file .license-header --output-base=" $$ {PWD}" \
146
+ deepcopy,defaulter _ ./pkg/apis eksctl.io:v1alpha5 --go-header-file .license-header --output-base=" $$ {PWD}" \
133
147
|| (cat codegenheader.txt ; cat pkg/apis/eksctl.io/v1alpha5/zz_generated.deepcopy.go ; exit 1)
134
148
135
- .PHONY : generate-kubernetes-types-test
136
- generate-kubernetes-types-test : generate-kubernetes-types # # Test if generated Kubernetes API helpers are checked-in
137
- git diff --exit-code ./pkg/nodebootstrap/assets.go > /dev/null || (git --no-pager diff ./pkg/nodebootstrap/assets.go; exit 1)
138
-
149
+ # static_resolver_ami.go doesn't only depend on files (it should be refreshed whenever a release is made in AWS)
150
+ # so we need to forcicly generate it
139
151
.PHONY : generate-ami
140
152
generate-ami : # # Generate the list of AMIs for use with static resolver. Queries AWS.
141
153
time go generate ./pkg/ami
142
154
143
- .PHONY : generate-schema
144
- generate-schema : # # Generate the schema file in the documentation site.
145
- @go run ./cmd/schema/generate.go
155
+ site/content/usage/20-schema.md : $(call godeps,cmd/schema/generate.go)
156
+ time go run ./cmd/schema/generate.go $@
146
157
147
- .PHONY : ami-check
148
- ami-check : generate-ami # # Check whether the AMIs have been updated and fail if they have. Designed for a automated test
149
- git diff --exit-code pkg/ami/static_resolver_ami.go > /dev/null || (git --no-pager diff; exit 1)
150
-
151
- .PHONY : generate-aws-mocks
152
- generate-aws-mocks : # # Generate mocks for AWS SDK
158
+ $(AWS_SDK_MOCKS ) : $(call godeps,pkg/eks/mocks/mocks.go)
153
159
mkdir -p vendor/github.com/aws/
154
160
@# Hack for Mockery to find the dependencies handled by `go mod`
155
161
ln -sfn
" $$ (go env GOPATH)/pkg/mod/github.com/aws/[email protected] " vendor/github.com/aws/aws-sdk-go
156
162
time env GOBIN=$(GOBIN ) go generate ./pkg/eks/mocks
157
163
158
- .PHONY : generate-aws-mocks-test
159
- generate-aws-mocks-test : generate-aws-mocks # # Test if generated mocks for AWS SDK are checked-in
160
- git diff --exit-code ./pkg/eks/mocks > /dev/null || (git --no-pager diff ./pkg/eks/mocks; exit 1)
161
-
162
164
# #@ Docker
163
165
164
166
ifeq ($(OS ) ,Windows_NT)
0 commit comments