From b656fa2ef1d2c161c88778f80cf7d6b0a5576958 Mon Sep 17 00:00:00 2001 From: go-jet Date: Thu, 15 Aug 2019 12:28:59 +0200 Subject: [PATCH] CircleCI update for MariaDB. --- .circleci/config.yml | 60 +++++++++++++++++++++++++++++++++++++++++++- tests/init/init.go | 5 +++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e4b7a9..8f941d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,7 +71,7 @@ jobs: sudo apt-get install default-mysql-client - run: - name: Init MySQL database + name: Create MySQL user and databases command: | mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';" mysql -h 127.0.0.1 -u root -pjet -e "set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';" @@ -99,3 +99,61 @@ jobs: - store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/ path: /tmp/test-results + build-mariadb: + docker: + # specify the version + - image: circleci/golang:1.11 + + - image: circleci/mariadb:10.4 + command: [--default-authentication-plugin=mysql_native_password] + environment: + MYSQL_ROOT_PASSWORD: jet + MYSQL_DATABASE: dvds + MYSQL_USER: jet + MYSQL_PASSWORD: jet + + working_directory: /go/src/github.com/go-jet/jet + + environment: # environment variables for the build itself + TEST_RESULTS: /tmp/test-results # path to where test results will be saved + + steps: + - checkout + + - run: + name: Install dependencies + command: | + go get github.com/google/uuid + go get github.com/lib/pq + go get github.com/go-sql-driver/mysql + + go get github.com/pkg/profile + go get gotest.tools/assert + go get github.com/davecgh/go-spew/spew + go get github.com/jstemmer/go-junit-report + + go install github.com/go-jet/jet/cmd/jet + +# - run: +# name: Install MySQL CLI; +# command: | +# sudo apt-get install default-mysql-client + + - run: + name: Init MariaDB database + command: | + mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';" + mysql -h 127.0.0.1 -u root -pjet -e "set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';" + mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample" + + - run: + name: Init MariaDB database + command: | + cd tests + go run ./init/init.go -testsuite MariaDB + cd .. + + - run: + name: Run MariaDB tests + command: | + go test -v ./tests/mysql/ -source=MariaDB diff --git a/tests/init/init.go b/tests/init/init.go index 1a6c0c4..1adbc15 100644 --- a/tests/init/init.go +++ b/tests/init/init.go @@ -12,6 +12,7 @@ import ( "io/ioutil" "os" "os/exec" + "strings" ) var testSuite string @@ -24,12 +25,14 @@ func init() { func main() { + testSuite = strings.ToLower(testSuite) + if testSuite == "postgres" { initPostgresDB() return } - if testSuite == "mysql" { + if testSuite == "mysql" || testSuite == "mariadb" { initMySQLDB() return }