feat: vendor, makefiles, build settings

This commit is contained in:
2026-04-30 09:43:22 +02:00
parent 0892c33b13
commit ed84610696
94 changed files with 14229 additions and 11 deletions
+60
View File
@@ -1,5 +1,13 @@
include .env
#
# ==========================================================
#
# HELPERS
#
# ==========================================================
#
## help: print this help message
.PHONY: help
help:
@@ -10,6 +18,14 @@ help:
confirm:
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
#
# ====================================================================================
#
# DEVELOPMENT
#
# ====================================================================================
#
## run/api: run the cmd/api application
.PHONY: run/api
run/api:
@@ -32,3 +48,47 @@ db/migrations/up: confirm
@echo 'Running up migrations...'
migrate -path ./migrations -database ${DATABASE_DSN} up
# ==================================================================================== #
#
# QUALITY CONTROL
#
# ==================================================================================== #
## audit: tidy and vendor dependencies and format, vet and test all code
.PHONY: audit
audit: vendor
@echo 'Formatting code...'
go fmt ./...
@echo 'Vetting code...'
go vet ./...
staticcheck ./...
@echo 'Running tests...'
go test -race -vet=off ./...
## vendor: tidy and vendor dependencies
.PHONY: vendor
vendor:
@echo 'Tidying and verifying module dependencies...'
go mod tidy
go mod verify
@echo 'Vendoring dependencies...'
go mod vendor
# ==================================================================================== #
#
# BUILD
#
# ==================================================================================== #
current_time = $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
linker_flags = '-s -X main.buildTime=${current_time}'
## build/api: build the cmd/api application
.PHONY: build/api
build/api:
@echo 'Building cmd/api...'
go build -ldflags=${linker_flags} -o=./bin/api ./cmd/api
GOOS=linux GOARCH=amd64 go build -ldflags=${linker_flags} -o=./bin/linux_amd64/api ./cmd/api