Files
backend/Makefile
Yi-Ting Shih 62c4d38e9c
Some checks failed
Go test / run-go-vet (push) Successful in 6s
Go test / run-go-test (push) Failing after 23s
Go test / cleanup-go-test (push) Successful in 12s
Feat: add workflows
2025-12-09 00:25:04 +08:00

43 lines
920 B
Makefile

.PHONY: all swagger install postgres test test-ci \
docker docker-quiet docker-clean
SWAG ?= go run github.com/swaggo/swag/cmd/swag@v1.16.4
DOCKER ?= docker
GO_ENV += CGO_ENABLED=0
SOURCE := $(shell find . -type f -name '*.go')
TARGET := backend
all: swagger docker
swagger:
$(SWAG) fmt
$(SWAG) init -o docs -g cmds/serve.go -pdl 1
docker: $(TARGET)
$(DOCKER) compose up -d --force-recreate --build backend
$(TARGET): $(SOURCE)
$(GO_ENV) go build -o $@
install:
$(GO_ENV) go install
test:
go test -v ./tests -count=1 -failfast
postgres:
$(DOCKER) compose exec postgres psql \
postgres://go2025:go2025@postgres:5432/go2025?sslmode=disable
test-ci: docker-quiet test docker-clean
docker-quiet: $(TARGET)
$(DOCKER) compose -p go2025-backend up -d \
--force-recreate --build backend \
--quiet-build --quiet-pull
sleep 5
docker-clean:
$(DOCKER) compose -p go2025-backend down -v --remove-orphans