github.com/fastly/go-fastly/v5@v5.3.0/Makefile (about) 1 SHELL := /bin/bash -o pipefail 2 3 # List of tests to run 4 FILES ?= ./... 5 6 # List all our actual files, excluding vendor 7 GOPKGS ?= $(shell go list $(FILES) | grep -v /vendor/) 8 GOFILES ?= $(shell find . -name '*.go' | grep -v /vendor/) 9 10 # Tags specific for building 11 GOTAGS ?= 12 13 # Number of procs to use 14 GOMAXPROCS ?= 4 15 16 NAME := $(notdir $(shell pwd)) 17 18 # Test Service ID 19 FASTLY_TEST_SERVICE_ID ?= 20 FASTLY_API_KEY ?= 21 22 all: mod-download dev-dependencies tidy fmt fiximports test vet staticcheck ## Runs all of the required cleaning and verification targets. 23 .PHONY: all 24 25 tidy: ## Cleans the Go module. 26 @echo "==> Tidying module" 27 @go mod tidy 28 .PHONY: tidy 29 30 mod-download: ## Downloads the Go module. 31 @echo "==> Downloading Go module" 32 @go mod download 33 .PHONY: mod-download 34 35 dev-dependencies: ## Downloads the necessesary dev dependencies. 36 @echo "==> Downloading development dependencies" 37 @go install honnef.co/go/tools/cmd/staticcheck 38 @go install golang.org/x/tools/cmd/goimports 39 .PHONY: dev-dependencies 40 41 test: ## Runs the test suite with VCR mocks enabled. 42 @echo "==> Testing ${NAME}" 43 @go test -timeout=30s -parallel=20 -tags="${GOTAGS}" ${GOPKGS} ${TESTARGS} 44 .PHONY: test 45 46 test-race: ## Runs the test suite with the -race flag to identify race conditions, if they exist. 47 @echo "==> Testing ${NAME} (race)" 48 @go test -timeout=60s -race -tags="${GOTAGS}" ${GOPKGS} ${TESTARGS} 49 .PHONY: test-race 50 51 test-full: ## Runs the tests with VCR disabled (i.e., makes external calls). 52 @echo "==> Testing ${NAME} with VCR disabled" 53 @VCR_DISABLE=1 \ 54 bash -c \ 55 'go test -timeout=60s -parallel=20 ${GOPKGS} ${TESTARGS}' 56 .PHONY: test-full 57 58 fix-fixtures: ## Updates test fixtures with a specified default service ID. 59 @echo "==> Updating fixtures" 60 @$(shell pwd)/scripts/fixFixtures.sh ${FASTLY_TEST_SERVICE_ID} 61 .PHONY: fix-fixtures 62 63 check-imports: ## A check which lists improperly-formatted imports, if they exist. 64 @$(shell pwd)/scripts/check-imports.sh 65 .PHONY: check-imports 66 67 check-fmt: ## A check which lists improperly-formatted files, if they exist. 68 @$(shell pwd)/scripts/check-gofmt.sh 69 .PHONY: check-fmt 70 71 check-mod: ## A check which lists extraneous dependencies, if they exist. 72 @$(shell pwd)/scripts/check-mod.sh 73 .PHONY: check-mod 74 75 fiximports: ## Properly formats and orders imports. 76 @echo "==> Fixing imports" 77 @goimports -w {fastly,tools} 78 .PHONY: fiximports 79 80 fmt: ## Properly formats Go files and orders dependencies. 81 @echo "==> Running gofmt" 82 @gofmt -s -w ${GOFILES} 83 .PHONY: fmt 84 85 vet: ## Identifies common errors. 86 @echo "==> Running go vet" 87 @go vet ./... 88 .PHONY: vet 89 90 staticcheck: ## Runs the staticcheck linter. 91 @echo "==> Running staticcheck" 92 @staticcheck ./... 93 .PHONY: staticcheck 94 95 .PHONY: help 96 help: ## Prints this help menu. 97 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'