-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (43 loc) · 2.05 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
# SPDX-FileCopyrightText: 2025 The Cipher Host Team <[email protected]>
#
# SPDX-License-Identifier: MIT
.POSIX:
.SUFFIXES:
GO ?= go
GIT ?= git
REUSE ?= reuse
RM ?= rm
REQUIRED_TOOLS := $(GO) $(GIT)
GO_MIN_VERSION := 1.23
all: pre-commit
check-tools: # Checks that all required tools for working with this repository are installed.
$(foreach tool,$(REQUIRED_TOOLS),\
$(if $(shell command -v $(tool)),,$(error "$(tool) not found in PATH")))
@$(GO) version | awk 'NR==1 {if ($$3 < "go$(GO_MIN_VERSION)") exit 1}'
pre-commit: check-tools tidy fmt lint vulnerabilities test # Runs all pre-commit checks.
commit: pre-commit # Commits the changes to the repository.
$(GIT) commit -s
doc: check-tools # Serves the documentation locally.
$(GO) run golang.org/x/tools/cmd/godoc@latest -http=localhost:1967
tidy: check-tools # Updates the go.mod file to ensure it matches the source code.
$(GO) mod tidy
fmt: check-tools # Formats Go source files in this repository.
$(GO) run mvdan.cc/gofumpt@latest -e -extra -w .
lint: check-tools # Runs linters on the codebase.
$(GO) run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run ./...
lint-licenses: # Run reuse to ensure the project complies with the REUSE specification.
$(REUSE) lint --lines
vulnerabilities: check-tools # Analyzes the codebase and looks for vulnerabilities affecting it.
$(GO) run golang.org/x/vuln/cmd/govulncheck@latest ./...
test: check-tools # Runs unit tests.
$(GO) test -cover -race -vet all -mod readonly ./...
test/coverage: check-tools # Generates a coverage profile and open it in a browser.
$(GO) test -coverprofile cover.out ./...
$(GO) tool cover -html=cover.out
licenses: check-tools # Runs go-licenses to check the licenses of the dependencies and generate a CSV file.
$(GO) run github.com/google/go-licenses@latest report \
--template '.github/license-3rdparty.tpl' \
--ignore 'go.cipher.host/cmdkit' \
'go.cipher.host/cmdkit' > LICENSE-3rdparty.csv
.PHONY: all check-tools pre-commit commit doc tidy fmt lint \
lint-licenses vulnerabilities test test/coverage licenses