Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (58 loc) · 2.46 KB
/
Copy pathMakefile
File metadata and controls
80 lines (58 loc) · 2.46 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
SHELL := /usr/bin/env bash -o pipefail
.SHELLFLAGS := -ec
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BIN_DIR := $(ROOT_DIR)/bin
GOLANG_VERSION := $(shell sed -En 's/^go (.*)$$/\1/p' "go.mod")
GO_BUILD_TAGS := containers_image_openpgp
# bingo manages consistent tooling versions.
include .bingo/Variables.mk
# Migration-specific build and test targets live separately so this Makefile
# remains the home for repository-wide targets.
include $(ROOT_DIR)/migration.mk
# Output paths for compiled CLI binaries
MIGRATE_OPERATORS_BIN := $(BIN_DIR)/migrate-operators-v0-to-v1
MIGRATE_CATALOGS_BIN := $(BIN_DIR)/migrate-catalogs-v0-to-v1
##@ General
.PHONY: help
help: ## Display this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9\/-]+:.*?##/ { printf " \033[36m%-36s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Build
.PHONY: build
build: build-migrate-operators build-migrate-catalogs ## Build both CLI binaries into bin/
.PHONY: build-migrate-operators
build-migrate-operators: ## Build migrate-operators-v0-to-v1 into bin/
@mkdir -p $(BIN_DIR)
go build -o $(MIGRATE_OPERATORS_BIN) ./migration/examples/cmd/migrate-operators-v0-to-v1
.PHONY: build-migrate-catalogs
build-migrate-catalogs: ## Build migrate-catalogs-v0-to-v1 into bin/
@mkdir -p $(BIN_DIR)
go build -o $(MIGRATE_CATALOGS_BIN) ./migration/examples/cmd/migrate-catalogs-v0-to-v1
.PHONY: build-all
build-all: ## Build and verify all packages (library + CLIs)
go build -tags "$(GO_BUILD_TAGS)" ./...
.PHONY: image/test
image/test: ## Run image package unit tests
go test -tags "$(GO_BUILD_TAGS)" ./image/...
##@ Lint & Verify
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run golangci-lint
$(GOLANGCI_LINT) run --build-tags "$(GO_BUILD_TAGS)" ./...
.PHONY: fmt
fmt: ## Run gofmt
go fmt ./...
.PHONY: vet
vet: ## Run go vet
go vet -tags "$(GO_BUILD_TAGS)" ./...
.PHONY: tidy
tidy: ## Run go mod tidy
go mod tidy
.PHONY: verify
verify: tidy fmt vet lint ## Run all verification steps (tidy, fmt, vet, lint)
@git diff --exit-code || (echo "Files modified by verify — please commit the changes" && exit 1)
.PHONY: api-diff
api-diff: $(GO_APIDIFF) ## Check for breaking API changes against origin/main
$(GO_APIDIFF) origin/main --repo-path=. --print-compatible
##@ Clean
.PHONY: clean
clean: ## Remove built binaries from bin/
rm -f $(MIGRATE_OPERATORS_BIN) $(MIGRATE_CATALOGS_BIN)