github.com/kotovmak/go-admin@v1.1.1/Makefile (about) 1 GOCMD = go 2 GOBUILD = $(GOCMD) build 3 BINARY_NAME = adm 4 LAST_VERSION = v1.2.23 5 VERSION = v1.2.24 6 CLI = adm 7 8 TEST_CONFIG_PATH=./../../common/config.json 9 TEST_CONFIG_PQ_PATH=./../../common/config_pg.json 10 TEST_CONFIG_SQLITE_PATH=./../../common/config_sqlite.json 11 TEST_CONFIG_MS_PATH=./../../common/config_ms.json 12 TEST_FRAMEWORK_DIR=./tests/frameworks 13 14 ## database configs 15 MYSQL_HOST = db_mysql 16 MYSQL_PORT = 3306 17 MYSQL_USER = root 18 MYSQL_PWD = root 19 20 POSTGRESSQL_HOST = db_pgsql 21 POSTGRESSQL_PORT = 5432 22 POSTGRESSQL_USER = postgres 23 POSTGRESSQL_PWD = root 24 25 TEST_DB = go-admin-test 26 27 all: test 28 29 ## tests 30 31 test: cp-mod black-box-test web-test restore-mod 32 33 ## tests: black box tests 34 35 black-box-test: mysql-test pg-test sqlite-test ms-test 36 37 mysql-test: $(TEST_FRAMEWORK_DIR)/* 38 go get github.com/ugorji/go/codec@none 39 for file in $^ ; do \ 40 make import-mysql ; \ 41 gotest -mod=mod -gcflags=all=-l -v ./$${file}/... -args $(TEST_CONFIG_PATH) ; \ 42 done 43 44 sqlite-test: $(TEST_FRAMEWORK_DIR)/* 45 for file in $^ ; do \ 46 make import-sqlite ; \ 47 gotest -mod=mod -gcflags=all=-l ./$${file}/... -args $(TEST_CONFIG_SQLITE_PATH) ; \ 48 done 49 50 pg-test: $(TEST_FRAMEWORK_DIR)/* 51 for file in $^ ; do \ 52 make import-postgresql ; \ 53 gotest -mod=mod -gcflags=all=-l ./$${file}/... -args $(TEST_CONFIG_PQ_PATH) ; \ 54 done 55 56 ms-test: $(TEST_FRAMEWORK_DIR)/* 57 for file in $^ ; do \ 58 make import-mssql ; \ 59 gotest -mod=mod -gcflags=all=-l ./$${file}/... -args $(TEST_CONFIG_MS_PATH) ; \ 60 done 61 62 ## tests: user acceptance tests 63 64 web-test: import-mysql 65 gotest -mod=mod ./tests/web/... 66 rm -rf ./tests/web/User* 67 68 web-test-debug: import-mysql 69 gotest -mod=mod ./tests/web/... -args true 70 71 ## tests: unit tests 72 73 unit-test: 74 gotest -mod=mod ./adm/... 75 gotest -mod=mod ./context/... 76 gotest -mod=mod ./modules/... 77 gotest -mod=mod ./plugins/admin/controller/... 78 gotest -mod=mod ./plugins/admin/modules/parameter/... 79 gotest -mod=mod ./plugins/admin/modules/table/... 80 gotest -mod=mod ./plugins/admin/modules/... 81 82 ## tests: helpers 83 84 import-sqlite: 85 rm -rf ./tests/common/admin.db 86 cp ./tests/data/admin.db ./tests/common/admin.db 87 88 import-mysql: 89 mysql -h$(MYSQL_HOST) -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PWD} -e "create database if not exists \`${TEST_DB}\`" 90 mysql -h$(MYSQL_HOST) -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PWD} ${TEST_DB} < ./tests/data/admin.sql 91 92 import-postgresql: 93 PGPASSWORD=${POSTGRESSQL_PWD} dropdb -h ${POSTGRESSQL_HOST} -p ${POSTGRESSQL_PORT} -U ${POSTGRESSQL_USER} ${TEST_DB} 94 PGPASSWORD=${POSTGRESSQL_PWD} createdb -h ${POSTGRESSQL_HOST} -p ${POSTGRESSQL_PORT} -U ${POSTGRESSQL_USER} ${TEST_DB} 95 PGPASSWORD=${POSTGRESSQL_PWD} psql -h ${POSTGRESSQL_HOST} -p ${POSTGRESSQL_PORT} -d ${TEST_DB} -U ${POSTGRESSQL_USER} -f ./tests/data/admin_pg.sql 96 97 import-mssql: 98 /opt/mssql-tools/bin/sqlcmd -S db_mssql -U SA -P Aa123456 -Q "RESTORE DATABASE [goadmin] FROM DISK = N'/home/data/admin_ms.bak' WITH FILE = 1, NOUNLOAD, REPLACE, RECOVERY, STATS = 5" 99 100 backup-mssql: 101 docker exec mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Aa123456 -Q "BACKUP DATABASE [goadmin] TO DISK = N'/home/data/admin_ms.bak' WITH NOFORMAT, NOINIT, NAME = 'goadmin-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10" 102 103 cp-mod: 104 cp go.mod go.mod.old 105 cp go.sum go.sum.old 106 107 restore-mod: 108 mv go.mod.old go.mod 109 mv go.sum.old go.sum 110 111 ## code style check 112 113 lint: fmt golint govet cilint 114 115 fmt: 116 GO111MODULE=off go fmt ./... 117 GO111MODULE=off goimports -l -w . 118 119 govet: 120 GO111MODULE=off go vet ./... 121 122 cilint: 123 GO111MODULE=off golangci-lint run 124 125 golint: 126 GO111MODULE=off golint ./... 127 128 build-tmpl: 129 ## form tmpl build 130 adm compile tpl --src ./template/types/tmpls/ --dist ./template/types/tmpl.go --package types --var tmpls 131 ## generator tmpl build 132 adm compile tpl --src ./plugins/admin/modules/table/tmpl --dist ./plugins/admin/modules/table/tmpl.go --package table --var tmpls 133 134 ## cli version update 135 136 cli: 137 GO111MODULE=on $(GOBUILD) -ldflags "-w" -o ./adm/build/mac/$(BINARY_NAME) ./adm/... 138 GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o ./adm/build/linux/x86_64/$(BINARY_NAME) ./adm/... 139 GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm $(GOBUILD) -o ./adm/build/linux/armel/$(BINARY_NAME) ./adm/... 140 GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o ./adm/build/windows/x86_64/$(BINARY_NAME).exe ./adm/... 141 GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 $(GOBUILD) -o ./adm/build/windows/i386/$(BINARY_NAME).exe ./adm/... 142 rm -rf ./adm/build/linux/armel/adm_linux_armel_$(LAST_VERSION).zip 143 rm -rf ./adm/build/linux/x86_64/adm_linux_x86_64_$(LAST_VERSION).zip 144 rm -rf ./adm/build/windows/x86_64/adm_windows_x86_64_$(LAST_VERSION).zip 145 rm -rf ./adm/build/windows/i386/adm_windows_i386_$(LAST_VERSION).zip 146 rm -rf ./adm/build/mac/adm_darwin_x86_64_$(LAST_VERSION).zip 147 zip -qj ./adm/build/linux/armel/adm_linux_armel_$(VERSION).zip ./adm/build/linux/armel/adm 148 zip -qj ./adm/build/linux/x86_64/adm_linux_x86_64_$(VERSION).zip ./adm/build/linux/x86_64/adm 149 zip -qj ./adm/build/windows/x86_64/adm_windows_x86_64_$(VERSION).zip ./adm/build/windows/x86_64/adm.exe 150 zip -qj ./adm/build/windows/i386/adm_windows_i386_$(VERSION).zip ./adm/build/windows/i386/adm.exe 151 zip -qj ./adm/build/mac/adm_darwin_x86_64_$(VERSION).zip ./adm/build/mac/adm 152 rm -rf ./adm/build/zip/* 153 cp ./adm/build/linux/armel/adm_linux_armel_$(VERSION).zip ./adm/build/zip/ 154 cp ./adm/build/linux/x86_64/adm_linux_x86_64_$(VERSION).zip ./adm/build/zip/ 155 cp ./adm/build/windows/x86_64/adm_windows_x86_64_$(VERSION).zip ./adm/build/zip/ 156 cp ./adm/build/windows/i386/adm_windows_i386_$(VERSION).zip ./adm/build/zip/ 157 cp ./adm/build/mac/adm_darwin_x86_64_$(VERSION).zip ./adm/build/zip/ 158 159 .PHONY: all fmt golint govet cp-mod restore-mod test black-box-test mysql-test sqlite-test import-sqlite import-mysql import-postgresql pg-test lint cilint cli