-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (84 loc) · 3.18 KB
/
Makefile
File metadata and controls
104 lines (84 loc) · 3.18 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
LINUX_TARGETS = linux/amd64 linux/386
VERSION ?= dev
GITHUB_SHA ?= $(shell git rev-parse HEAD)
BUILD_TIME = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n')
GO_VERSION = $(shell go version | awk {'print $$3'})
LDFLAGS = -s -w
PKG = github.com/juandiegopalomino/cloudgrep
DOCKER_RELEASE_TAG = "ghcr.io/run-x/cloudgrep:$(VERSION)"
DOCKER_LATEST_TAG = "ghcr.io/run-x/cloudgrep:main"
THIS_FILE := $(lastword $(MAKEFILE_LIST))
usage:
@echo ""
@echo "Task : Description"
@echo "----------------- : -------------------"
@echo "make awsgen : Generate the AWS provider resource functions"
@echo "make clean : Remove all build files and reset assets"
@echo "make build : Generate build for current OS"
@echo "make format : Format code"
@echo "make frontend-build : Build the frontend assets"
@echo "make frontend-deploy : Deploy the frontend assets"
@echo "make load-test : Execute load test suite"
@echo "make markdown : Generate the markdown files"
@echo "make run : Run using local code"
@echo "make run-demo : Run using local code with demo data"
@echo "make setup : Install all necessary dependencies"
@echo "make test : Execute test suite"
@echo "make version : Show version"
@echo ""
format:
go fmt github.com/run-x/...
lint:
golangci-lint run ./...
test:
go test -race ./hack/... ./pkg/... ./cmd/... ./demo/... -coverprofile=coverage.out -covermode=atomic
load-test:
go clean -testcache && go test ./loadtest/...
pre-commit:
go mod tidy
@$(MAKE) -f $(THIS_FILE) format
@$(MAKE) -f $(THIS_FILE) lint
@$(MAKE) -f $(THIS_FILE) test
run:
go run -race main.go
run-demo:
go run -race main.go demo
version:
@go run -race main.go --version
frontend-build:
docker run -v "$(PWD)/fe":/usr/src/app -w /usr/src/app node:18 npm install
docker run -v "$(PWD)/fe":/usr/src/app -w /usr/src/app node:18 npm run build
frontend-deploy:
rm -rf ./static/css ./static/js ./static/*.ico ./static/*.html ./static/*.txt ./static/*.json ./static/*.png
cp -r ./fe/build/static/css ./static
cp -r ./fe/build/static/js ./static
cp ./fe/build/*.ico ./static
cp ./fe/build/*.html ./static
cp ./fe/build/*.js ./static/js
cp ./fe/build/*.txt ./static
cp ./fe/build/*.json ./static
cp ./fe/build/*.png ./static
build: LDFLAGS += -X $(PKG)/pkg/version.GitCommit=$(GITHUB_SHA)
build: LDFLAGS += -X $(PKG)/pkg/version.BuildTime=$(BUILD_TIME)
build: LDFLAGS += -X $(PKG)/pkg/version.GoVersion=$(GO_VERSION)
build: LDFLAGS += -X $(PKG)/pkg/version.Version=$(VERSION)
build:
go build -race -ldflags "$(LDFLAGS)"
@echo "You can now execute ./cloudgrep"
docker-build:
docker build --no-cache -t $(DOCKER_RELEASE_TAG) .
docker tag $(DOCKER_RELEASE_TAG) $(DOCKER_LATEST_TAG)
docker images $(DOCKER_RELEASE_TAG)
docker-push:
docker push $(DOCKER_RELEASE_TAG)
docker push $(DOCKER_LATEST_TAG)
setup:
go install github.com/mitchellh/gox@v1.0.1
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
clean:
@rm -f ./cloudgrep
@rm -rf ./bin/*
awsgen:
CGO_ENABLED=1 go run -race ./hack/awsgen --config pkg/provider/aws/config/config.yaml --output-dir pkg/provider/aws
markdown:
go run script/markdowngen.go