Skip to content

Commit

Permalink
Merge pull request #444 from GoAdminGroup/pre-release
Browse files Browse the repository at this point in the history
add drone ci
  • Loading branch information
cg33 authored Jun 1, 2021
2 parents b26e642 + 79105d1 commit 07a1d1b
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 68 deletions.
164 changes: 164 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -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
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/[email protected]
sudo chmod -R 777 $(GOPATH)/pkg/mod/github.com/gogf/[email protected]/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/[email protected]/net/ghttp/ghttp_server_handler.go

cp-mod:
cp go.mod go.mod.old
cp go.sum go.sum.old
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</p>

<p align="center">
<a href="https://travis-ci.com/GoAdminGroup/go-admin"><img alt="Go Report Card" src="https://api.travis-ci.com/GoAdminGroup/go-admin.svg?branch=master"></a>
<a href="http://drone.go-admin.com/GoAdminGroup/go-admin"><img alt="Build Status" src="http://drone.go-admin.com/api/badges/GoAdminGroup/go-admin/status.svg?ref=refs/heads/master"></a>
<a href="https://goreportcard.com/report/github.com/GoAdminGroup/go-admin"><img alt="Go Report Card" src="https://camo.githubusercontent.com/59eed852617e19c272a4a4764fd09c669957fe75/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f6368656e6867352f676f2d61646d696e"></a>
<a href="https://goreportcard.com/report/github.com/GoAdminGroup/go-admin"><img alt="golang" src="https://img.shields.io/badge/awesome-golang-blue.svg"></a>
<a href="https://t.me/joinchat/NlyH6Bch2QARZkArithKvg" rel="nofollow"><img alt="telegram" src="https://img.shields.io/badge/chat%20on-telegram-blue" style="max-width:100%;"></a>
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
遗失的Golang编写的数据可视化与管理平台构建框架
</p>
<p align="center">
<a href="https://travis-ci.com/GoAdminGroup/go-admin"><img alt="Go Report Card" src="https://api.travis-ci.com/GoAdminGroup/go-admin.svg?branch=master"></a>
<a href="http://drone.go-admin.com/GoAdminGroup/go-admin"><img alt="Build Status" src="http://drone.go-admin.com/api/badges/GoAdminGroup/go-admin/status.svg?ref=refs/heads/master"></a>
<a href="https://goreportcard.com/report/github.com/GoAdminGroup/go-admin"><img alt="Go Report Card" src="https://camo.githubusercontent.com/59eed852617e19c272a4a4764fd09c669957fe75/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f6368656e6867352f676f2d61646d696e"></a>
<a href="https://goreportcard.com/report/github.com/GoAdminGroup/go-admin"><img alt="golang" src="https://img.shields.io/badge/awesome-golang-blue.svg"></a>
<a href="https://t.me/joinchat/NlyH6Bch2QARZkArithKvg" rel="nofollow"><img alt="telegram" src="https://img.shields.io/badge/chat%20on-telegram-blue" style="max-width:100%;"></a>
Expand Down
2 changes: 1 addition & 1 deletion tests/common/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"database": {
"default": {
"host": "127.0.0.1",
"host": "db_mysql",
"port": "3306",
"user": "root",
"pwd": "root",
Expand Down
2 changes: 1 addition & 1 deletion tests/common/config_ms.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"database": {
"default": {
"host": "127.0.0.1",
"host": "db_mssql",
"port": "1433",
"user": "sa",
"pwd": "Aa123456",
Expand Down
2 changes: 1 addition & 1 deletion tests/common/config_pg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"database": {
"default": {
"host": "127.0.0.1",
"host": "db_pgsql",
"port": "5432",
"user": "postgres",
"pwd": "root",
Expand Down
3 changes: 1 addition & 2 deletions tests/frameworks/gf/gf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion tests/web/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"database": {
"default": {
"host": "127.0.0.1",
"host": "db_mysql",
"port": "3306",
"user": "root",
"pwd": "root",
Expand Down
2 changes: 1 addition & 1 deletion tests/web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 07a1d1b

Please sign in to comment.