Files
backend/Makefile
Yi-Ting Shih 54c7659ee8
Some checks failed
Go test / run-go-vet (push) Successful in 5s
Go test / check-swagger-up-to-date (push) Successful in 9s
Go test / run-go-test (push) Successful in 27s
Go test / cleanup-go-test (push) Successful in 14s
Go test / release-image (push) Failing after 56s
Feat: add release image workflows
2025-12-09 01:55:15 +08:00

47 lines
1.0 KiB
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
COMPOSE ?= $(DOCKER) compose -p go2025-backend --progress plain
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:
$(COMPOSE) exec postgres psql \
postgres://go2025:go2025@postgres:5432/go2025?sslmode=disable
test-ci: docker-quiet test docker-clean
docker-quiet: $(TARGET)
$(COMPOSE) up -d \
--force-recreate --build backend \
--quiet-build --quiet-pull
-for i in seq 10; do \
$(COMPOSE) exec postgres docker-ensure-initdb.sh && break; \
sleep 1; \
done
docker-clean:
$(COMPOSE) down -v --remove-orphans