-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
71 lines (53 loc) · 1.56 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
VERSION ?= 0.0.2
CONTAINER_MANAGER ?= podman
# Image URL to use all building/pushing image targets
IMG ?= quay.io/crcont/crc-cloud:v${VERSION}
# Go and compilation related variables
GOPATH ?= $(shell go env GOPATH)
BUILD_DIR ?= out
SOURCE_DIRS = cmd pkg
# https://golang.org/cmd/link/
LDFLAGS := $(VERSION_VARIABLES) ${GO_EXTRA_LDFLAGS}
GCFLAGS := all=-N -l
# Add default target
.PHONY: default
default: install
# Create and update the vendor directory
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
.PHONY: check
check: build test lint
# Start of the actual build targets
.PHONY: install
install: $(SOURCES)
go install -ldflags="$(LDFLAGS)" $(GO_EXTRA_BUILDFLAGS) ./cmd
$(BUILD_DIR)/crc-cloud: $(SOURCES)
GOOS=linux GOARCH=amd64 go build -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/crc-cloud $(GO_EXTRA_BUILDFLAGS) ./cmd
.PHONY: build
build: clean $(BUILD_DIR)/crc-cloud
.PHONY: test
test:
go test -race --tags build -v -ldflags="$(VERSION_VARIABLES)" ./pkg/... ./cmd/...
.PHONY: clean ## Remove all build artifacts
clean:
rm -rf $(BUILD_DIR)
rm -f $(GOPATH)/bin/crc-cloud
.PHONY: fmt
fmt:
@gofmt -l -w $(SOURCE_DIRS)
$(GOPATH)/bin/golangci-lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
# Run golangci-lint against code
.PHONY: lint
lint: $(GOPATH)/bin/golangci-lint
$(GOPATH)/bin/golangci-lint run
# Build the container image
.PHONY: oci-build
oci-build:
${CONTAINER_MANAGER} build -t ${IMG} -f oci/Containerfile .
# Push the container image
.PHONY: oci-push
container-push:
${CONTAINER_MANAGER} push ${IMG}