generated from pulumi/pulumi-provider-boilerplate
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
115 lines (89 loc) · 3.94 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
PROJECT_NAME := Pulumi supabase Resource Provider
PACK := supabase
PACKDIR := sdk
PROJECT := github.com/nitrictech/pulumi-supabase
NODE_MODULE_NAME := @nitric/pulumi-supabase
NUGET_PKG_NAME := Nitric.pulumi-supabase
PROVIDER := pulumi-resource-${PACK}
VERSION ?= $(shell pulumictl get version)
PROVIDER_PATH := provider
VERSION_PATH := main.Version
GOPATH := $(shell go env GOPATH)
WORKING_DIR := $(shell pwd)
TESTPARALLELISM := 4
ensure::
cd provider && go mod tidy
cd sdk && go mod tidy
cd tests && go mod tidy
provider::
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))
provider_debug::
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -gcflags="all=-N -l" -ldflags "-X ${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))
test_provider::
cd provider/pkg && go test -short -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM} ./...
dotnet_sdk:: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
dotnet_sdk::
rm -rf sdk/dotnet
pulumi package gen-sdk $(WORKING_DIR)/bin/$(PROVIDER) --language dotnet
cd ${PACKDIR}/dotnet/&& \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
go_sdk:: $(WORKING_DIR)/bin/$(PROVIDER)
rm -rf sdk/go
pulumi package gen-sdk $(WORKING_DIR)/bin/$(PROVIDER) --language go
nodejs_sdk:: VERSION := $(shell pulumictl get version --language javascript)
nodejs_sdk::
rm -rf sdk/nodejs
pulumi package gen-sdk $(WORKING_DIR)/bin/$(PROVIDER) --language nodejs
cd ${PACKDIR}/nodejs/ && \
yarn install && \
yarn run tsc && \
cp ../../README.md ../../LICENSE package.json yarn.lock bin/ && \
sed -i.bak 's/$${VERSION}/$(VERSION)/g' bin/package.json && \
rm ./bin/package.json.bak
python_sdk:: PYPI_VERSION := $(shell pulumictl get version --language python)
python_sdk::
rm -rf sdk/python
pulumi package gen-sdk $(WORKING_DIR)/bin/$(PROVIDER) --language python
cp README.md ${PACKDIR}/python/
cd ${PACKDIR}/python/ && \
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
.PHONY: build
build:: generate provider dotnet_sdk go_sdk nodejs_sdk python_sdk
# Required for the codegen action that runs in pulumi/pulumi
only_build:: build
lint::
for DIR in "provider" "sdk" "tests" ; do \
pushd $$DIR && golangci-lint run -c ../.golangci.yml --timeout 10m && popd ; \
done
install:: install_nodejs_sdk install_dotnet_sdk
cp $(WORKING_DIR)/bin/${PROVIDER} ${GOPATH}/bin
GO_TEST := go test -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM}
test_all::
cd provider/pkg && $(GO_TEST) ./...
cd tests/sdk/nodejs && $(GO_TEST) ./...
cd tests/sdk/python && $(GO_TEST) ./...
cd tests/sdk/dotnet && $(GO_TEST) ./...
cd tests/sdk/go && $(GO_TEST) ./...
install_dotnet_sdk::
rm -rf $(WORKING_DIR)/nuget/$(NUGET_PKG_NAME).*.nupkg
mkdir -p $(WORKING_DIR)/nuget
find . -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \;
install_python_sdk::
#target intentionally blank
install_go_sdk::
#target intentionally blank
install_nodejs_sdk::
-yarn unlink --cwd $(WORKING_DIR)/sdk/nodejs/bin
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin
.PHONY: generate
# Generate go client for resource provider from supabase openapi spec
generate::
mkdir -p ./provider/pkg/api/supabase
mkdir -p ./provider/pkg/api/supabase/v0
go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest -package supabase https://api.supabase.com/api/v1-json > ./provider/pkg/api/supabase/api.gen.go
go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest -package v0 supabase.v0.yaml > ./provider/pkg/api/supabase/v0/api.gen.go