diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 000000000..dae97b116 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,164 @@ +--- +kind: pipeline +type: docker +name: api_mysql + +trigger: + event: + - pull_request + +clone: + disable: true + +services: +- name: db_mysql + image: mysql:5.7 + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: go-admin-test + +steps: +- name: api + image: chg80333/goadmin-test:v7 + environment: + GO111MODULE: on + GOPROXY: https://goproxy.cn + commands: + - cd /go/src/github.com/GoAdminGroup/go-admin + - git pull + - git checkout $DRONE_COMMIT + - sleep 80 + - make mysql-test + +--- +kind: pipeline +type: docker +name: api_mssql + +trigger: + event: + - pull_request + +clone: + disable: true + +volumes: +- name: data + temp: {} + +services: +- name: db_mssql + image: mcr.microsoft.com/mssql/server:2017-latest + volumes: + - name: data + path: /home/data + environment: + ACCEPT_EULA: Y + SA_PASSWORD: Aa123456 + +steps: +- name: api + image: chg80333/goadmin-test:v7 + volumes: + - name: data + path: /go/src/github.com/GoAdminGroup/go-admin/tests/data + environment: + GO111MODULE: on + GOPROXY: https://goproxy.cn + commands: + - cd /go/src/github.com/GoAdminGroup/go-admin + - git pull + - git checkout $DRONE_COMMIT + - sleep 80 + - make ms-test + +--- +kind: pipeline +type: docker +name: api_postgres + +trigger: + event: + - pull_request + +clone: + disable: true + +services: +- name: db_pgsql + image: postgres:10 + environment: + POSTGRES_USER: postgres + POSTGRES_DB: go-admin-test + POSTGRES_PASSWORD: root + +steps: +- name: api + image: chg80333/goadmin-test:v7 + environment: + GO111MODULE: on + GOPROXY: https://goproxy.cn + commands: + - cd /go/src/github.com/GoAdminGroup/go-admin + - git pull + - git checkout $DRONE_COMMIT + - sleep 80 + - make pg-test + +--- +kind: pipeline +type: docker +name: api_sqlite + +trigger: + event: + - pull_request + +clone: + disable: true + +steps: +- name: api + image: chg80333/goadmin-test:v7 + environment: + GO111MODULE: on + GOPROXY: https://goproxy.cn + commands: + - cd /go/src/github.com/GoAdminGroup/go-admin + - git pull + - git checkout $DRONE_COMMIT + - sleep 80 + - make sqlite-test + +--- +kind: pipeline +type: docker +name: frontend + +trigger: + event: + - pull_request + +clone: + disable: true + +services: +- name: db_mysql + image: mysql:5.7 + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: go-admin-test + +steps: +- name: chrome + image: chg80333/goadmin-test:v7 + environment: + GO111MODULE: on + GOPROXY: https://goproxy.cn + commands: + - cd /go/src/github.com/GoAdminGroup/go-admin + - git pull + - git checkout $DRONE_COMMIT + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & + - sleep 8 + - make web-test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a44ade351..000000000 --- a/.travis.yml +++ /dev/null @@ -1,46 +0,0 @@ -language: go -sudo: true - -go: - - 1.13.x - -env: - - GO111MODULE=on PGPASSWORD=root GOPROXY=https://goproxy.cn,https://goproxy.io,direct - -addons: - chrome: stable - apt: - packages: - - chromium-chromedriver - -services: - - mysql - - postgresql - - docker - -before_install: - - mysql -e 'create database `go-admin-test`;' - - createdb -U postgres go-admin-test - -install: - - wget -N https://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_linux64.zip -P ~/ - - unzip ~/chromedriver_linux64.zip -d ~/ - - rm ~/chromedriver_linux64.zip - - sudo chmod +x /home/travis/chromedriver - - ln --symbolic /home/travis/chromedriver "${HOME}/bin/chromedriver" - - chromedriver --version - -before_script: - - google-chrome-stable --version - - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & - - echo "USE mysql;\nUPDATE user SET authentication_string=PASSWORD('root') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root - - psql -c "ALTER USER postgres WITH PASSWORD 'root';" -U postgres - - go get -u github.com/rakyll/gotest - - go get -u -v github.com/gogf/gf@v1.12.1 - - sudo chmod -R 777 $GOPATH/pkg/mod/github.com/gogf/gf@v1.12.1/net/ghttp/ghttp_server_handler.go - - sudo echo -e "\nfunc (s *Server) DefaultHttpHandle(w http.ResponseWriter, r *http.Request) { \n s.handleRequest(w, r) \n}\n" >> $GOPATH/pkg/mod/github.com/gogf/gf@v1.12.1/net/ghttp/ghttp_server_handler.go - - docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Aa123456" -v /home/travis/gopath/src/github.com/GoAdminGroup/go-admin/tests/data:/home/data -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server:2017-latest - - cd /home/travis/gopath/src/github.com/GoAdminGroup/go-admin && go get github.com/GoAdminGroup/themes@master - -script: - - cd /home/travis/gopath/src/github.com/GoAdminGroup/go-admin && make test \ No newline at end of file diff --git a/Makefile b/Makefile index cffa405ea..8e6caa544 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,18 @@ TEST_CONFIG_MS_PATH=./../../common/config_ms.json TEST_FRAMEWORK_DIR=./tests/frameworks ## database configs -MYSQL_HOST = 127.0.0.1 +MYSQL_HOST = db_mysql MYSQL_PORT = 3306 MYSQL_USER = root MYSQL_PWD = root +POSTGRESSQL_HOST = db_pgsql +POSTGRESSQL_PORT = 5432 +POSTGRESSQL_USER = postgres +POSTGRESSQL_PWD = root + +TEST_DB = go-admin-test + all: test ## tests @@ -79,25 +86,20 @@ import-sqlite: cp ./tests/data/admin.db ./tests/common/admin.db import-mysql: - mysql -h$(MYSQL_HOST) -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PWD} -e "create database if not exists \`go-admin-test\`" - mysql -h$(MYSQL_HOST) -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PWD} go-admin-test < ./tests/data/admin.sql + mysql -h$(MYSQL_HOST) -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PWD} -e "create database if not exists \`${TEST_DB}\`" + mysql -h$(MYSQL_HOST) -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PWD} ${TEST_DB} < ./tests/data/admin.sql import-postgresql: - dropdb -U postgres go-admin-test - createdb -U postgres go-admin-test - psql -d go-admin-test -U postgres -f ./tests/data/admin_pg.sql + PGPASSWORD=${POSTGRESSQL_PWD} dropdb -h ${POSTGRESSQL_HOST} -p ${POSTGRESSQL_PORT} -U ${POSTGRESSQL_USER} ${TEST_DB} + PGPASSWORD=${POSTGRESSQL_PWD} createdb -h ${POSTGRESSQL_HOST} -p ${POSTGRESSQL_PORT} -U ${POSTGRESSQL_USER} ${TEST_DB} + PGPASSWORD=${POSTGRESSQL_PWD} psql -h ${POSTGRESSQL_HOST} -p ${POSTGRESSQL_PORT} -d ${TEST_DB} -U ${POSTGRESSQL_USER} -f ./tests/data/admin_pg.sql import-mssql: - docker exec mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Aa123456 -Q "RESTORE DATABASE [goadmin] FROM DISK = N'/home/data/admin_ms.bak' WITH FILE = 1, NOUNLOAD, REPLACE, RECOVERY, STATS = 5" + /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" backup-mssql: 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" -fix-gf: - go get -u -v github.com/gogf/gf@v1.12.1 - sudo chmod -R 777 $(GOPATH)/pkg/mod/github.com/gogf/gf@v1.12.1/net/ghttp/ghttp_server_handler.go - sudo echo "\nfunc (s *Server) DefaultHttpHandle(w http.ResponseWriter, r *http.Request) { \n s.handleRequest(w, r) \n}\n" >> $(GOPATH)/pkg/mod/github.com/gogf/gf@v1.12.1/net/ghttp/ghttp_server_handler.go - cp-mod: cp go.mod go.mod.old cp go.sum go.sum.old @@ -154,4 +156,4 @@ cli: cp ./adm/build/windows/i386/adm_windows_i386_$(VERSION).zip ./adm/build/zip/ cp ./adm/build/mac/adm_darwin_x86_64_$(VERSION).zip ./adm/build/zip/ -.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 fix-gf lint cilint cli +.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 diff --git a/README.md b/README.md index 836cfb46a..59c924130 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@
- + diff --git a/README_CN.md b/README_CN.md index 3249d7d8c..5f8985735 100644 --- a/README_CN.md +++ b/README_CN.md @@ -7,7 +7,7 @@ 遗失的Golang编写的数据可视化与管理平台构建框架
- + diff --git a/tests/common/config.json b/tests/common/config.json index 9951dabb0..3a3c0de3b 100644 --- a/tests/common/config.json +++ b/tests/common/config.json @@ -1,7 +1,7 @@ { "database": { "default": { - "host": "127.0.0.1", + "host": "db_mysql", "port": "3306", "user": "root", "pwd": "root", diff --git a/tests/common/config_ms.json b/tests/common/config_ms.json index 9e115e52f..daddb0f0a 100644 --- a/tests/common/config_ms.json +++ b/tests/common/config_ms.json @@ -1,7 +1,7 @@ { "database": { "default": { - "host": "127.0.0.1", + "host": "db_mssql", "port": "1433", "user": "sa", "pwd": "Aa123456", diff --git a/tests/common/config_pg.json b/tests/common/config_pg.json index 91c67c780..b308d6db2 100644 --- a/tests/common/config_pg.json +++ b/tests/common/config_pg.json @@ -1,7 +1,7 @@ { "database": { "default": { - "host": "127.0.0.1", + "host": "db_pgsql", "port": "5432", "user": "postgres", "pwd": "root", diff --git a/tests/frameworks/gf/gf.go b/tests/frameworks/gf/gf.go index 483a63008..79c218df1 100644 --- a/tests/frameworks/gf/gf.go +++ b/tests/frameworks/gf/gf.go @@ -58,6 +58,5 @@ func (hh *httpHandler) SetSrv(s *ghttp.Server) *httpHandler { } func (hh *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - // NOTE: ╮(╯▽╰)╭ - hh.srv.DefaultHttpHandle(w, r) + hh.srv.ServeHTTP(w, r) } diff --git a/tests/web/config.json b/tests/web/config.json index 6ae97033c..f560ee836 100644 --- a/tests/web/config.json +++ b/tests/web/config.json @@ -1,7 +1,7 @@ { "database": { "default": { - "host": "127.0.0.1", + "host": "db_mysql", "port": "3306", "user": "root", "pwd": "root", diff --git a/tests/web/web_test.go b/tests/web/web_test.go index 9181572a3..0c6f5ab32 100644 --- a/tests/web/web_test.go +++ b/tests/web/web_test.go @@ -530,7 +530,7 @@ func testEditPageOperations(page *Page) { page.Value(birthdayField, "2010-09-05 00:00:00") page.Value(passwordField, "12345678") page.Value(ipField, "127.0.0.1") - page.Value(amountField, "15.00") + page.Value(amountField, "15") page.Click(selectTab)