github.com/Venafi/vcert/v5@v5.10.2/Makefile (about)

     1  GOFLAGS ?= $(GOFLAGS:)
     2  
     3  VERSION=`git describe --abbrev=0 --tags`
     4  
     5  ifdef BUILD_NUMBER
     6  VERSION:=$(VERSION)+$(BUILD_NUMBER)
     7  endif
     8  
     9  define cucumber_image_build
    10      rm -rf ./aruba/bin/
    11  	mkdir -p ./aruba/bin/ && cp ./bin/linux/vcert ./aruba/bin/vcert
    12  	docker build --tag vcert.auto aruba/
    13  endef
    14  
    15  export DUMMY_PASS=CyberArkT3stP4ZZC0de%jQX^J=4H
    16  
    17  define cucumber_tests_run
    18      if [ -n "$(FEATURE)" ] && [ -n "$(PLATFORM)" ]; then \
    19  		echo "running cucumber tests for both feature $(FEATURE) and platform $(PLATFORM)"; \
    20  		cd aruba && ./cucumber.sh -a $(FEATURE) -b $(PLATFORM); \
    21  	elif [ -n "$(FEATURE)" ]; then \
    22  		echo "running cucumber tests for feature $(FEATURE)"; \
    23  		cd aruba && ./cucumber.sh -a $(FEATURE); \
    24  	elif [ -n "$(PLATFORM)" ]; then \
    25  		echo "running cucumber tests for platform $(PLATFORM)"; \
    26  		cd aruba && ./cucumber.sh -b $(PLATFORM); \
    27  	else \
    28  		echo "running all cucumber tests"; \
    29  		cd aruba && ./cucumber.sh; \
    30      fi
    31  endef
    32  
    33  ifdef RELEASE_VERSION
    34  ifneq ($(RELEASE_VERSION),none)
    35  VERSION=$(RELEASE_VERSION)
    36  endif
    37  endif
    38  
    39  GO_LDFLAGS=-ldflags "-X github.com/Venafi/vcert/v5.versionString=$(VERSION) -X github.com/Venafi/vcert/v5.versionBuildTimeStamp=`date -u +%Y%m%d.%H%M%S` -s -w"
    40  version:
    41  	echo "$(VERSION)"
    42  
    43  get: gofmt
    44  	go get $(GOFLAGS) ./...
    45  
    46  build_quick: get
    47  	env GOOS=linux   GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/linux/vcert         ./cmd/vcert
    48  
    49  # Note for any future contributor that would like to add a new architecture: keep in mind that we do an internal signing
    50  # for VCert binaries, thus just updating here the new desired architecture won't be enough.
    51  build: get
    52  	env GOOS=linux   GOARCH=arm64 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm       ./cmd/vcert
    53  	env GOOS=linux   GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/linux/vcert           ./cmd/vcert
    54  	env GOOS=linux   GOARCH=386   go build $(GO_LDFLAGS) -o bin/linux/vcert86         ./cmd/vcert
    55  	env GOOS=linux   GOARCH=arm GOARM=5 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm32v5       ./cmd/vcert
    56  	env GOOS=linux   GOARCH=arm GOARM=6 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm32v6       ./cmd/vcert
    57  	env GOOS=linux   GOARCH=arm GOARM=7 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm32v7       ./cmd/vcert
    58  	env GOOS=darwin  GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/darwin/vcert          ./cmd/vcert
    59  	env GOOS=darwin  GOARCH=arm64 go build $(GO_LDFLAGS) -o bin/darwin/vcert_arm      ./cmd/vcert
    60  	env GOOS=windows GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/windows/vcert.exe     ./cmd/vcert
    61  	env GOOS=windows GOARCH=386   go build $(GO_LDFLAGS) -o bin/windows/vcert86.exe   ./cmd/vcert
    62  	env GOOS=windows GOARCH=arm64 go build $(GO_LDFLAGS) -o bin/windows/vcert_arm.exe ./cmd/vcert
    63  
    64  cucumber_build:
    65  	$(call cucumber_image_build)
    66  
    67  cucumber_test:
    68  	$(call cucumber_tests_run)
    69  
    70  cucumber:
    71  	$(call cucumber_image_build)
    72  	$(call cucumber_tests_run)
    73  
    74  gofmt:
    75  	! gofmt -l . | grep -v ^vendor/ | grep .
    76  
    77  test: get linter
    78  	go test -v -coverprofile=cov1.out .
    79  	go tool cover -func=cov1.out
    80  	go test -v -coverprofile=cov2.out ./pkg/certificate
    81  	go tool cover -func=cov2.out
    82  	go test -v -coverprofile=cov3.out ./pkg/endpoint
    83  	go tool cover -func=cov3.out
    84  	go test -v -coverprofile=cov4.out ./pkg/venafi/fake
    85  	go tool cover -func=cov4.out
    86  	go test -v -coverprofile=cov5.out ./pkg/policy
    87  	go tool cover -func=cov5.out
    88  	go test -v -coverprofile=cov6.out ./pkg/util
    89  	go tool cover -func=cov6.out
    90  	go test -v -coverprofile=cov_cmd.out ./cmd/vcert
    91  	go tool cover -func=cov_cmd.out
    92  
    93  tpp_test: get
    94  	go test -v $(GOFLAGS) -coverprofile=cov_tpp.out ./pkg/venafi/tpp
    95  	go tool cover -func=cov_tpp.out
    96  
    97  cloud_test: get
    98  	go test -v $(GOFLAGS) -coverprofile=cov_vaas.out ./pkg/venafi/cloud
    99  	go tool cover -func=cov_vaas.out
   100  
   101  firefly_test: get
   102  	go test -v $(GOFLAGS) -coverprofile=cov_firefly.out ./pkg/venafi/firefly
   103  	go tool cover -func=cov_firefly.out
   104  
   105  cmd_test: get
   106  	go test -v $(GOFLAGS) -coverprofile=cov_cmd.out ./cmd/vcert
   107  	go tool cover -func=cov_cmd.out
   108  
   109  playbook_test: get
   110  	go test -v $(GOFLAGS) -coverprofile=cov_playbook.out ./pkg/playbook/...
   111  	go tool cover -func=cov_playbook.out
   112  
   113  collect_artifacts:
   114  	rm -rf artifacts
   115  	mkdir -p artifacts
   116  	# we are assuming that signature are in the path were the make file was executed (not necessarily should be in the root of project)
   117  	zip -j "artifacts/vcert_$(VERSION)_linux_arm.zip" "bin/linux/vcert_arm" "vcert_linux_arm.sig" || exit 1
   118  	zip -j "artifacts/vcert_$(VERSION)_linux.zip" "bin/linux/vcert" "vcert_linux.sig" || exit 1
   119  	zip -j "artifacts/vcert_$(VERSION)_linux86.zip" "bin/linux/vcert86" "vcert_linux86.sig" || exit 1
   120  	zip -j "artifacts/vcert_$(VERSION)_darwin.zip" "bin/darwin/vcert" "vcert_darwin.sig" || exit 1
   121  	zip -j "artifacts/vcert_$(VERSION)_darwin_arm.zip" "bin/darwin/vcert_arm" "vcert_darwin_arm.sig" || exit 1
   122  	zip -j "artifacts/vcert_$(VERSION)_windows.zip" "bin/windows/vcert.exe" || exit 1
   123  	zip -j "artifacts/vcert_$(VERSION)_windows86.zip" "bin/windows/vcert86.exe" || exit 1
   124  	zip -j "artifacts/vcert_$(VERSION)_windows_arm.zip" "bin/windows/vcert_arm.exe" || exit 1
   125  
   126  release:
   127  	echo '```' > release.txt
   128  	cd artifacts; sha1sum * >> ../release.txt
   129  	echo '```' >> release.txt
   130  	go install github.com/tcnksm/ghr@v0.16.2
   131  	export "PATH=$(PATH):$(shell go env GOPATH)/bin" && ghr -prerelease -n $$RELEASE_VERSION -body="$$(cat ./release.txt)" $$RELEASE_VERSION artifacts/
   132  
   133  linter:
   134  	@golangci-lint --version || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /go/bin
   135  	golangci-lint run --timeout 5m