Skip to content

Commit 3d84e52

Browse files
committed
Move each license function dependent on SPDX licenses
* move to package spdxlicenses * put each in their own file to make licenses easier to update
1 parent 5033dc8 commit 3d84e52

File tree

6 files changed

+1132
-1048
lines changed

6 files changed

+1132
-1048
lines changed

Makefile

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Go projects should have a Makefile for commond build-related tasks.
2+
# See help target for a list of targets and their descriptions.
3+
#
4+
# Debug related targets are commented out until they can be tested.
5+
6+
# setup defaults
7+
SHELL := $(shell which bash)
8+
CWD_DIR := $(shell pwd)
9+
GITHUB_API_URL ?= https://api.github.com
10+
# DLV_BIN := $(shell go env GOPATH)/bin/dlv
11+
LINT_FILES := ./...
12+
13+
# provide extra information when format fails
14+
define goformat
15+
files="$$(go fmt ./...)"; \
16+
if [ -n "$${files}" ]; then \
17+
echo "❌ ERROR: go files are not properly formatted:"; \
18+
echo "$$files"; \
19+
echo ""; \
20+
echo "run the 'go fmt ./..' command or configure your editor"; \
21+
exit 1; \
22+
fi;
23+
endef
24+
25+
# # install dlv if it is not already installed
26+
# define dlv
27+
# cat /proc/sys/kernel/yama/ptrace_scope | grep 0 || \
28+
# echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope; \
29+
# echo "Checking if '$(DLV_BIN)' exist"; \
30+
# test -f "$(DLV_BIN)" || \
31+
# echo "Installing dlv..." && \
32+
# go install github.com/go-delve/delve/cmd/dlv@latest && \
33+
# echo "Installed dlv";
34+
# endef
35+
36+
# NOTE: Targets defined with .PHONY are not files, they execute commands.
37+
38+
# clean up the go modules files
39+
.PHONY: tidy
40+
tidy:
41+
@echo "==> starting tidy"
42+
go mod tidy
43+
44+
# go format this project
45+
.PHONY: format
46+
format:
47+
@echo "==> starting format"
48+
@$(call goformat)
49+
50+
# run some go test
51+
.PHONY: test
52+
test:
53+
@echo "==> starting test"
54+
go test ./...
55+
56+
# runs linter for all files
57+
.PHONY: lint-all
58+
lint-all:
59+
@echo "==> starting lint for directory: ${LINT_FILES}"
60+
golangci-lint run ${LINT_FILES}
61+
62+
# runs linter for only files with diffs from origin/main (useful for PRs)
63+
.PHONY: lint
64+
lint:
65+
@echo "==> starting lint for changed files"
66+
golangci-lint run --whole-files --new-from-rev=origin/main
67+
68+
.PHONY: help
69+
help:
70+
@echo "Usage: make <target>"
71+
@echo ""
72+
@echo "Targets:"
73+
@echo " tidy - clean up the go modules files"
74+
@echo " format - go format this project"
75+
@echo " test - run some go test"
76+
@echo " lint-all - runs linter for all files (optional pass in LINT_FILES=path_to_dir_or_file_to_check)"
77+
@echo " lint - runs linter for only files with diffs from origin/main (useful for PRs)"
78+
@echo " help - this help message"

0 commit comments

Comments
 (0)