-
Notifications
You must be signed in to change notification settings - Fork 79
/
Makefile
208 lines (164 loc) · 7.96 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
PROJECT_NAME := Pulumi Amazon Web Services (AWS) EKS Components
# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
# Local & branch builds will just used this fixed default version unless specified
PROVIDER_VERSION ?= 2.0.0-alpha.0+dev
# Use this normalised version everywhere rather than the raw input to ensure consistency.
VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION)")
TESTPARALLELISM := 12
PACK := eks
PROVIDER := pulumi-resource-${PACK}
CODEGEN := pulumi-gen-${PACK}
GZIP_PREFIX := pulumi-resource-${PACK}-v${VERSION_GENERIC}
WORKING_DIR := $(shell pwd)
JAVA_GEN := pulumi-java-gen
JAVA_GEN_VERSION := v0.9.8
EKS_SRC := $(wildcard nodejs/eks/*.*) $(wildcard nodejs/eks/*/*.ts) $(wildcard nodejs/eks/*/*/*.ts)
LOCAL_PLAT ?= ""
PKG_ARGS := --no-bytecode --public-packages "*" --public
PKG_TARGET := ./bin/cmd/provider/index.js
build:: schema provider build_nodejs build_python build_go build_dotnet build_java
schema::
(cd provider/cmd/$(CODEGEN) && go run main.go schema ../$(PROVIDER))
provider:: bin/${PROVIDER}
build_nodejs::
rm -rf nodejs/eks/bin/*
cd nodejs/eks && \
yarn install && \
yarn run tsc && \
yarn run tsc --version && \
sed -e 's/\$${VERSION}/$(VERSION_GENERIC)/g' < package.json > bin/package.json && \
cp ../../README.md ../../LICENSE bin/ && \
cp -R dashboard bin/ && \
cp -R cni bin/ && \
cp ../../provider/cmd/pulumi-resource-eks/schema.json bin/cmd/provider/
bin/pulumi-java-gen::
mkdir -p bin/
pulumictl download-binary -n pulumi-language-java -v $(JAVA_GEN_VERSION) -r pulumi/pulumi-java
build_java:: PACKAGE_VERSION := ${VERSION_GENERIC}
build_java:: bin/pulumi-java-gen schema
rm -rf sdk/java
$(WORKING_DIR)/bin/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema.json --out sdk/java --build gradle-nexus
cd sdk/java && \
echo "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
gradle --console=plain build
build_python:: schema
rm -rf sdk/python
cd provider/cmd/$(CODEGEN) && go run main.go python ../../../sdk/python ../$(PROVIDER)/schema.json $(VERSION_GENERIC)
cd sdk/python/ && \
echo "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
cp ../../README.md . && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
python3 -m venv venv && \
./venv/bin/python -m pip install build && \
cd ./bin && \
../venv/bin/python -m build .
build_go:: schema
rm -rf sdk/go
cd provider/cmd/$(CODEGEN) && go run main.go go ../../../sdk/go ../$(PROVIDER)/schema.json $(VERSION_GENERIC)
build_dotnet:: schema
rm -rf sdk/dotnet
cd provider/cmd/$(CODEGEN) && go run main.go dotnet ../../../sdk/dotnet ../$(PROVIDER)/schema.json $(VERSION_GENERIC)
cd sdk/dotnet/ && \
echo "module fake_dotnet_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \
echo "${VERSION_GENERIC}" >version.txt && \
dotnet build
lint:
cd nodejs/eks && \
yarn install && \
yarn format && \
yarn run tslint -c ../tslint.json -p tsconfig.json
lint_provider::
cd provider && golangci-lint run -c ../.golangci.yml
install_provider:: PROVIDER_VERSION := latest
install_provider:: provider install_nodejs_sdk
cd provider/cmd/$(PROVIDER) && \
rm -rf ../provider.bin/ && \
cp -R . ../provider.bin && mv ../provider.bin ./bin && \
cp ../../../bin/$(PROVIDER) ./bin && \
sed -e 's/\$${VERSION}/$(PROVIDER_VERSION)/g' < package.json > bin/package.json && \
cd ./bin && \
yarn install && \
yarn link @pulumi/eks
generate_schema:: schema
install_nodejs_sdk:: build_nodejs
yarn link --cwd $(WORKING_DIR)/nodejs/eks/bin
install_dotnet_sdk:: build_dotnet
mkdir -p $(WORKING_DIR)/nuget
find . -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \;
install_go_sdk::
#Intentionally empty for CI / CD templating
install_python_sdk::
#Intentionally empty for CI / CD templating
install_java_sdk::
#Intentionally empty for CI / CD templating
nodejs/eks/node_modules: nodejs/eks/package.json nodejs/eks/yarn.lock
yarn install --cwd nodejs/eks --no-progress
@touch nodejs/eks/node_modules
nodejs/eks/bin: nodejs/eks/node_modules ${EKS_SRC}
@cd nodejs/eks && \
yarn tsc && \
sed -e 's/\$${VERSION}/$(VERSION_GENERIC)/g' < package.json > bin/package.json && \
cp -R dashboard bin/ && \
cp -R cni bin/ && \
cp ../../provider/cmd/pulumi-resource-eks/schema.json bin/cmd/provider/
@touch nodejs/eks/bin
# Re-use the local platform if provided (e.g. `make provider LOCAL_PLAT=linux-amd64`)
ifneq ($(LOCAL_PLAT),"")
bin/${PROVIDER}:: bin/provider/$(LOCAL_PLAT)/${PROVIDER}
cp bin/provider/$(LOCAL_PLAT)/${PROVIDER} bin/${PROVIDER}
else
bin/${PROVIDER}: nodejs/eks/bin nodejs/eks/node_modules
cd nodejs/eks && yarn run pkg ${PKG_TARGET} ${PKG_ARGS} --target node18 --output $(WORKING_DIR)/bin/${PROVIDER}
endif
bin/provider/linux-amd64/${PROVIDER}:: TARGET := node18-linuxstatic-x64
bin/provider/linux-arm64/${PROVIDER}:: TARGET := node18-linuxstatic-arm64
bin/provider/darwin-amd64/${PROVIDER}:: TARGET := node18-macos-x64
bin/provider/darwin-arm64/${PROVIDER}:: TARGET := node18-macos-arm64
bin/provider/windows-amd64/${PROVIDER}.exe:: TARGET := node18-win-x64
bin/provider/%:: nodejs/eks/bin nodejs/eks/node_modules
test ${TARGET}
cd nodejs/eks && \
yarn run pkg ${PKG_TARGET} ${PKG_ARGS} --target ${TARGET} --output ${WORKING_DIR}/$@
dist/${GZIP_PREFIX}-linux-amd64.tar.gz:: bin/provider/linux-amd64/${PROVIDER}
dist/${GZIP_PREFIX}-linux-arm64.tar.gz:: bin/provider/linux-arm64/${PROVIDER}
dist/${GZIP_PREFIX}-darwin-amd64.tar.gz:: bin/provider/darwin-amd64/${PROVIDER}
dist/${GZIP_PREFIX}-darwin-arm64.tar.gz:: bin/provider/darwin-arm64/${PROVIDER}
dist/${GZIP_PREFIX}-windows-amd64.tar.gz:: bin/provider/windows-amd64/${PROVIDER}.exe
dist/${GZIP_PREFIX}-%.tar.gz::
@mkdir -p dist
@# $< is the last dependency (the binary path from above)
tar --gzip -cf $@ README.md LICENSE -C $$(dirname $<) .
dist:: dist/${GZIP_PREFIX}-linux-amd64.tar.gz
dist:: dist/${GZIP_PREFIX}-linux-arm64.tar.gz
dist:: dist/${GZIP_PREFIX}-darwin-amd64.tar.gz
dist:: dist/${GZIP_PREFIX}-darwin-arm64.tar.gz
dist:: dist/${GZIP_PREFIX}-windows-amd64.tar.gz
test_build::
cd examples/utils/testvpc && yarn install && yarn run tsc
test_nodejs:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_nodejs:: provider install_nodejs_sdk
cd examples && go test -tags=nodejs -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_nodejs_upgrade:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_nodejs_upgrade:: provider install_nodejs_sdk
cd provider && go test -tags=nodejs -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_python:: install_provider test_build
cd examples && go test -tags=python -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_dotnet:: install_provider
cd examples && go test -tags=dotnet -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_java:: install_provider
cd examples && go test -tags=java -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_unit_tests:
cd nodejs/eks && \
yarn install && \
yarn run test
specific_test:: install_nodejs_sdk test_build
cd examples && go test -tags=$(LanguageTags) -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . --run=TestAcc$(TestName) 2>&1 | tee /tmp/gotest.log | gotestfmt
specific_test_local:: install_nodejs_sdk test_build
cd examples && go test -tags=$(LanguageTags) -v -count=1 -cover -timeout 3h . --run=TestAcc$(TestName)
dev:: lint build_nodejs
test:: test_nodejs
test_provider:
@echo ""
@echo "== test_provider ==================================================================="
@echo ""
cd provider && go test -v -short ./... -parallel $(TESTPARALLELISM)