Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add make help to display the usage for project Makefile #902

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ define print
echo $(GREEN)$1$(NC)
endef

#? default: Run `make build`
default: build

#? all: Run `make build` and `make check`
all: build check

# ============
Expand All @@ -55,6 +57,7 @@ $(GOACC_BIN):
@$(call print, "Fetching go-acc")
$(GOINSTALL) $(GOACC_PKG)@$(GOACC_COMMIT)

#? goimports: Install goimports
goimports:
@$(call print, "Installing goimports.")
$(GOINSTALL) $(GOIMPORTS_PKG)@${GOIMPORTS_COMMIT}
Expand All @@ -63,10 +66,12 @@ goimports:
# INSTALLATION
# ============

#? build: Compile and build btcwallet
build:
@$(call print, "Compiling btcwallet.")
$(GOBUILD) $(PKG)/...

#? install: Install btcwallet, dropwtxmgr and sweepaccount, place them in $GOPATH/bin
install:
@$(call print, "Installing btcwallet.")
$(GOINSTALL) $(PKG)
Expand All @@ -77,16 +82,20 @@ install:
# TESTING
# =======

#? check: Run `make unit`
check: unit

#? unit: Run unit tests
unit:
@$(call print, "Running unit tests.")
$(GOLIST) | $(XARGS) env $(GOTEST) -test.timeout=20m

#? unit-cover: Run unit coverage tests
unit-cover: $(GOACC_BIN)
@$(call print, "Running unit coverage tests.")
$(GOACC_BIN) $(GOLIST_COVER)

#? unit-race: Run unit race tests
unit-race:
@$(call print, "Running unit race tests.")
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOLIST) | $(XARGS) env $(GOTEST) -race -test.timeout=20m
Expand All @@ -95,24 +104,29 @@ unit-race:
# UTILITIES
# =========

#? fmt: Fix imports and formatting source
fmt: goimports
@$(call print, "Fixing imports.")
goimports -w $(GOFILES_NOVENDOR)
@$(call print, "Formatting source.")
gofmt -l -w -s $(GOFILES_NOVENDOR)

#? lint: Lint source
lint: $(LINT_BIN)
@$(call print, "Linting source.")
$(LINT)

#? clean: Clean source
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) coverage.txt

#? tidy-module: Run 'go mod tidy' for all modules
tidy-module:
echo "Running 'go mod tidy' for all modules"
scripts/tidy_modules.sh

#? tidy-module-check: Run 'go mod tidy' for all modules and check results
tidy-module-check: tidy-module
if test -n "$$(git status --porcelain)"; then echo "modules not updated, please run `make tidy-module` again!"; git status; exit 1; fi

Expand All @@ -126,3 +140,10 @@ tidy-module-check: tidy-module
fmt \
lint \
clean

#? help: Get more info on make commands
help: Makefile
@echo " Choose a command run in btcwallet:"
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'

.PHONY: help