forked from pulumi/pulumi-awsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
251 lines (203 loc) · 9.65 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
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.9.7
AWSX_SRC := $(wildcard awsx/*.*) $(wildcard awsx/*/*.ts)
AWSX_CLASSIC_SRC:= $(wildcard awsx-classic/*.*) $(wildcard awsx-classic/*/*.ts)
CODEGEN_SRC := $(shell find schemagen -type f)
WORKING_DIR := $(shell pwd)
GOPATH ?= ${HOME}/go
GOBIN ?= ${GOPATH}/bin
LanguageTags ?= "all"
LOCAL_PLAT ?= ""
PKG_ARGS := --no-bytecode --public-packages "*" --public
# Pre-requisites: ensure these folders exist
_ := $(shell mkdir -p .make bin dist)
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)
.make/schema: bin/${CODEGEN} awsx/package.json
bin/${CODEGEN} schema $(WORKING_DIR)
@touch $@
.make/awsx_node_modules: awsx/package.json awsx/yarn.lock
yarn install --cwd awsx --no-progress
@touch $@
.make/gen_types: .make/awsx_node_modules .make/schema
cd awsx && yarn gen-types
@touch $@
.make/awsx_bin: .make/awsx_node_modules .make/gen_types ${AWSX_SRC}
@cd awsx && \
yarn tsc && \
cp package.json ../schema.json ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json
@touch $@
# 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}: .make/awsx_bin .make/awsx_node_modules .make/gen_types
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/%:: .make/awsx_bin .make/gen_types
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 $<) .
.make/build_nodejs: VERSION := $(shell pulumictl get version --language javascript)
.make/build_nodejs: bin/${CODEGEN} .make/schema ${AWSX_CLASSIC_SRC}
rm -rf sdk/nodejs
bin/${CODEGEN} nodejs sdk/nodejs 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/
@touch $@
.make/build_java: VERSION := $(shell pulumictl get version --language javascript)
.make/build_java: bin/pulumi-java-gen .make/schema ${AWSX_CLASSIC_SRC}
rm -rf sdk/java
$(WORKING_DIR)/bin/$(JAVA_GEN) generate --schema schema.json --out sdk/java --build gradle-nexus
cd sdk/java && \
gradle --console=plain build
@touch $@
bin/pulumi-java-gen::
$(shell pulumictl download-binary -n pulumi-language-java -v $(JAVA_GEN_VERSION) -r pulumi/pulumi-java)
.make/build_python: PYPI_VERSION := $(shell pulumictl get version --language python)
.make/build_python: bin/${CODEGEN} .make/schema README.md
rm -rf sdk/python
bin/${CODEGEN} python sdk/python schema.json $(VERSION)
cd sdk/python/ && \
cp ../../README.md . && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e 's/^ version = .*/ version = "$(PYPI_VERSION)"/g' ./bin/pyproject.toml && \
rm ./bin/pyproject.toml.bak && \
python3 -m venv venv && \
./venv/bin/python -m pip install build && \
cd ./bin && \
../venv/bin/python -m build .
.make/build_go: VERSION := $(shell pulumictl get version --language generic)
.make/build_go: AWS_VERSION := $(shell node -e 'console.log(require("./awsx/package.json").dependencies["@pulumi/aws"])')
.make/build_go: bin/${CODEGEN} .make/schema
rm -rf sdk/go
bin/${CODEGEN} go sdk/go schema.json $(VERSION)
cd sdk && \
go get github.com/pulumi/pulumi-aws/sdk/v6@v$(AWS_VERSION) && \
go mod tidy && \
go test -v ./... -check.vv
@touch $@
.make/build_dotnet: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
.make/build_dotnet: bin/${CODEGEN} .make/schema
rm -rf sdk/dotnet
bin/${CODEGEN} dotnet sdk/dotnet schema.json $(VERSION)
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
@touch $@
# Phony targets
build_nodejs: .make/build_nodejs
build_python: .make/build_python
build_go: .make/build_go
build_dotnet: .make/build_dotnet
build_java: .make/build_java
install_provider: bin/${PROVIDER}
rm -f ${GOBIN}/${PROVIDER}
cp bin/${PROVIDER} ${GOBIN}/${PROVIDER}
install_nodejs_sdk: .make/build_nodejs
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin
install_python_sdk: .make/build_python
#Intentionall empty for CI / CD templating
install_go_sdk: .make/build_go
#Intentionally empty for CI / CD templating
install_dotnet_sdk: .make/build_dotnet
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:: .make/awsx_node_modules
cd awsx && \
yarn format && yarn lint
test_provider:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_provider:: .make/awsx_node_modules .make/gen_types bin/${PROVIDER} bin/gotestfmt
cd awsx && yarn test
@export PATH
cd provider && go test -tags=yaml -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
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 bin/gotestfmt
@export PATH
cd provider && go test -tags=nodejs -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
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} bin/gotestfmt
@export PATH
cd provider && go test -tags=python -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
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} bin/gotestfmt
@export PATH
cd provider && go test -tags=java -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
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} bin/gotestfmt
@export PATH
cd provider && go test -tags=go -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
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 bin/gotestfmt
@export PATH
cd provider && go test -tags=dotnet -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
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:: bin/gotestfmt
@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: .make/schema
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 .make 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
bin/gotestfmt:
@mkdir -p bin
@GOBIN="${PWD}/bin" go install github.com/gotesttools/gotestfmt/v2/cmd/[email protected]
.PHONY: clean provider install_% dist sdk/go