-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (75 loc) · 2.84 KB
/
Makefile
File metadata and controls
95 lines (75 loc) · 2.84 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
92
93
94
95
# The commands used in this Makefile expect to be interpreted by bash.
# Adapted from Funnel's Makefile:
# https://github.com/ohsu-comp-bio/funnel/blob/master/Makefile
SHELL := /bin/bash
TESTS=$(shell go list ./... | grep -v /vendor/)
git_commit := $(shell git rev-parse --short HEAD)
git_branch := $(shell git symbolic-ref -q --short HEAD)
git_upstream := $(shell git config --get remote.origin.url)
export GIT_BRANCH = $(git_branch)
export GIT_UPSTREAM = $(git_upstream)
# Determine if the current commit has a tag
git_tag := $(shell git describe --tags --exact-match --abbrev=0 2>/dev/null)
ifeq ($(git_tag),)
version := unknown
else
version := $(git_tag)
endif
VERSION_LDFLAGS=\
-X "github.com/calypr/git-drs/version.BuildDate=$(shell date)" \
-X "github.com/calypr/git-drs/version.GitCommit=$(git_commit)" \
-X "github.com/calypr/git-drs/version.GitBranch=$(git_branch)" \
-X "github.com/calypr/git-drs/version.GitUpstream=$(git_upstream)" \
-X "github.com/calypr/git-drs/version.Version=$(version)"
export CGO_ENABLED=0
# Build the code
install:
@go install -ldflags '$(VERSION_LDFLAGS)' .
# Build the code
build:
@go build -ldflags '$(VERSION_LDFLAGS)' -buildvcs=false .
lint-depends:
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/client9/misspell/cmd/misspell@latest
# Run code style and other checks
# Note: Using native Go tools instead of golangci-lint for Go 1.24 compatibility
lint:
@echo "Running go vet..."
@go vet ./...
@echo "Running gofmt..."
@test -z "$$(gofmt -s -l . | tee /dev/stderr)" || (echo "Please run: gofmt -s -w ." && exit 1)
@echo "Running goimports..."
@test -z "$$(goimports -l . | tee /dev/stderr)" || (echo "Please run: goimports -w ." && exit 1)
@echo "Running misspell..."
@misspell -error .
@echo "✅ All lint checks passed!"
# Auto-fix formatting issues
fmt:
@echo "Formatting with gofmt..."
@gofmt -s -w .
@echo "Formatting with goimports..."
@goimports -w .
@echo "✅ Formatting complete!"
# Run all tests
test:
@go test $(TESTS)
test-verbose:
@go test -v $(TESTS)
# Run tests with coverage
test-coverage:
@go test -v -race -coverprofile=coverage.out -covermode=atomic $(TESTS)
@go tool cover -func=coverage.out | tail -1
# Generate HTML coverage report
coverage-html: test-coverage
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
@echo "Open it with: open coverage.html (macOS) or xdg-open coverage.html (Linux)"
# View coverage in browser
coverage-view: coverage-html
@open coverage.html || xdg-open coverage.html || echo "Please open coverage.html manually"
# Make everything usually needed to prepare for a pull request
full: proto install tidy lint test website webdash
# Remove build/development files.
clean:
@rm -rf ./bin ./pkg ./test_tmp ./build ./buildtools
.PHONY: proto proto-lint website docker webdash build debug