forked from jfrog/terraform-provider-artifactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
67 lines (53 loc) · 2.67 KB
/
GNUmakefile
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
TEST?=./...
TARGET_ARCH=$(shell go env GOOS)_$(shell go env GOARCH)
PKG_NAME=pkg/artifactory
PKG_VERSION_PATH=github.com/jfrog/terraform-provider-artifactory/${PKG_NAME}
VERSION := $(shell git tag --sort=-creatordate | head -1 | sed -n 's/v\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1.\2.\3/p')
NEXT_VERSION := $(shell echo ${VERSION}| awk -F '.' '{print $$1 "." $$2 "." $$3 +1 }' )
BUILD_PATH=terraform.d/plugins/registry.terraform.io/jfrog/artifactory/${NEXT_VERSION}/${TARGET_ARCH}
default: build
install:
mkdir -p ${BUILD_PATH} && \
(test -f terraform-provider-artifactory || go build -ldflags="-X '${PKG_VERSION_PATH}.Version=${NEXT_VERSION}'") && \
mv terraform-provider-artifactory ${BUILD_PATH} && \
rm -f .terraform.lock.hcl && \
sed -i.bak 's/version = ".*"/version = "${NEXT_VERSION}"/' sample.tf && rm sample.tf.bak && \
terraform init
clean:
rm -fR .terraform.d/ .terraform terraform.tfstate* terraform.d/ .terraform.lock.hcl
release:
@git tag ${NEXT_VERSION} && git push --mirror
@echo "Pushed ${NEXT_VERSION}"
GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/jfrog/terraform-provider-artifactory@v${NEXT_VERSION}
@echo "Updated pkg cache"
update_pkg_cache:
GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/jfrog/terraform-provider-artifactory@v${VERSION}
build: fmtcheck
go build -ldflags="-X '${PKG_VERSION_PATH}.Version=${NEXT_VERSION}'"
debug_install:
mkdir -p ${BUILD_PATH} && \
(test -f terraform-provider-artifactory || go build -gcflags "all=-N -l" -ldflags="-X '${PKG_VERSION_PATH}.Version=${NEXT_VERSION}-develop'") && \
mv terraform-provider-artifactory ${BUILD_PATH} && \
rm .terraform.lock.hcl && \
sed -i.bak 's/version = ".*"/version = "${NEXT_VERSION}"/' sample.tf && rm sample.tf.bak && \
terraform init
test:
@echo "==> Starting unit tests"
go test $(TEST) -timeout=30s -parallel=4
attach:
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient attach $$(pgrep terraform-provider-artifactory)
acceptance: fmtcheck
export TF_ACC=true && \
test -n ARTIFACTORY_USERNAME && test -n ARTIFACTORY_PASSWORD && test -n ARTIFACTORY_URL \
&& go test -ldflags="-X '${PKG_VERSION_PATH}.Version=${NEXT_VERSION}-test'" -v -parallel 20 -timeout 20m ./pkg/...
acceptance_federated:
export TF_ACC=true && \
go test -v -run TestAccFederatedRepo ./pkg/...
fmt:
@echo "==> Fixing source code with gofmt..."
@gofmt -s -w ./$(PKG_NAME)
(command -v goimports &> /dev/null || go get golang.org/x/tools/cmd/goimports) && goimports -w pkg/artifactory
fmtcheck:
@echo "==> Checking that code complies with gofmt requirements..."
@sh -c "find . -name '*.go' -not -name '*vendor*' -print0 | xargs -0 gofmt -l -s"
.PHONY: build fmt