-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
106 lines (80 loc) · 3.52 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
97
98
99
100
101
102
103
104
105
106
GOBASE=$(shell pwd)
GOBIN=$(GOBASE)/bin
GO_BUILD_FLAGS := ${GO_BUILD_FLAGS}
ROOT_DIR := $(or ${ROOT_DIR},$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
TIMEOUT ?= 30m
VERBOSE ?= false
.EXPORT_ALL_VARIABLES:
all: build
help:
@echo "Targets:"
@echo " generate: regenerate all generated files"
@echo " tidy: tidy go mod"
@echo " lint: run golangci-lint"
@echo " build: run all builds"
@echo " integration-test: run integration tests"
@echo " unit-test: run unit tests"
@echo " test: run all tests"
@echo " deploy: deploy flightctl-server and db as pods in kind"
@echo " deploy-db: deploy only the database as a container, for testing"
@echo " clean: clean up all containers and volumes"
@echo " cluster: create a kind cluster and load the flightctl-server image"
@echo " clean-cluster: kill the kind cluster only"
@echo " rpm/deb: generate rpm or debian packages"
generate:
go generate -v $(shell go list ./...)
hack/mockgen.sh
tidy:
git ls-files go.mod '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && go mod tidy'
lint: tools
$(GOBIN)/golangci-lint run -v
build: bin
go build -buildvcs=false $(GO_BUILD_FLAGS) -o $(GOBIN) ./cmd/...
# rebuild container only on source changes
bin/.flightctl-server-container: bin Containerfile go.mod go.sum $(shell find ./ -name "*.go" -not -path "./bin/*" -not -path "./packaging/*")
mkdir -p $${HOME}/go/flightctl-go-cache
podman build -f Containerfile -v $${HOME}/go/flightctl-go-cache:/opt/app-root/src/go:Z -t flightctl-server:latest
touch bin/.flightctl-server-container
flightctl-server-container: bin/.flightctl-server-container
bin:
mkdir -p bin
# only trigger the rpm build when not built before or changes happened to the codebase
bin/.rpm: bin $(shell find ./ -name "*.go" -not -path "./packaging/*") packaging/rpm/flightctl-agent.spec packaging/systemd/flightctl-agent.service hack/build_rpms.sh
./hack/build_rpms.sh
touch bin/.rpm
rpm: bin/.rpm
.PHONY: rpm
# cross-building for deb pkg
bin/amd64:
GOARCH=amd64 go build -buildvcs=false $(GO_BUILD_FLAGS) -o $@/flightctl ./cmd/flightctl/...
GOARCH=amd64 go build -buildvcs=false $(GO_BUILD_FLAGS) -o $@/flightctl-agent ./cmd/flightctl-agent/...
bin/arm64:
GOARCH=arm64 go build -buildvcs=false $(GO_BUILD_FLAGS) -o $@/flightctl ./cmd/flightctl/...
GOARCH=arm64 go build -buildvcs=false $(GO_BUILD_FLAGS) -o $@/flightctl-agent ./cmd/flightctl-agent/...
bin/riscv64:
GOARCH=riscv64 go build -buildvcs=false $(GO_BUILD_FLAGS) -o $@/flightctl ./cmd/flightctl/...
GOARCH=riscv64 go build -buildvcs=false $(GO_BUILD_FLAGS) -o $@/flightctl-agent ./cmd/flightctl-agent/...
# made as phony targets to make sure they are always rebuilt
.PHONY: bin/arm64 bin/amd64 bin/riscv64
deb-sources: bin/arm64 bin/amd64 bin/riscv64
ln -f -s packaging/debian debian
debuild -us -uc -S
deb: bin/arm64 bin/amd64 bin/riscv64
ln -f -s packaging/debian debian
debuild -us -uc -b
clean: clean-agent-vm
- kind delete cluster
- podman-compose -f deploy/podman/compose.yaml down
- rm -r ~/.flightctl
- rm -f -r bin
- rm -f -r $(shell uname -m)
- rm -f -r obj-*-linux-gnu
- rm -f -r debian
.PHONY: tools flightctl-server-container
tools: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.54.0
# include the deployment targets
include deploy/deploy.mk
include deploy/agent-vm.mk
include test/test.mk