forked from tenable/terrascan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (65 loc) · 1.92 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
90
91
92
93
94
95
96
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
BUILD_FLAGS := -v -ldflags "-w -s"
BUILD_DIR = ./bin
BINARY_NAME = terrascan
# default
default: help
# please keep the commands in lexicographical order
help:
@echo "usage: make [command]\ncommands:"
@echo "build\n\tbuild terrascan binary"
@echo "cicd\n\tsimulate CI/CD pipeline locally"
@echo "clean\n\tclean up build"
@echo "docker-build\n\tbuild terrascan docker image"
@echo "docker-push\n\tpush terrascan docker image"
@echo "docker-push-latest\n\tpush terrascan docker image with latest tag"
@echo "gofmt\n\tvalidate gofmt"
@echo "golint\n\tvalidate golint"
@echo "gomodverify\n\tverify go modules"
@echo "govet\n\tvalidate govet"
@echo "staticcheck\n\trun static code analysis"
@echo "test\n\texecute unit and integration tests"
@echo "unit-tests\n\texecute unit tests"
@echo "validate\n\trun all validations"
# build terrascan binary
build: clean
@mkdir -p $(BUILD_DIR) > /dev/null
@export GO111MODULE=on
go build ${BUILD_FLAGS} -o ${BUILD_DIR}/${BINARY_NAME} cmd/terrascan/main.go
@echo "binary created at ${BUILD_DIR}/${BINARY_NAME}"
# clean build
clean:
@rm -rf $(BUILD_DIR)
# run all cicd steps
cicd: validate build test docker-build
# run all unit and integration tests
test: unit-tests
# run all validation tests
validate: gofmt govet golint gomodverify staticcheck
# gofmt validation
gofmt:
./scripts/validate-gofmt.sh
# golint validation
golint:
./scripts/validate-golint.sh
# govet validation
govet:
./scripts/validate-govet.sh
# go mod validation
gomodverify:
go mod verify
# static code analysis
staticcheck:
./scripts/staticcheck.sh
# run unit tests
unit-tests:
./scripts/generate-coverage.sh
# build terrascan docker image
docker-build:
./scripts/docker-build.sh
# push terrascan docker image
docker-push:
./scripts/docker-push.sh
# push latest terrascan docker image
docker-push-latest:
./scripts/docker-push-latest.sh