-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (61 loc) · 2.62 KB
/
Makefile
File metadata and controls
80 lines (61 loc) · 2.62 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
PACKNAME=github-repo
BUILD_FLAGS=-X 'main.GitCommitHash=`git rev-parse --short HEAD`' -X 'main.BuiltAt=`date +%FT%T%z`'
BUILD_WIN=@env GOOS=windows GOARCH=amd64 go build -o $(PACKNAME).exe
BUILD_LINUX=@env GOOS=linux GOARCH=amd64 go build -o $(PACKNAME)
BUILD_MAC=@env GOOS=darwin GOARCH=amd64 go build -o $(PACKNAME)-darwin
COVERAGE = $(shell go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+')
release: package release bin
release-candidate: package release-candidate
binary: package build
release: release-nix release-win release-mac
docker-build: release-nix
@echo " > Building docker image ..."
@docker build -t $(PACKNAME) .
docker-run:
@echo " > Running docker image ..."
docker run -it --rm -v ./config.yml:/.privateer/config.yml -v ./docker_output:/evaluation_results $(PACKNAME)
# Pushing to eddieknight docker hub namespace until a more preferred option exists
docker-build-release:
@echo " > Building docker images for linux/amd64 and linux/arm64..."
docker buildx build --platform linux/amd64,linux/arm64 -t eddieknight/pvtr-github-repo:latest .
docker-run-latest:
@echo " > Running docker image ..."
docker pull eddieknight/pvtr-github-repo:latest
docker run -it --rm -v ./config.yml:/.privateer/config.yml -v ./docker_output:/evaluation_results eddieknight/pvtr-github-repo:latest
build:
@echo " > Building binary ..."
@go build -o $(PACKNAME) -ldflags="$(BUILD_FLAGS)"
package: tidy test
@echo " > Packaging static files..."
vet:
@echo " > Validating code ..."
@go vet ./...
test: vet
@go clean -testcache
@go test ./...
tidy:
@echo " > Tidying go.mod ..."
@go mod tidy
test-cov: vet
@echo "Running tests and generating coverage output ..."
@go test ./... -coverprofile coverage.out -covermode count
print-cov:
@echo "Current test coverage : $(COVERAGE)%"
release-candidate: tidy test
@echo " > Building release candidate for Linux..."
$(BUILD_LINUX) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=nix-rc'"
@echo " > Building release candidate for Windows..."
$(BUILD_WIN) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=win-rc'"
@echo " > Building release for Darwin..."
$(BUILD_MAC) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=darwin-rc'"
release-nix:
@echo " > Building release for Linux..."
$(BUILD_LINUX) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=linux'"
release-win:
@echo " > Building release for Windows..."
$(BUILD_WIN) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=windows'"
release-mac:
@echo " > Building release for Darwin..."
$(BUILD_MAC) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=darwin'"
bin:
@mv $(PACKNAME)* ~/privateer/bin