github.com/greenpau/go-authcrunch@v1.0.50/Makefile (about) 1 APP_VERSION:=$(shell cat VERSION | head -1) 2 GIT_COMMIT:=$(shell git describe --dirty --always) 3 GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD -- | head -1) 4 BUILD_USER:=$(shell whoami) 5 BUILD_DATE:=$(shell date +"%Y-%m-%d") 6 VERBOSE:=-v 7 ifdef TEST 8 TEST:="-run ${TEST}" 9 endif 10 11 all: info build 12 @echo "$@: complete" 13 14 .PHONY: info 15 info: 16 @echo "Version: $(APP_VERSION), Branch: $(GIT_BRANCH), Revision: $(GIT_COMMIT)" 17 @echo "Build on $(BUILD_DATE) by $(BUILD_USER)" 18 19 .PHONY: build 20 build: templates 21 @mkdir -p bin/ 22 @rm -rf ./bin/* 23 @versioned -sync ./pkg/identity/database.go 24 @CGO_ENABLED=0 go build -o ./bin/authdbctl $(VERBOSE) \ 25 -ldflags="-w -s \ 26 -X main.appVersion=$(APP_VERSION) \ 27 -X main.gitBranch=$(GIT_BRANCH) \ 28 -X main.gitCommit=$(GIT_COMMIT) \ 29 -X main.buildUser=$(BUILD_USER) \ 30 -X main.buildDate=$(BUILD_DATE)" \ 31 -gcflags="all=-trimpath=$(GOPATH)/src" \ 32 -asmflags="all=-trimpath $(GOPATH)/src" \ 33 cmd/authdbctl/*.go 34 @./bin/authdbctl --version 35 @./bin/authdbctl --help 36 @echo "$@: complete" 37 38 .PHONY: linter 39 linter: 40 @echo "Running lint checks" 41 @golint -set_exit_status ./... 42 @echo "$@: complete" 43 44 .PHONY: gtest 45 gtest: 46 @go test $(VERBOSE) -coverprofile=.coverage/coverage.out ./... 47 @echo "$@: complete" 48 49 .PHONY: test 50 test: templates info covdir linter gtest coverage 51 @echo "$@: complete" 52 53 .PHONY: ctest 54 ctest: templates covdir linter 55 @richgo version || go install github.com/kyoh86/richgo@latest 56 @time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./... 57 @echo "$@: complete" 58 59 .PHONY: covdir 60 covdir: 61 @echo "Creating .coverage/ directory" 62 @mkdir -p .coverage 63 @echo "$@: complete" 64 65 .PHONY: coverage 66 coverage: 67 @#go tool cover -help 68 @go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html 69 @go test -covermode=count -coverprofile=.coverage/coverage.out ./... 70 @go tool cover -func=.coverage/coverage.out | grep -v "100.0" 71 @echo "$@: complete" 72 73 .PHONY: ui-templates 74 ui-templates: 75 @./assets/scripts/generate_ui.sh 76 @echo "$@: complete" 77 78 .PHONY: email-templates 79 email-templates: 80 @./assets/scripts/generate_email_templates.sh 81 @echo "$@: complete" 82 83 .PHONY: templates 84 templates: ui-templates email-templates license 85 @echo "$@: complete" 86 87 .PHONY: docs 88 docs: 89 @mkdir -p .doc 90 @go doc -all > .doc/index.txt 91 @cat .doc/index.txt 92 @echo "$@: complete" 93 94 .PHONY: clean 95 clean: 96 @rm -rf .doc 97 @rm -rf .coverage 98 @rm -rf bin/ 99 @echo "$@: complete" 100 101 .PHONY: qtest 102 qtest: covdir 103 @echo "Perform quick tests ..." 104 @#time richgo test -v -coverprofile=.coverage/coverage.out internal/tag/*.go 105 @#time richgo test -v -coverprofile=.coverage/coverage.out internal/testutils/*.go 106 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/util/data/... 107 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/util/... 108 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewConfig ./*.go 109 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewServer ./*.go 110 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/registry/... 111 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/waf/... 112 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestAuthorize ./pkg/authz/validator/... 113 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestAddProviders ./pkg/messaging/... 114 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/messaging/... 115 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/credentials/... 116 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/errors/... 117 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/requests/... 118 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/... 119 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewPortal ./pkg/authn/*.go 120 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestServeHTTP ./pkg/authn/*.go 121 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestFactory ./pkg/authn/cookie/*.go 122 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewSingleSignOnProviderConfig ./pkg/sso/*.go 123 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewSingleSignOnProvider ./pkg/sso/*.go 124 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestParseRequestURL ./pkg/sso/request*.go 125 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestGetMetadata ./pkg/sso/*.go 126 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestValidateJwksKey ./pkg/authn/backends/oauth2/jwks*.go 127 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestTransformData ./pkg/authn/transformer/*.go 128 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/transformer/*.go 129 @time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/redirects/*.go 130 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/icons/... 131 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/idp/... 132 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/idp/saml/*.go 133 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/idp/oauth/*.go 134 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewJwksKeyFromRSAPublicKeyPEM ./pkg/idp/oauth/*.go 135 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewIdentityProviderConfig ./pkg/idp/*.go 136 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/ui/... 137 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/ids/... 138 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/ids/local/*.go 139 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/ids/ldap/*.go 140 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authz/... 141 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewGatekeeper ./pkg/authz/*.go 142 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestAuthenticate ./pkg/authz/*.go 143 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/util/... 144 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/kms/... 145 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/acl/... 146 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run NewAclRule ./pkg/acl/... 147 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestCustomAccessList ./pkg/acl/... 148 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewAclRuleCondition ./pkg/acl/... 149 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestMatchAclRuleCondition ./pkg/acl/... 150 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/user/... 151 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authproxy/... 152 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/identity/... 153 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/backends/... 154 @#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run NewAPIKey ./pkg/identity/... 155 @# 156 @go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html; 157 @#go tool cover -func=.coverage/coverage.out | grep -v "100.0" 158 @#go tool cover -func=.coverage/coverage.out; 159 @echo "$@: complete" 160 161 .PHONY: dep 162 dep: 163 @echo "Making dependencies check ..." 164 @golint || go install golang.org/x/lint/golint@latest 165 @go install github.com/kyoh86/richgo@latest 166 @versioned || go install github.com/greenpau/versioned/cmd/versioned@latest 167 @echo "$@: complete" 168 169 .PHONY: license 170 license: 171 @versioned || go install github.com/greenpau/versioned/cmd/versioned@latest 172 @for f in `find ./ -type f -name '*.go'`; do versioned -addlicense -copyright="Paul Greenberg greenpau@outlook.com" -year=2022 -filepath=$$f; done 173 @#for f in `find ./ -type f -name '*.go'`; do versioned -striplicense -filepath=$$f; done 174 @echo "$@: complete" 175 176 .PHONY: release 177 release: 178 @echo "Making release" 179 @go mod tidy; 180 @go mod verify; 181 @if [ $(GIT_BRANCH) != "main" ]; then echo "cannot release to non-main branch $(GIT_BRANCH)" && false; fi 182 @git diff-index --quiet HEAD -- || ( echo "git directory is dirty, commit changes first" && false ) 183 @versioned -patch 184 @echo "Patched version" 185 @git add VERSION 186 @versioned -sync ./cmd/authdbctl/main.go 187 @versioned -sync ./pkg/identity/database.go 188 @git add cmd/authdbctl/main.go ./pkg/identity/database.go 189 @git commit -m "released v`cat VERSION | head -1`" 190 @git tag -a v`cat VERSION | head -1` -m "v`cat VERSION | head -1`" 191 @git push 192 @git push --tags