forked from pulumi/pulumi-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: code parity with other native providers
Fixes pulumi#9 and #3 Signed-off-by: Noel Georgi <[email protected]>
- Loading branch information
Showing
26 changed files
with
1,278 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
/vendor/ | ||
**/bin/ | ||
**/obj/ | ||
**/node_modules/ | ||
**/.vs | ||
**/.idea | ||
**/.ionide | ||
.pulumi | ||
Pulumi.*.yaml | ||
yarn.lock | ||
yarn.lock | ||
ci-scripts | ||
/nuget/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
PROJECT_NAME := Pulumi Xyz Resource Provider | ||
|
||
PACK := xyz | ||
PACKDIR := sdk | ||
PROJECT := github.com/pulumi/pulumi-xyz | ||
NODE_MODULE_NAME := @pulumi/xyz | ||
NUGET_PKG_NAME := Pulumi.xyz | ||
|
||
PROVIDER := pulumi-resource-${PACK} | ||
CODEGEN := pulumi-gen-${PACK} | ||
VERSION ?= $(shell pulumictl get version) | ||
PROVIDER_PATH := provider/v3 | ||
VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version | ||
|
||
SCHEMA_FILE := provider/cmd/pulumi-resource-xyz/schema.json | ||
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 | ||
|
||
gen:: | ||
(cd provider && go build -a -o $(WORKING_DIR)/bin/${CODEGEN} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/$(CODEGEN)) | ||
|
||
provider:: | ||
(cd provider && VERSION=${VERSION} go generate cmd/${PROVIDER}/main.go) | ||
(cd provider && go build -a -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER)) | ||
|
||
provider_debug:: | ||
(cd provider && go build -a -o $(WORKING_DIR)/bin/${PROVIDER} -gcflags="all=-N -l" -ldflags "-X ${PROJECT}/${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:: | ||
$(WORKING_DIR)/bin/$(CODEGEN) -version=${DOTNET_VERSION} dotnet $(SCHEMA_FILE) $(CURDIR) | ||
rm -rf sdk/dotnet | ||
cd ${PACKDIR}/dotnet/&& \ | ||
echo "${DOTNET_VERSION}" >version.txt && \ | ||
dotnet build /p:Version=${DOTNET_VERSION} | ||
|
||
go_sdk:: | ||
rm -rf sdk/go | ||
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION} go $(SCHEMA_FILE) $(CURDIR) | ||
|
||
nodejs_sdk:: VERSION := $(shell pulumictl get version --language javascript) | ||
nodejs_sdk:: | ||
rm -rf sdk/nodejs | ||
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION} nodejs $(SCHEMA_FILE) $(CURDIR) | ||
cd ${PACKDIR}/nodejs/ && \ | ||
yarn install && \ | ||
yarn run tsc | ||
cp README.md LICENSE ${PACKDIR}/nodejs/package.json ${PACKDIR}/nodejs/yarn.lock ${PACKDIR}/nodejs/bin/ | ||
sed -i.bak 's/$${VERSION}/$(VERSION)/g' ${PACKDIR}/nodejs/bin/package.json | ||
|
||
python_sdk:: PYPI_VERSION := $(shell pulumictl get version --language python) | ||
python_sdk:: | ||
# Delete only files and folders that are generated. | ||
rm -r sdk/python/pulumi_kubernetes/*/ sdk/python/pulumi_kubernetes/__init__.py | ||
$(WORKING_DIR)/bin/$(CODEGEN) -version=${VERSION} python $(SCHEMA_FILE) $(CURDIR) | ||
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:: gen 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_FAST := go test -short -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM} | ||
GO_TEST := go test -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM} | ||
|
||
test_fast:: | ||
# TODO: re-enable this test once https://github.com/pulumi/pulumi/issues/4954 is fixed. | ||
# ./sdk/nodejs/node_modules/mocha/bin/mocha ./sdk/nodejs/bin/tests | ||
cd provider/pkg && $(GO_TEST_FAST) ./... | ||
cd tests/sdk/nodejs && $(GO_TEST_FAST) ./... | ||
cd tests/sdk/python && $(GO_TEST_FAST) ./... | ||
cd tests/sdk/dotnet && $(GO_TEST_FAST) ./... | ||
cd tests/sdk/go && $(GO_TEST_FAST) ./... | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.