github.com/greenpau/go-authcrunch@v1.1.4/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 $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/tagging/...
   105  	@#time richgo test -v -coverprofile=.coverage/coverage.out internal/tag/*.go
   106  	@#time richgo test -v -coverprofile=.coverage/coverage.out internal/testutils/*.go
   107  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/util/data/...
   108  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/util/...
   109  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewConfig ./*.go
   110  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewServer ./*.go
   111  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/registry/...
   112  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/waf/...
   113  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestAuthorize ./pkg/authz/validator/...
   114  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out  -run TestAddProviders ./pkg/messaging/...
   115  	@time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/messaging/...
   116  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/credentials/...
   117  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/errors/...
   118  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/requests/...
   119  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/...
   120  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewPortal ./pkg/authn/*.go
   121  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestServeHTTP ./pkg/authn/*.go
   122  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestFactory ./pkg/authn/cookie/*.go
   123  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewSingleSignOnProviderConfig ./pkg/sso/*.go
   124  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewSingleSignOnProvider ./pkg/sso/*.go
   125  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestParseRequestURL ./pkg/sso/request*.go
   126  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestGetMetadata ./pkg/sso/*.go
   127  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestValidateJwksKey ./pkg/authn/backends/oauth2/jwks*.go
   128  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestTransformData ./pkg/authn/transformer/*.go
   129  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/transformer/*.go
   130  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/redirects/*.go
   131  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/icons/...
   132  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/idp/...
   133  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/idp/saml/*.go
   134  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/idp/oauth/*.go
   135  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewJwksKeyFromRSAPublicKeyPEM ./pkg/idp/oauth/*.go
   136  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewIdentityProviderConfig ./pkg/idp/*.go
   137  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/ui/...
   138  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/ids/...
   139  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/ids/local/*.go
   140  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/ids/ldap/*.go
   141  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authz/...
   142  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewGatekeeper ./pkg/authz/*.go
   143  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestAuthenticate ./pkg/authz/*.go
   144  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/util/...
   145  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/kms/...
   146  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/acl/...
   147  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run NewAclRule ./pkg/acl/...
   148  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestCustomAccessList ./pkg/acl/...
   149  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestNewAclRuleCondition ./pkg/acl/...
   150  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run TestMatchAclRuleCondition ./pkg/acl/...
   151  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/user/...
   152  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authproxy/...
   153  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/identity/...
   154  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/authn/backends/...
   155  	@#time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out -run NewPublicKey ./pkg/identity/...
   156  	@#
   157  	@go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html;
   158  	@#go tool cover -func=.coverage/coverage.out | grep -v "100.0"
   159  	@#go tool cover -func=.coverage/coverage.out;
   160  	@echo "$@: complete"
   161  
   162  .PHONY: dep
   163  dep:
   164  	@echo "Making dependencies check ..."
   165  	@golint || go install golang.org/x/lint/golint@latest
   166  	@go install github.com/kyoh86/richgo@latest
   167  	@versioned || go install github.com/greenpau/versioned/cmd/versioned@latest
   168  	@echo "$@: complete"
   169  
   170  .PHONY: license
   171  license:
   172  	@versioned || go install github.com/greenpau/versioned/cmd/versioned@latest
   173  	@for f in `find ./ -type f -name '*.go'`; do versioned -addlicense -copyright="Paul Greenberg greenpau@outlook.com" -year=2022 -filepath=$$f; done
   174  	@#for f in `find ./ -type f -name '*.go'`; do versioned -striplicense -filepath=$$f; done
   175  	@echo "$@: complete"
   176  
   177  .PHONY: release
   178  release:
   179  	@echo "Making release"
   180  	@go mod tidy;
   181  	@go mod verify;
   182  	@if [ $(GIT_BRANCH) != "main" ]; then echo "cannot release to non-main branch $(GIT_BRANCH)" && false; fi
   183  	@git diff-index --quiet HEAD -- || ( echo "git directory is dirty, commit changes first" && false )
   184  	@versioned -patch
   185  	@echo "Patched version"
   186  	@git add VERSION
   187  	@versioned -sync ./cmd/authdbctl/main.go
   188  	@versioned -sync ./pkg/identity/database.go
   189  	@git add cmd/authdbctl/main.go ./pkg/identity/database.go
   190  	@git commit -m "released v`cat VERSION | head -1`"
   191  	@git tag -a v`cat VERSION | head -1` -m "v`cat VERSION | head -1`"
   192  	@git push
   193  	@git push --tags