-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
65 lines (50 loc) · 1.5 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
IMG=ghcr.io/doodlescheduling/flux-build
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
rwildcard=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))
all: lint test build
tidy:
go mod tidy -compat=1.22
fmt:
go fmt ./...
.PHONY: test
test:
go test -race -coverprofile coverage.out -v ./...
.PHONY: e2e-test
e2e-test: build
./flux-build test/e2e/overlay test/e2e/repositories | yq ea '[.] | sort_by(.kind) | .[] | splitDoc' > build.yaml
cmp test/e2e/expected.yaml build.yaml
rm build.yaml
GOLANGCI_LINT = $(GOBIN)/golangci-lint
golangci-lint: ## Download golint locally if necessary.
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/[email protected])
lint: golangci-lint
golangci-lint run --timeout=3m
vet:
go vet ./...
code-gen:
./hack/code-gen.sh
build:
CGO_ENABLED=0 go build -o ./flux-build .
.PHONY: docker-build
docker-build: build
docker build -t ${IMG} .
.PHONY: install
install:
CGO_ENABLED=0 go install .
# go-install-tool will 'go install' any package $2 and install it to $1
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
env -i bash -c "GOBIN=$(GOBIN) PATH=$(PATH) GOPATH=$(shell go env GOPATH) GOCACHE=$(shell go env GOCACHE) go install $(2)" ;\
rm -rf $$TMP_DIR ;\
}
endef