-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
114 lines (99 loc) · 5.27 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
107
108
109
110
111
112
113
114
# ---------------------------------------------------------------------------- #
# Apache 2.0 License Copyright © 2023 The Aurae Authors #
# #
# +--------------------------------------------+ #
# | █████╗ ██╗ ██╗██████╗ █████╗ ███████╗ | #
# | ██╔══██╗██║ ██║██╔══██╗██╔══██╗██╔════╝ | #
# | ███████║██║ ██║██████╔╝███████║█████╗ | #
# | ██╔══██║██║ ██║██╔══██╗██╔══██║██╔══╝ | #
# | ██║ ██║╚██████╔╝██║ ██║██║ ██║███████╗ | #
# | ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ | #
# +--------------------------------------------+ #
# #
# Distributed Systems Runtime #
# #
# ---------------------------------------------------------------------------- #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# #
# ---------------------------------------------------------------------------- #
GORELEASER_FLAGS ?= --snapshot --rm-dist
all: compile check-format lint test
# Variables and Settings
version ?= 0.0.1
target ?= ae
org ?= aurae-runtime
authorname ?= The Aurae Authors
authoremail ?= [email protected]
license ?= Apache2
year ?= 2023
copyright ?= Copyright (c) $(year)
COMMIT := $(shell git rev-parse HEAD)
DATE := $(shell date +%Y-%m-%d)
PKG_LDFLAGS := github.com/prometheus/common/version
compile: mod proto ## Compile for the local architecture ⚙
@echo "Compiling..."
go build -ldflags "\
-X 'main.Version=$(version)' \
-X 'main.AuthorName=$(authorname)' \
-X 'main.AuthorEmail=$(authoremail)' \
-X 'main.Copyright=$(copyright)' \
-X 'main.License=$(license)' \
-X 'main.Name=$(target)' \
-X '${PKG_LDFLAGS}.Version=$(version)' \
-X '${PKG_LDFLAGS}.BuildDate=$(DATE)' \
-X '${PKG_LDFLAGS}.Revision=$(COMMIT)'" \
-o bin/$(target) .
.PHONY: goreleaser
goreleaser: ## Run goreleaser directly at the pinned version 🛠
go run github.com/goreleaser/[email protected] $(GORELEASER_FLAGS)
.PHONY: mod
mod: proto ## Go mod things
go mod tidy
go mod vendor
go mod download
.PHONY: install
install: compile test ## Install the program to /usr/bin 🎉
@echo "Installing..."
sudo cp bin/$(target) /usr/local/bin/$(target)
.PHONY: test
test: compile ## 🤓 Run go tests
@echo "Testing..."
go test -v ./...
.PHONY: clean
clean: ## Clean your artifacts 🧼
@echo "Cleaning..."
rm -rvf dist/*
rm -rvf release/*
rm -rvf pkg/api/
.PHONY: help
help: ## Show help messages for make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: format
format: ## Format the code using gofmt
@echo "Formatting..."
@gofmt -s -w $(shell find . -name '*.go' -not -path "./vendor/*")
.PHONY: check-format
check-format: ## Used by CI to check if code is formatted
@gofmt -l $(shell find . -name '*.go' -not -path "./vendor/*") | grep ".*" ; if [ $$? -eq 0 ]; then exit 1; fi
.PHONY: lint
lint: ## Runs the linter
golangci-lint run
.PHONY: check-editorconfig
check-editorconfig: ## Use to check if the codebase follows editorconfig rules
@docker run --rm --volume=$(shell PWD):/check mstruebing/editorconfig-checker
# TODO: run this conditionally. see aurae-runtime/aurae for how to do this.
.PHONY: proto
proto:
@buf --version >/dev/null 2>&1 || (echo "Error: buf is not installed. Please install from https://docs.buf.build/installation"; exit 1)
buf generate -v https://github.com/aurae-runtime/aurae.git#branch=main,subdir=api