forked from pulumi/pulumi-awsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
227 lines (181 loc) · 8.37 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
MAKEFLAGS := --jobs=$(shell nproc) --warn-undefined-variables
PROJECT_NAME := Pulumi Infrastructure Components for AWS
VERSION := $(shell pulumictl get version)
TESTPARALLELISM := 10
PACK := awsx
PROVIDER := pulumi-resource-${PACK}
CODEGEN := pulumi-gen-${PACK}
GZIP_PREFIX := pulumi-resource-${PACK}-v${VERSION}
BIN := ${PROVIDER}
JAVA_GEN := pulumi-java-gen
JAVA_GEN_VERSION := v0.5.0
AWSX_SRC := $(wildcard awsx/*.*) $(wildcard awsx/*/*.ts)
AWSX_CLASSIC_SRC:= $(wildcard awsx-classic/*.*) $(wildcard awsx-classic/*/*.ts)
CODEGEN_SRC := $(wildcard schemagen/go.*) $(wildcard schemagen/pkg/*/*.go) $(wildcard schemagen/pkg/cmd/${CODEGEN}/*.go)
WORKING_DIR := $(shell pwd)
GOPATH ?= ${HOME}/go
GOBIN ?= ${GOPATH}/bin
LanguageTags ?= "all"
LOCAL_PLAT ?= ""
PKG_ARGS := --no-bytecode --public-packages "*" --public
all:: lint lint_classic provider build_sdks test_provider
bin/${CODEGEN}: ${CODEGEN_SRC}
cd schemagen && go build -o $(WORKING_DIR)/bin/${CODEGEN} $(WORKING_DIR)/schemagen/cmd/$(CODEGEN)
awsx/schema.json: bin/${CODEGEN}
cd schemagen/cmd/$(CODEGEN) && go run . schema $(WORKING_DIR)/$(PACK)
awsx/node_modules: awsx/package.json awsx/yarn.lock
yarn install --cwd awsx --no-progress
@touch awsx/node_modules
awsx/schema-types.ts: awsx/node_modules awsx/schema.json
cd awsx && yarn gen-types
awsx/bin: awsx/node_modules ${AWSX_SRC}
@cd awsx && \
yarn tsc && \
cp package.json schema.json ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json
# 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}: awsx/bin awsx/node_modules
cd awsx && yarn run pkg . ${PKG_ARGS} --target node16 --output $(WORKING_DIR)/bin/${PROVIDER}
endif
bin/provider/linux-amd64/${PROVIDER}:: TARGET := node16-linuxstatic-x64
bin/provider/linux-arm64/${PROVIDER}:: TARGET := node16-linuxstatic-arm64
bin/provider/darwin-amd64/${PROVIDER}:: TARGET := node16-macos-x64
bin/provider/darwin-arm64/${PROVIDER}:: TARGET := node16-macos-arm64
bin/provider/windows-amd64/${PROVIDER}.exe:: TARGET := node16-win-x64
bin/provider/%:: awsx/bin awsx/node_modules
test ${TARGET}
cd awsx && \
yarn run pkg . ${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 $<) .
sdk/nodejs/bin:: VERSION := $(shell pulumictl get version --language javascript)
sdk/nodejs/bin:: bin/${CODEGEN} awsx/schema.json ${AWSX_CLASSIC_SRC}
rm -rf sdk/nodejs
bin/${CODEGEN} nodejs sdk/nodejs awsx/schema.json $(VERSION)
cd sdk/nodejs && \
yarn install --no-progress && \
yarn run tsc --version && \
yarn run tsc && \
sed -e 's/\$${VERSION}/$(VERSION)/g' < package.json > bin/package.json && \
cp ../../README.md ../../LICENSE bin/
sdk/java/build:: VERSION := $(shell pulumictl get version --language javascript)
sdk/java/build:: bin/pulumi-java-gen awsx/schema.json ${AWSX_CLASSIC_SRC}
rm -rf sdk/java
$(WORKING_DIR)/bin/$(JAVA_GEN) generate --schema awsx/schema.json --out sdk/java --build gradle-nexus
cd sdk/java && \
gradle --console=plain build
bin/pulumi-java-gen::
$(shell pulumictl download-binary -n pulumi-language-java -v $(JAVA_GEN_VERSION) -r pulumi/pulumi-java)
sdk/python/bin:: PYPI_VERSION := $(shell pulumictl get version --language python)
sdk/python/bin:: bin/${CODEGEN} awsx/schema.json README.md
rm -rf sdk/python
bin/${CODEGEN} python sdk/python awsx/schema.json $(VERSION)
cd sdk/python/ && \
cp ../../README.md . && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' -e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "$(VERSION)"/g' ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist
sdk/go:: VERSION := $(shell pulumictl get version --language generic)
sdk/go:: AWS_VERSION := $(shell node -e 'console.log(require("./awsx/package.json").dependencies["@pulumi/aws"])')
sdk/go:: bin/${CODEGEN} awsx/schema.json
rm -rf sdk/go
bin/${CODEGEN} go sdk/go awsx/schema.json $(VERSION)
cd sdk && \
go get github.com/pulumi/pulumi-aws/sdk/v5@v$(AWS_VERSION) && \
go mod tidy && \
go test -v ./... -check.vv
sdk/dotnet/bin:: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
sdk/dotnet/bin:: bin/${CODEGEN} awsx/schema.json
rm -rf sdk/dotnet
bin/${CODEGEN} dotnet sdk/dotnet awsx/schema.json $(VERSION)
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
# Phony targets
build_nodejs:: sdk/nodejs/bin
build_python:: sdk/python/bin
build_go:: sdk/go
build_dotnet:: sdk/dotnet/bin
build_java:: sdk/java/build
install_provider: bin/${PROVIDER}
rm -f ${GOBIN}/${PROVIDER}
cp bin/${PROVIDER} ${GOBIN}/${PROVIDER}
install_nodejs_sdk:: sdk/nodejs/bin
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin
install_python_sdk:: sdk/python/bin
#Intentionall empty for CI / CD templating
install_go_sdk:: sdk/go
#Intentionally empty for CI / CD templating
install_dotnet_sdk:: sdk/dotnet/bin
mkdir -p $(WORKING_DIR)/nuget
find sdk/dotnet/bin -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \;
@if ! dotnet nuget list source | grep ${WORKING_DIR}; then \
dotnet nuget add source ${WORKING_DIR}/nuget --name ${WORKING_DIR} \
; fi\
lint_classic:
cd awsx-classic && \
yarn install --no-progress && \
yarn lint
lint:: awsx/node_modules
cd awsx && \
yarn format && yarn lint
test_provider:: awsx/node_modules
cd awsx && yarn test
istanbul_tests::
cd awsx-classic/tests && \
yarn && yarn run build && yarn run mocha $$(find bin -name '*.spec.js')
test_nodejs:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_nodejs:: bin/${PROVIDER} install_nodejs_sdk
@export PATH
cd examples && go test -tags=nodejs -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_python:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_python:: bin/${PROVIDER}
@export PATH
cd examples && go test -tags=python -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_java:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_java:: bin/${PROVIDER}
@export PATH
cd examples && go test -tags=java -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_go:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_go:: bin/${PROVIDER}
@export PATH
cd examples && go test -tags=go -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test_dotnet:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_dotnet:: bin/${PROVIDER} install_dotnet_sdk
@export PATH
cd examples && go test -tags=dotnet -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
test:: PATH := $(WORKING_DIR)/bin:$(PATH)
test::
@export PATH
@if [ -z "${Test}" ]; then \
cd examples && go test -tags=$(LanguageTags) -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt; \
else \
cd examples && go test -tags=$(LanguageTags) -v -json -count=1 -cover -timeout 3h . --run=${Test} 2>&1 | tee /tmp/gotest.log; \
fi
schemagen:: bin/${CODEGEN}
schema: awsx/schema.json
provider: bin/${PROVIDER}
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
clean:
rm -rf bin dist awsx/bin awsx/node_modules
build_sdks: build_nodejs build_python build_go build_dotnet build_java
build:: provider test_provider build_sdks
dev:: lint test_provider build_nodejs
.PHONY: clean provider install_% dist sdk/go