generated from pulumi/pulumi-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (71 loc) · 2.45 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
PROJECT_NAME := Pulumi Asd Resource Provider
PACK := asd
PACKDIR := sdk
PROJECT := github.com/dprzybyl/pulumi-asd-native
NODE_MODULE_NAME := @pulumi/asd
NUGET_PKG_NAME := Pulumi.Asd
PROVIDER := pulumi-resource-${PACK}
VERSION ?= $(shell pulumictl get version)
PROVIDER_PATH := provider
VERSION_PATH := ${PROVIDER_PATH}.Version
GOPATH := $(shell go env GOPATH)
WORKING_DIR := $(shell pwd)
EXAMPLES_DIR := ${WORKING_DIR}/examples/yaml
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 ${PROJECT}/${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 ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))
test_provider::
cd tests && go test -short -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM} ./...
go_sdk:: $(WORKING_DIR)/bin/$(PROVIDER)
rm -rf sdk/go
pulumi package gen-sdk $(WORKING_DIR)/bin/$(PROVIDER) --language go
gen_examples: gen_go_example
gen_%_example:
rm -rf ${WORKING_DIR}/examples/$*
pulumi convert \
--cwd ${WORKING_DIR}/examples/yaml \
--logtostderr \
--generate-only \
--non-interactive \
--language $* \
--out ${WORKING_DIR}/examples/$*
define pulumi_login
export PULUMI_CONFIG_PASSPHRASE=asdfqwerty1234; \
pulumi login --local;
endef
up::
$(call pulumi_login) \
cd ${EXAMPLES_DIR} && \
pulumi stack init dev && \
pulumi stack select dev && \
pulumi config set name dev && \
pulumi up -y
down::
$(call pulumi_login) \
cd ${EXAMPLES_DIR} && \
pulumi stack select dev && \
pulumi destroy -y && \
pulumi stack rm dev -y
devcontainer::
git submodule update --init --recursive .devcontainer
git submodule update --remote --merge .devcontainer
cp -f .devcontainer/devcontainer.json .devcontainer.json
.PHONY: build
build:: provider go_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::
cp $(WORKING_DIR)/bin/${PROVIDER} ${GOPATH}/bin
GO_TEST := go test -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM}
test_all:: test_provider
cd tests/sdk/go && $(GO_TEST) ./...