forked from SkynetLabs/malware-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (72 loc) · 3.12 KB
/
Makefile
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
80
81
82
83
84
85
86
87
88
89
# These variables get inserted into ./build/commit.go
BUILD_TIME=$(shell date)
GIT_REVISION=$(shell git rev-parse --short HEAD)
GIT_DIRTY=$(shell git diff-index --quiet HEAD -- || echo "✗-")
ldflags= -X github.com/SkynetLabs/malware-scanner/build.GitRevision=${GIT_DIRTY}${GIT_REVISION} \
-X "github.com/SkynetLabs/malware-scanner/build.BuildTime=${BUILD_TIME}"
racevars= history_size=3 halt_on_error=1 atexit_sleep_ms=2000
# all will build and install release binaries
all: release
# count says how many times to run the tests.
count = 1
# pkgs changes which packages the makefile calls operate on. run changes which
# tests are run during testing.
pkgs = ./ ./api ./database
# fmt calls go fmt on all packages.
fmt:
gofmt -s -l -w $(pkgs)
# vet calls go vet on all packages.
# We don't check composite literals because we need to use unkeyed fields for
# MongoDB's BSONs and that sets vet off.
# NOTE: go vet requires packages to be built in order to obtain type info.
vet:
go vet -composites=false $(pkgs)
# markdown-spellcheck runs codespell on all markdown files that are not
# vendored.
markdown-spellcheck:
pip install codespell 1>/dev/null 2>&1
git ls-files "*.md" :\!:"vendor/**" | xargs codespell --check-filenames
# lint runs golangci-lint (which includes golint, a spellcheck of the codebase,
# and other linters), the custom analyzers, and also a markdown spellchecker.
lint: fmt markdown-spellcheck vet
golangci-lint run -c .golangci.yml
go mod tidy
analyze -lockcheck -- $(pkgs)
# lint-ci runs golint.
lint-ci:
# golint is skipped on Windows.
ifneq ("$(OS)","Windows_NT")
# Linux
go get -d golang.org/x/lint/golint
golint -min_confidence=1.0 -set_exit_status $(pkgs)
go mod tidy
endif
# debug builds and installs debug binaries. This will also install the utils.
debug:
go install -tags='debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
debug-race:
GORACE='$(racevars)' go install -race -tags='debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
# dev builds and installs developer binaries. This will also install the utils.
dev:
go install -tags='dev debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
dev-race:
GORACE='$(racevars)' go install -race -tags='dev debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
# release builds and installs release binaries.
release:
go install -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs)
release-race:
GORACE='$(racevars)' go install -race -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs)
release-util:
go install -tags='netgo' -ldflags='-s -w $(ldflags)' $(release-pkgs) $(util-pkgs)
# check is a development helper that ensures all test files at least build
# without actually running the tests.
check:
go test --exec=true ./...
bench: fmt
go test -tags='debug testing netgo' -timeout=500s -run=XXX -bench=. $(pkgs) -count=$(count)
test:
go test -short -tags='debug testing netgo' -timeout=5s $(pkgs) -run=. -count=$(count)
test-long: lint lint-ci
@mkdir -p cover
GORACE='$(racevars)' go test -race --coverprofile='./cover/cover.out' -v -failfast -tags='testing debug netgo' -timeout=30s $(pkgs) -run=. -count=$(count)
.PHONY: all fmt install release check test test-long