This repository was archived by the owner on Jan 26, 2024. It is now read-only.
forked from fastly/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (60 loc) · 1.85 KB
/
Makefile
File metadata and controls
79 lines (60 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
SHELL := /bin/bash -o pipefail
# the rationale for using both `git describe` and `git rev-parse` is because
# when CI builds the application it can be based on a git tag, so this ensures
# the output is consistent across environments.
VERSION ?= $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD)
TESTARGS ?= ./{cmd,pkg}/...
LDFLAGS = -ldflags "\
-X 'github.com/fastly/cli/pkg/revision.AppVersion=${VERSION}' \
-X 'github.com/fastly/cli/pkg/revision.GitCommit=$(shell git rev-parse --short HEAD || echo unknown)' \
-X 'github.com/fastly/cli/pkg/revision.GoVersion=$(shell go version)' \
"
fastly:
@go build -trimpath $(LDFLAGS) -o "$@" ./cmd/fastly
# useful for attaching a debugger such as https://github.com/go-delve/delve
debug:
@go build -gcflags="all=-N -l" -o "fastly" ./cmd/fastly
.PHONY: all
all: config tidy fmt vet staticcheck lint gosec test build install
.PHONY: dependencies
dependencies:
go get -v -u github.com/securego/gosec/cmd/gosec
go get -v -u honnef.co/go/tools/cmd/staticcheck
go get -v -u golang.org/x/lint/golint
.PHONY: tidy
tidy:
go mod tidy
.PHONY: fmt
fmt:
@echo gofmt -l ./{cmd,pkg}
@eval "bash -c 'F=\$$(gofmt -l ./{cmd,pkg}) ; if [[ \$$F ]] ; then echo \$$F ; exit 1 ; fi'"
.PHONY: vet
vet:
go vet ./{cmd,pkg}/...
.PHONY: gosec
gosec:
gosec -quiet -exclude=G104 ./{cmd,pkg}/...
.PHONY: staticcheck
staticcheck:
staticcheck ./{cmd,pkg}/...
.PHONY: lint
lint:
golint ./{cmd,pkg}/...
.PHONY: test
test: config
go test -race $(TESTARGS)
.PHONY: build
build: config
go build ./cmd/fastly
.PHONY: install
install:
go install ./cmd/fastly
.PHONY: changelog
changelog:
@$(shell pwd)/scripts/changelog.sh
.PHONY: release-changelog
release-changelog:
@$(shell pwd)/scripts/release-changelog.sh
.PHONY: config
config:
@curl -so cmd/fastly/static/config.toml https://developer.fastly.com/api/internal/cli-config