Skip to content

Commit

Permalink
chore: Rework Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
sonjek committed Dec 8, 2024
1 parent d6c05c3 commit 8b7bc51
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 30 deletions.
62 changes: 44 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,11 @@ BINNAME := mouse-stay-up
TARGET_BIN := $(BINDIR)/$(BINNAME)
INSTALL_PATH := /usr/local/bin

# -------------------------------------------------------------------------------------------------
# main
# -------------------------------------------------------------------------------------------------

## help: Display this help
.PHONY: help
help: Makefile
@echo "Usage: make COMMAND"
@echo
@echo "Commands:"
@sed -n 's/^##//p' $< | column -ts ':' | sed -e 's/^/ /'

## get-deps: Download application dependencies
.PHONY: get-deps
get-deps:
@command -v go &> /dev/null || (echo "Please install GoLang" && false)
go mod download

all: help

## build: Build application
.PHONY: build
Expand Down Expand Up @@ -49,25 +39,61 @@ uninstall: clean
start: get-deps
go run ./cmd/app

# -------------------------------------------------------------------------------------------------
# testing
# -------------------------------------------------------------------------------------------------

## test: Run unit tests
.PHONY: test
test:
@go test ./...
test: check-go
@go test -v -count=1 ./...

# -------------------------------------------------------------------------------------------------
# tools && shared
# -------------------------------------------------------------------------------------------------

## check-go: Ensure that Go is installed
.PHONY: check-go
check-go:
@command -v go &> /dev/null || (echo "Please install GoLang" && false)

## tidy: Removes unused dependencies and adds missing ones
.PHONY: tidy
tidy: check-go
go mod tidy

## update-deps: Update go dependencies
.PHONY: update-deps
update-deps: check-go
go get -u ./...
-@$(MAKE) tidy

## get-deps: Download application dependencies
.PHONY: get-deps
get-deps: check-go
go mod download

## format: Fix code format issues
.PHONY: format
format:
go run mvdan.cc/gofumpt@latest -w -l .

## deadcode: Run deadcode tool for find unreachable functions
.PHONY: deadcode
deadcode:
go run golang.org/x/tools/cmd/deadcode@latest -test ./...


## audit: Quality checks
.PHONY: audit
audit:
audit: check-go
go mod verify
go vet ./...
go run golang.org/x/vuln/cmd/govulncheck@latest ./...

## help: Display this help
.PHONY: help
help: Makefile
@echo "Usage: make COMMAND"
@echo
@echo "Commands:"
@sed -n 's/^##//p' $< | column -ts ':' | sed -e 's/^/ /'
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To build the application on Debian-based Linux systems, follow these steps to in
$ make build
```

The binary file is built and ready to run from current folder:
The binary file is built and ready to run:
```
$ ./bin/mouse-stay-up
```
Expand All @@ -71,6 +71,8 @@ To build the application on Debian-based Linux systems, follow these steps to in
Installs to `/usr/local/bin/` by default:
```
$ make install
or
$ sudo make install
```

Install to a different location:
Expand All @@ -84,15 +86,18 @@ All available makefile actions:
Usage: make COMMAND
Commands:
help Display this help
get-deps Download application dependencies
build Build application
clean Remove binary file from local bin directory
install Install binary file from local bin directory to /usr/local/bin/
uninstall Remove binary file from /usr/local/bin/
start Build and start application
test Run unit tests
format Fix code format issues
deadcode Run deadcode tool for find unreachable functions
audit Quality checks
build Build application
clean Remove binary file from local bin directory
install Install binary file from local bin directory to /usr/local/bin/
uninstall Remove binary file from /usr/local/bin/
start Build and start application
test Run unit tests
check-go Ensure that Go is installed
tidy Removes unused dependencies and adds missing ones
update-deps Update go dependencies
get-deps Download application dependencies
format Fix code format issues
deadcode Run deadcode tool for find unreachable functions
audit Quality checks
help Display this help
```

0 comments on commit 8b7bc51

Please sign in to comment.