-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (54 loc) · 2.19 KB
/
Makefile
File metadata and controls
66 lines (54 loc) · 2.19 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
##################################################
# Gitlab-CI Exporter - Makefile
##################################################
NAME := gitlab-ci-exporter
FILES := $(shell git ls-files */*.go)
COVERAGE_FILE := coverage.out
REPOSITORY := "helvethink/$(NAME)"
.DEFAULT_GOAL := help
GOLANG_VERSION := 1.26.1
GOLANGCI_LINT_VERSION ?= v2.1.5
.PHONY: lint
lint: ## Run all lint related tests againts the codebase
@echo "--- Linting code..."
docker run --rm -w /workdir -v $(PWD):/workdir golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint run -c .golangci.yml --fix
.PHONY: run
run: ## Run the tests against the codebase
@echo "Run app:"
$(GO) run cmd/$(APP_NAME)/main.go
.PHONY: coverage
coverage: ## Prints coverage report
@echo "Running coverage:"
./coverage.sh
.PHONY: coverage-html
coverage-html: ## Generates coverage report and displays it in the browser
go tool cover -html=coverage.out
.PHONY: install
install: ## Build and install locally the binary (dev purpose)
go install ./cmd/$(NAME)
.PHONY: build
build: ## Build the binaries using local GOOS
go build -o ./bin/$(NAME) ./cmd/$(NAME)
.PHONY: build-docker
build-docker: ## Build a local image
docker build -t $(REPOSITORY)/$(NAME)
.PHONY: docker-compose
docker-compose: ## Run docker compose
cd examples/
docker compose up --build
.PHONY: clean
clean: ## Remove binary if it exists
rm -f $(NAME)
.PHONY: protoc
protoc: ## Generate golang from .proto files
@command -v protoc 2>&1 >/dev/null || (echo "protoc needs to be available in PATH: https://github.com/protocolbuffers/protobuf/releases"; false)
@command -v protoc-gen-go 2>&1 >/dev/null || go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
protoc \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
pkg/monitor/protobuf/monitor.proto
.PHONY: all
all: lint run build coverage ## Test, builds and ship package for all supported platforms
.PHONY: help
help: ## Displays this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'