-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (73 loc) · 2.03 KB
/
Copy pathMakefile
File metadata and controls
91 lines (73 loc) · 2.03 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
81
82
83
84
85
86
87
88
89
90
91
PROJECT_VERSION := 1.0.0
GOBIN := $(shell go env GOBIN)
ifeq ($(strip $(GOBIN)),)
GOBIN := $(shell go env GOPATH)/bin
endif
XK6_VERSION := v0.13.4
XK6_BINARY := "$(GOBIN)/xk6"
GOLANGCI_VERSION := v1.64.5
GOLANGCI_BINARY := "$(GOBIN)/golangci-lint"
GO_TOOLCHAIN := $(shell go env GOVERSION 2>/dev/null | sed 's/^go//')
ifneq ($(strip $(GO_TOOLCHAIN)),)
export ASDF_GOLANG_VERSION := $(GO_TOOLCHAIN)
endif
.DEFAULT_GOAL := all
.PHONY: all
all: format lint test run
.PHONY: deps
deps:
@if [ ! -f "$(XK6_BINARY)" ]; then \
echo "Installing xk6..."; \
go install go.k6.io/xk6/cmd/xk6@$(XK6_VERSION); \
else \
echo "xk6 is already installed."; \
fi
@if [ ! -f "$(GOLANGCI_BINARY)" ]; then \
echo "Installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VERSION); \
else \
echo "golangci-lint is already installed."; \
fi
.PHONY: build
build: deps
@echo "Building k6 with jsonparser extension..."
@"$(XK6_BINARY)" build --with github.com/InditexTech/xk6-jsonparser=.
.PHONY: run
run: deps
@echo "Running example..."
@"$(XK6_BINARY)" run ./examples/main.js
.PHONY: verify
verify: format lint test run
.PHONY: test
test:
@echo "Running unit tests..."
@go clean -testcache && go test -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
.PHONY: tidy
tidy:
@echo "Running go mod tidy..."
@go mod tidy
.PHONY: format
format:
@echo "Running go fmt..."
@go fmt ./...
.PHONY: lint
lint: deps
@echo "Running golangci-lint..."
@"$(GOLANGCI_BINARY)" run
.PHONY: reuse-deps
reuse-deps:
@if [ -z "reuse" ]; then \
echo "Installing reuse tool..."; \
pip3 install --user reuse ;\
else \
echo "reuse is already installed."; \
fi
.PHONY: add-copyright-headers
reuse-annotate: reuse-deps
@echo "Adding copyright headers..."
@reuse annotate --copyright "2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)" --license "AGPL-3.0-only" --year "$$(date +%Y)" --merge-copyrights *.go **/**/*.go
@reuse lint
.PHONY: get-version
get-version:
@echo $(PROJECT_VERSION)