github.com/blend/go-sdk@v1.20220411.3/Makefile (about)

     1  PREFIX				?= $(shell pwd)
     2  PKGS 					:= $(shell go list ./... | grep -v /vendor/)
     3  SHASUMCMD 		:= $(shell command -v sha1sum || command -v shasum; 2> /dev/null)
     4  TARCMD 				:= $(shell command -v tar || command -v tar; 2> /dev/null)
     5  GIT_REF 			:= $(shell git log --pretty=format:'%h' -n 1)
     6  CURRENT_USER 	:= $(shell whoami)
     7  VERSION 			:= $(shell cat ./VERSION)
     8  
     9  # this is to allow local go-sdk/db tests to pass
    10  DB_PORT 			?= 5432
    11  DB_SSLMODE		?= disable
    12  
    13  export GIT_REF
    14  export VERSION
    15  export DB_SSLMODE
    16  
    17  all: ci
    18  
    19  ci: deps vet profanity copyright test
    20  
    21  new-install: deps dev-deps install-all
    22  
    23  list-deps:
    24  	@go list -f '{{ join .Imports "\n" }}' ./... | egrep "github.com|golang.org" | grep -v "github.com/blend/go-sdk" | sort | uniq
    25  
    26  deps:
    27  	@go get ./...
    28  
    29  dev-deps:
    30  	@go install golang.org/x/lint/golint@latest
    31  	@go install github.com/goreleaser/goreleaser@latest
    32  
    33  install-all: install-ask install-copyright install-coverage install-profanity install-reverseproxy install-recover install-semver install-shamir install-template
    34  
    35  install-ask:
    36  	@go install github.com/blend/go-sdk/cmd/ask
    37  
    38  install-copyright:
    39  	@go install github.com/blend/go-sdk/cmd/copyright
    40  
    41  install-coverage:
    42  	@go install github.com/blend/go-sdk/cmd/coverage
    43  
    44  install-profanity:
    45  	@go install github.com/blend/go-sdk/cmd/profanity
    46  
    47  install-reverseproxy:
    48  	@go install github.com/blend/go-sdk/cmd/reverseproxy
    49  
    50  install-recover:
    51  	@go install github.com/blend/go-sdk/cmd/recover
    52  
    53  install-semver:
    54  	@go install github.com/blend/go-sdk/cmd/semver
    55  
    56  install-shamir:
    57  	@go install github.com/blend/go-sdk/cmd/shamir
    58  
    59  install-template:
    60  	@go install github.com/blend/go-sdk/cmd/template
    61  
    62  release-binaries: release-ask release-copyright release-coverage release-profanity release-reverseproxy release-recover release-semver release-shamir release-template
    63  
    64  release-ask:
    65  	@goreleaser ./.goreleaser/ask.yml
    66  
    67  release-copyright:
    68  	@goreleaser ./.goreleaser/copyright.yml
    69  
    70  release-coverage:
    71  	@goreleaser ./.goreleaser/coverage.yml
    72  
    73  release-profanity:
    74  	@goreleaser ./.goreleaser/profanity.yml
    75  
    76  release-reverseproxy:
    77  	@goreleaser ./.goreleaser/reverseproxy.yml
    78  
    79  release-recover:
    80  	@goreleaser ./.goreleaser/recover.yml
    81  
    82  release-semver:
    83  	@goreleaser ./.goreleaser/semver.yml
    84  
    85  release-shamir:
    86  	@goreleaser ./.goreleaser/shamir.yml
    87  
    88  release-template:
    89  	@goreleaser ./.goreleaser/template.yml
    90  
    91  format:
    92  	@echo "$(VERSION)/$(GIT_REF) >> formatting code"
    93  	@go fmt $(PKGS)
    94  
    95  vet:
    96  	@echo "$(VERSION)/$(GIT_REF) >> vetting code"
    97  	@go vet $(PKGS)
    98  
    99  lint:
   100  	@echo "$(VERSION)/$(GIT_REF) >> linting code"
   101  	@golint $(PKGS)
   102  
   103  generate:
   104  	@echo "$(VERSION)/$(GIT_REF) >> generating code"
   105  	@go generate $(PKGS)
   106  
   107  build:
   108  	@echo "$(VERSION)/$(GIT_REF) >> linting code"
   109  	@docker build . -t go-sdk:$(GIT_REF)
   110  	@docker run go-sdk:$(GIT_REF)
   111  
   112  .PHONY: profanity
   113  profanity:
   114  	@echo "$(VERSION)/$(GIT_REF) >> profanity"
   115  	@go run cmd/profanity/main.go --rules ".profanity.yml" --exclude-dir="cmd/*" --exclude-file="coverage.html" --exclude-dir="dist/*" --include-file="*.go" --exclude-dir="*/node_modules/*" --exclude-dir="vendor/*" --exclude-dir="examples/*" --verbose
   116  
   117  .PHONY: copyright 
   118  copyright:
   119  	@echo "$(VERSION)/$(GIT_REF) >> copyright"
   120  	@go run cmd/copyright/main.go --restrictions-open-source
   121  
   122  test:
   123  	@echo "$(VERSION)/$(GIT_REF) >> tests"
   124  	@go test $(PKGS) -timeout 15s
   125  
   126  test-race:
   127  	@echo "$(VERSION)/$(GIT_REF) >> tests"
   128  	@go test $(PKGS) -timeout 15s -race
   129  
   130  test-verbose:
   131  	@echo "$(VERSION)/$(GIT_REF) >> tests"
   132  	@go test -v $(PKGS) -timeout 15s -race
   133  
   134  cover:
   135  	@echo "$(VERSION)/$(GIT_REF) >> coverage"
   136  	@go run cmd/coverage/main.go --exclude="examples/*,cmd/*" --timeout="30s" --race
   137  
   138  cover-ci:
   139  	@echo "$(VERSION)/$(GIT_REF) >> coverage"
   140  	@go run cmd/coverage/main.go --keep-coverage-out --covermode=atomic --coverprofile=coverage.txt --exclude="examples/*,cmd/*" --timeout="30s"
   141  
   142  clean: clean-dist clean-coverage clean-cache
   143  
   144  clean-coverage:
   145  	@echo "Cleaning COVERAGE files"
   146  	@find . -name "COVERAGE" -exec rm {} \;
   147  
   148  clean-cache:
   149  	@go clean ./...
   150  
   151  clean-dist:
   152  	@rm -rf dist
   153  
   154  push: 
   155  	@echo "Tagging $(VERSION)"
   156  	@git add .
   157  	@git commit -am 'Updates from Blend'
   158  	@git tag -f $(VERSION)
   159  	@git push -f origin $(VERSION)
   160  	@git push -f origin HEAD
   161  
   162  push-verified: 
   163  	@echo "Tagging $(VERSION)"
   164  	@git add .
   165  	@git commit -S -am 'Updates from Blend'
   166  	@git tag -f $(VERSION)
   167  	@git push -f origin $(VERSION)
   168  	@git push -f origin HEAD