chore: update makefile commands (!92)

* Tweak makefile commands and file formatting
* Remove command and build step for go mod formatting
* Add command to update project dependencies
* Add make command to list all make commands

https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/merge_requests/92
This commit is contained in:
Hector 2023-06-21 15:02:11 +00:00
parent b32bbeb1cd
commit 56ecc03341
2 changed files with 24 additions and 11 deletions

View File

@ -12,12 +12,6 @@ sast:
include:
- template: Security/SAST.gitlab-ci.yml
dependencies:
extends: .go_template
stage: test
script:
- make check/dependencies
format:
extends: .go_template
stage: test

View File

@ -1,21 +1,38 @@
.PHONY: download test fmt check/dependencies check/fmt build build/docker
# List make commands
.PHONY: ls
ls:
cat Makefile | grep "^[a-zA-Z#].*" | cut -d ":" -f 1 | sed s';#;\n#;'g
# Download dependencies
.PHONY: download
download:
go mod download
# Update project dependencies
.PHONY: update
update:
go get -u
go mod download
go mod tidy
# Run project tests
.PHONY: test
test: download
go test ./... -v -race
# Format code
.PHONY: fmt
fmt: download
go mod tidy
go fmt ./...
check/dependencies: download
go mod tidy -v
git diff-index --quiet HEAD
# Check for unformatted go code
.PHONY: check/fmt
check/fmt: download
test -z $(shell gofmt -l .)
# Build project
.PHONY: build
build:
go build \
-ldflags "\
@ -27,5 +44,7 @@ build:
-o fail2ban_exporter \
exporter.go
# Build project docker container
.PHONY: build/docker
build/docker: build
docker build -t fail2ban-prometheus-exporter .