github.com/opendevstack/tailor@v1.3.5-0.20220119161809-cab064e60a67/Makefile (about)

     1  SHELL = /bin/bash
     2  .SHELLFLAGS := -eu -o pipefail -c
     3  .DELETE_ON_ERROR:
     4  MAKEFLAGS += --warn-undefined-variables
     5  MAKEFLAGS += --no-builtin-rules
     6  
     7  ## Run unit tests.
     8  test-unit: imports
     9  	@(go list ./... | grep -v "vendor/" | grep -v "e2e" | xargs -n1 go test -cover)
    10  .PHONY: test-unit
    11  
    12  ## Run E2E tests (real binary against temporal, unique project in real cluster).
    13  test-e2e: imports internal/test/e2e/tailor-test
    14  	@(go test -v -cover -timeout 20m github.com/opendevstack/tailor/internal/test/e2e)
    15  .PHONY: test-e2e
    16  
    17  ## Run all tests.
    18  test: test-unit test-e2e
    19  .PHONY: test
    20  
    21  ## Run goimports.
    22  imports:
    23  	@(goimports -w .)
    24  .PHONY: imports
    25  
    26  ## Run gofmt.
    27  fmt:
    28  	@(gofmt -w .)
    29  .PHONY: fmt
    30  
    31  ## Run golangci-lint.
    32  lint:
    33  	@(go mod download && golangci-lint run)
    34  .PHONY: lint
    35  
    36  ## Install binary on current platform.
    37  install: imports
    38  	@(cd cmd/tailor && go install -gcflags "all=-trimpath=$(CURDIR);$(shell go env GOPATH)")
    39  .PHONY: install
    40  
    41  ## Build binaries for all supported platforms.
    42  build: imports build-linux build-darwin build-windows
    43  .PHONY: build
    44  
    45  ## Build Linux binary.
    46  build-linux: imports
    47  	cd cmd/tailor && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -gcflags "all=-trimpath=$(CURDIR);$(shell go env GOPATH)" -o tailor-linux-amd64
    48  .PHONY: build-linux
    49  
    50  ## Build macOS binary.
    51  build-darwin: imports
    52  	cd cmd/tailor && GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -gcflags "all=-trimpath=$(CURDIR);$(shell go env GOPATH)" -o tailor-darwin-amd64
    53  .PHONY: build-darwin
    54  
    55  ## Build Windows binary.
    56  build-windows: imports
    57  	cd cmd/tailor && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -gcflags "all=-trimpath=$(CURDIR);$(shell go env GOPATH)" -o tailor-windows-amd64.exe
    58  .PHONY: build-windows
    59  
    60  internal/test/e2e/tailor-test: cmd/tailor/main.go go.mod go.sum pkg/cli/* pkg/commands/* pkg/openshift/* pkg/utils/*
    61  	@(echo "Generating E2E test binary ...")
    62  	@(cd cmd/tailor && go build -gcflags "all=-trimpath=$(CURDIR);$(shell go env GOPATH)" -o ../../internal/test/e2e/tailor-test)
    63  
    64  ### HELP
    65  ### Based on https://gist.github.com/prwhite/8168133#gistcomment-2278355.
    66  help:
    67  	@echo ''
    68  	@echo 'Usage:'
    69  	@echo '  make <target>'
    70  	@echo ''
    71  	@echo 'Targets:'
    72  	@awk '/^[a-zA-Z\-\_0-9]+:|^# .*/ { \
    73  		helpMessage = match(lastLine, /^## (.*)/); \
    74  		if (helpMessage) { \
    75  			helpCommand = substr($$1, 0, index($$1, ":")-1); \
    76  			helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
    77  			printf "  %-35s %s\n", helpCommand, helpMessage; \
    78  		} else { \
    79  			printf "\n"; \
    80  		} \
    81  	} \
    82  	{ lastLine = $$0 }' $(MAKEFILE_LIST)
    83  .PHONY: help