From ac4b9af63a6bf3afd76a15511713cb9c4eb0cdaa Mon Sep 17 00:00:00 2001 From: Stanislas Michalak Date: Sat, 16 Mar 2019 08:30:09 +0100 Subject: [PATCH] WIP azure pipelines (#44) Azure pipelines --- .travis.yml | 75 ----------------------------------- azure-pipelines.yml | 97 +++++++++++++++++++++++++++++++++++++++++++++ azure-tests.yml | 58 +++++++++++++++++++++++++++ bubbler_test.go | 5 ++- database.yml | 10 +---- tables.go | 3 ++ 6 files changed, 163 insertions(+), 85 deletions(-) delete mode 100644 .travis.yml create mode 100644 azure-pipelines.yml create mode 100644 azure-tests.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e1646303..00000000 --- a/.travis.yml +++ /dev/null @@ -1,75 +0,0 @@ -dist: trusty -sudo: required -language: go - -install: - - go get -t -v ./... - - go get -v -tags sqlite github.com/gobuffalo/pop/soda - -before_script: - - soda create -e $SODA_DIALECT - - soda migrate -e $SODA_DIALECT - -script: - - go test -tags sqlite ./... -v - -global_env: - - MYSQL_USER="travis" - - MYSQL_PASSWORD="" - - POSTGRES_PASSWORD="" - -.mysql: &mysql - services: - - mysql - addons: - apt: - sources: - - mysql-5.7-trusty - packages: - - mysql-server - -.postgres: &postgres - addons: - postgresql: "9.5" - -.mariadb: &mariadb - addons: - mariadb: '10.0' - -matrix: - include: - - dist: trusty - go: 1.9 - env: SODA_DIALECT="postgres" - <<: *postgres - - dist: trusty - go: 1.9 - env: SODA_DIALECT="mysql_travis" - <<: *mysql - - dist: trusty - go: 1.9 - env: SODA_DIALECT="sqlite" - - dist: trusty - go: "1.10" - env: SODA_DIALECT="postgres" - <<: *postgres - - dist: trusty - go: "1.10" - env: SODA_DIALECT="mysql_travis" - <<: *mysql - - dist: trusty - go: "1.10" - env: SODA_DIALECT="sqlite" - - dist: trusty - go: "tip" - env: SODA_DIALECT="postgres" - <<: *postgres - - dist: trusty - go: "tip" - env: SODA_DIALECT="mysql_travis" - <<: *mysql - - dist: trusty - go: "tip" - env: SODA_DIALECT="sqlite" - allow_failures: - - go: 'tip' \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..066ac638 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,97 @@ + +variables: + GOBIN: "$(GOPATH)/bin" # Go binaries path + GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path + modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code + +jobs: +- job: Windows + pool: + vmImage: "vs2017-win2016" + strategy: + matrix: + # SQLite3 + go 1.12 (on) sqlite: + go_version: "1.12" + GO111MODULE: "on" + SODA_DIALECT: "sqlite" + go 1.12 (off) sqlite: + go_version: "1.12" + GO111MODULE: "off" + SODA_DIALECT: "sqlite" + steps: + - template: azure-tests.yml + +- job: macOS + pool: + vmImage: "macOS-10.13" + strategy: + matrix: + # SQLite3 + go 1.12 (on) sqlite: + go_version: "1.12" + GO111MODULE: "on" + SODA_DIALECT: "sqlite" + go 1.12 (off) sqlite: + go_version: "1.12" + GO111MODULE: "off" + SODA_DIALECT: "sqlite" + steps: + - template: azure-tests.yml + +- job: Linux + pool: + vmImage: "ubuntu-16.04" + strategy: + matrix: + # Postgres + go 1.10 postgres: + go_version: "1.10" + SODA_DIALECT: "postgres" + go 1.11 (on) postgres: + go_version: "1.11.5" + GO111MODULE: "on" + SODA_DIALECT: "postgres" + go 1.11 (off) postgres: + go_version: "1.11.5" + GO111MODULE: "off" + SODA_DIALECT: "postgres" + go 1.12 (on) postgres: + go_version: "1.12" + GO111MODULE: "on" + SODA_DIALECT: "postgres" + go 1.12 (off) postgres: + go_version: "1.12" + GO111MODULE: "off" + SODA_DIALECT: "postgres" + # Cockroach + go 1.12 (on) cockroach: + go_version: "1.12" + GO111MODULE: "on" + SODA_DIALECT: "cockroach" + go 1.12 (off) cockroach: + go_version: "1.12" + GO111MODULE: "off" + SODA_DIALECT: "cockroach" + # MySQL + go 1.12 (on) mysql: + go_version: "1.12" + GO111MODULE: "on" + SODA_DIALECT: "mysql" + MYSQL_PORT: "3307" + go 1.12 (off) mysql: + go_version: "1.12" + GO111MODULE: "off" + SODA_DIALECT: "mysql" + MYSQL_PORT: "3307" + # SQLite3 + go 1.12 (on) sqlite: + go_version: "1.12" + GO111MODULE: "on" + SODA_DIALECT: "sqlite" + go 1.12 (off) sqlite: + go_version: "1.12" + GO111MODULE: "off" + SODA_DIALECT: "sqlite" + steps: + - template: azure-tests.yml \ No newline at end of file diff --git a/azure-tests.yml b/azure-tests.yml new file mode 100644 index 00000000..8ada323a --- /dev/null +++ b/azure-tests.yml @@ -0,0 +1,58 @@ +steps: + - task: GoTool@0 + inputs: + version: $(go_version) + - task: Bash@3 + inputs: + targetType: inline + script: | + mkdir -p "$(GOBIN)" + mkdir -p "$(GOPATH)/pkg" + mkdir -p "$(modulePath)" + shopt -s extglob + mv !(gopath) "$(modulePath)" + displayName: "Setup Go Workspace" + - task: Docker@1 + displayName: Run postgres image + inputs: + command: run + imageName: postgres:9.6 + ports: "5432:5432" + envVars: POSTGRES_DB=pop_test + condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'postgres')) + - task: Docker@1 + displayName: Run mysql image + inputs: + command: run + imageName: mysql:5.7 + ports: "3307:3306" + envVars: | + MYSQL_ROOT_PASSWORD=root + MYSQL_DATABASE=pop_test + MYSQL_USER=pop + MYSQL_PASSWORD=pop + condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'mysql')) + - task: Docker@1 + displayName: Run cockroach image + inputs: + command: run + imageName: cockroachdb/cockroach:v1.1.1 + ports: "26257:26257" + containerCommand: start --insecure + condition: and(succeeded(), eq(variables['SODA_DIALECT'], 'cockroach')) + - task: Bash@3 + inputs: + targetType: inline + script: | + GO111MODULE=off go get -v -tags sqlite github.com/gobuffalo/pop/soda + displayName: "Install soda" + - script: | + $(GOBIN)/soda create -e $(SODA_DIALECT) + $(GOBIN)/soda migrate -e $(SODA_DIALECT) + workingDirectory: "$(modulePath)" + displayName: "Create DB & run migrations" + - script: | + go get -t -v ./... + go test -race -v ./... + workingDirectory: "$(modulePath)" + displayName: "Tests" \ No newline at end of file diff --git a/bubbler_test.go b/bubbler_test.go index dacaecb9..400e656b 100644 --- a/bubbler_test.go +++ b/bubbler_test.go @@ -2,6 +2,7 @@ package fizz import ( "bytes" + "strings" "testing" "github.com/stretchr/testify/require" @@ -15,7 +16,7 @@ func Test_Exec(t *testing.T) { bb := &bytes.Buffer{} c := f.Exec(bb) c("echo hello") - r.Equal("hello\n", bb.String()) + r.Equal("hello", strings.TrimSpace(bb.String())) } func Test_ExecQuoted(t *testing.T) { @@ -27,5 +28,5 @@ func Test_ExecQuoted(t *testing.T) { c := f.Exec(bb) // without proper splitting we would get "'a b c'" c("echo 'a b c'") - r.Equal("a b c\n", bb.String()) + r.Equal("a b c", strings.TrimSpace(bb.String())) } diff --git a/database.yml b/database.yml index fcbdbe92..c877e101 100644 --- a/database.yml +++ b/database.yml @@ -6,14 +6,6 @@ mysql: user: {{ envOr "MYSQL_USER" "root" }} password: {{ envOr "MYSQL_PASSWORD" "root" }} -mysql_travis: - dialect: "mysql" - database: "pop_test" - host: {{ envOr "MYSQL_HOST" "127.0.0.1" }} - port: {{ envOr "MYSQL_PORT" "3306" }} - user: {{ envOr "MYSQL_USER" "root" }} - password: {{ envOr "MYSQL_PASSWORD" "" }} - postgres: url: "postgres://postgres:postgres@localhost:5432/pop_test?sslmode=disable" pool: 25 @@ -26,6 +18,8 @@ cockroach: port: {{ envOr "COCKROACH_PORT" "26257" }} user: {{ envOr "COCKROACH_USER" "root" }} password: {{ envOr "COCKROACH_PASSWORD" "" }} + options: + sslmode: disable sqlserver: dialect: "sqlserver" diff --git a/tables.go b/tables.go index 8b7626c0..44fdc9f3 100644 --- a/tables.go +++ b/tables.go @@ -97,6 +97,9 @@ func (t *Table) Column(name string, colType string, options Options) error { Options: options, Primary: primary, } + if t.columnsCache == nil { + t.columnsCache = make(map[string]struct{}) + } t.columnsCache[name] = struct{}{} // Ensure id is first if name == "id" {