This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
93 lines (75 loc) · 2.56 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
TEST?=$$(go list ./... |grep -v 'vendor')
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
XC_ARCH="386 amd64 arm"
XC_OS="linux darwin windows freebsd openbsd solaris"
XC_EXCLUDE_OSARCH="!darwin/arm !darwin/386"
VERSION=$$(git describe --abbrev=0 --tags)
PWD=$$(pwd)
COMMIT=$$(git rev-parse HEAD)
GOOS=$$(go env GOOS)
GOARCH=$$(go env GOARCH)
default: build
build: fmt
go install
test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | \
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
pkg: fmt
mkdir -p ./pkg
rm -rf ./pkg/*
echo "==> Building..."
CGO_ENABLED=0 gox -os=$(XC_OS) -arch=$(XC_ARCH) \
-osarch=$(XC_EXCLUDE_OSARCH) \
-output ./pkg/terraform-provider-osc_{{.OS}}_{{.Arch}}_$(VERSION)/terraform-provider-osc_$(VERSION) .
bin: fmt
mkdir -p ./bin
echo "==> Building..."
CGO_ENABLED=0 gox -os=$(GOOS) -arch=$(GOARCH) -output ./bin/terraform-provider-osc_$(VERSION) .
chmod 777 ./bin/terraform-provider-osc_$(VERSION)
bin-darwin: fmt
mkdir -p ./bin
echo "==> Building..."
CGO_ENABLED=0 gox -os=darwin -arch=amd64 -output ./bin/terraform-provider-osc_$(VERSION) .
chmod 777 ./bin/terraform-provider-osc_$(VERSION)
vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
fmt:
gofmt -w $(GOFMT_FILES)
test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./aws"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
release:
bash scripts/github-releases.sh
docker-bin: docker-image
docker run \
-v $(PWD)/bin:/go/src/github.com/remijouannet/terraform-provider-osc/bin \
terraform-provider-osc:$(VERSION) bin
docker-bin-darwin: docker-image
docker run \
-v $(PWD)/bin:/go/src/github.com/remijouannet/terraform-provider-osc/bin \
terraform-provider-osc:$(VERSION) bin-darwin
docker-image:
docker build -t terraform-provider-osc:$(VERSION) .
docker-build:
docker run \
-v $(PWD)/pkg:/go/src/github.com/remijouannet/terraform-provider-osc/pkg \
terraform-provider-osc:$(VERSION) pkg
docker-release:
docker run \
-v $(PWD)/pkg:/go/src/github.com/remijouannet/terraform-provider-osc/pkg \
-e "GITHUB_TOKEN=$(GITHUB_TOKEN)" \
terraform-provider-osc:$(VERSION) release
.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile