mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 02:27:57 +00:00
The repository has 19 test files and nothing was running any of them. Both workflows build with go build, which does not compile _test.go, the Makefile's test target was commented out, and there is no pre-commit hook. Every test in the tree, including the schema guards that exist precisely to catch a silent breakage, only ran when someone remembered to type go test. Enables the commented-out target and calls it from go.yml, the one workflow that fires on every push and pull request. build.yml is left alone: it skips documentation-only changes and deploys on master, so it is the wrong place for a gate that should never be skipped. Runs with -race. common/actions reuses model instances across concurrent requests, so a Generate() that returns in place rather than a copy leaks data between them, which a single-threaded run cannot see. Verified locally: the suite passes under CGO_ENABLED=0 and under -race, and make test exits non-zero when a test fails, so the step actually gates. Claude-Session: https://claude.ai/code/session_01DJhM6LvhkNPej35wy9F7Aq
59 lines
1.8 KiB
Makefile
59 lines
1.8 KiB
Makefile
PROJECT:=go-admin
|
|
|
|
.PHONY: build
|
|
build:
|
|
CGO_ENABLED=0 go build -ldflags="-w -s" -a -installsuffix "" -o go-admin .
|
|
|
|
# make build-linux
|
|
build-linux:
|
|
@docker build -t go-admin:latest .
|
|
@echo "build successful"
|
|
|
|
build-sqlite:
|
|
go build -tags sqlite3 -ldflags="-w -s" -a -installsuffix -o go-admin .
|
|
|
|
# make run
|
|
run:
|
|
# delete go-admin-api container
|
|
@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi
|
|
|
|
# 启动方法一 run go-admin-api container docker-compose 启动方式
|
|
# 进入到项目根目录 执行 make run 命令
|
|
@docker-compose up -d
|
|
|
|
# 启动方式二 docker run 这里注意-v挂载的宿主机的地址改为部署时的实际绝对路径
|
|
#@docker run --name=go-admin -p 8000:8000 -v /home/code/go/src/go-admin/go-admin/config:/go-admin-api/config -v /home/code/go/src/go-admin/go-admin-api/static:/go-admin/static -v /home/code/go/src/go-admin/go-admin/temp:/go-admin-api/temp -d --restart=always go-admin:latest
|
|
|
|
@echo "go-admin service is running..."
|
|
|
|
# delete Tag=<none> 的镜像
|
|
@docker image prune -f
|
|
@docker ps -a | grep "go-admin"
|
|
|
|
stop:
|
|
# delete go-admin-api container
|
|
@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker-compose down; fi
|
|
#@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi
|
|
#@echo "go-admin stop success"
|
|
|
|
|
|
# -race is worth the extra minute here: common/actions reuses model instances
|
|
# across concurrent requests, so a Generate() that returns in place instead of
|
|
# a copy leaks data between them - and that is invisible to a single-threaded
|
|
# test run.
|
|
.PHONY: test
|
|
test:
|
|
go test -race -cover ./...
|
|
|
|
#.PHONY: docker
|
|
#docker:
|
|
# docker build . -t go-admin:latest
|
|
|
|
# make deploy
|
|
deploy:
|
|
|
|
#@git checkout master
|
|
#@git pull origin master
|
|
make build-linux
|
|
make run
|