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/87.0.4280.88/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