diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..2c2a3ea9 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,125 @@ +name: Tests +on: [push] +jobs: + mysql-tests: + name: MySQL tests + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3307:3306 + # needed because the mysql container does not provide a healthcheck + options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + - name: Checkout Code + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Get dependencies + run: | + go get -v -tags sqlite -t -d ./... + - name: Build and run soda + env: + SODA_DIALECT: "mysql" + MYSQL_PORT: 3307 + run: | + go build -v -tags sqlite -o tsoda ./soda + ./tsoda drop -e $SODA_DIALECT -p ./testdata/migrations + ./tsoda create -e $SODA_DIALECT -p ./testdata/migrations + ./tsoda migrate -e $SODA_DIALECT -p ./testdata/migrations + - name: Test + env: + SODA_DIALECT: "mysql" + MYSQL_PORT: 3307 + run: | + go test -tags sqlite -race ./... + + pg-tests: + name: PostgreSQL tests + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + - name: Checkout Code + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Get dependencies + run: | + go get -v -tags sqlite -t -d ./... + - name: Build and run soda + env: + SODA_DIALECT: "postgres" + POSTGRESQL_URL: "postgres://postgres:postgres@${{job.services.postgres.host}}:${{ job.services.postgres.ports[5432] }}/pop_test?sslmode=disable" + run: | + go build -v -tags sqlite -o tsoda ./soda + ./tsoda drop -e $SODA_DIALECT -p ./testdata/migrations + ./tsoda create -e $SODA_DIALECT -p ./testdata/migrations + ./tsoda migrate -e $SODA_DIALECT -p ./testdata/migrations + - name: Test + env: + SODA_DIALECT: "postgres" + POSTGRESQL_URL: "postgres://postgres:postgres@${{job.services.postgres.host}}:${{ job.services.postgres.ports[5432] }}/pop_test?sslmode=disable" + run: | + go test -tags sqlite -race ./... + + sqlite-tests: + name: SQLite tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + - name: Checkout Code + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Get dependencies + run: | + go get -v -tags sqlite -t -d ./... + - name: Build and run soda + env: + SODA_DIALECT: "sqlite" + run: | + go build -v -tags sqlite -o tsoda ./soda + ./tsoda drop -e $SODA_DIALECT -p ./testdata/migrations + ./tsoda create -e $SODA_DIALECT -p ./testdata/migrations + ./tsoda migrate -e $SODA_DIALECT -p ./testdata/migrations + shell: bash + - name: Test + env: + SODA_DIALECT: "sqlite" + run: | + go test -tags sqlite -race ./... diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d29a425..c14c2a3b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,50 +4,11 @@ variables: 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.13 (off) sqlite: - go_version: "1.13" - GO111MODULE: "off" - SODA_DIALECT: "sqlite" - steps: - - template: azure-tests.yml - -- job: macOS - pool: - vmImage: "macOS-10.13" - strategy: - matrix: - # SQLite3 - go 1.13 (off) sqlite: - go_version: "1.13" - GO111MODULE: "off" - SODA_DIALECT: "sqlite" - steps: - - template: azure-tests.yml - - job: Linux pool: vmImage: "ubuntu-16.04" strategy: matrix: - # Postgres - go 1.11 (off) postgres: - go_version: "1.11.5" - GO111MODULE: "off" - SODA_DIALECT: "postgres" - go 1.12 (off) postgres: - go_version: "1.12" - GO111MODULE: "off" - SODA_DIALECT: "postgres" - go 1.13 (off) postgres: - go_version: "1.13" - GO111MODULE: "off" - SODA_DIALECT: "postgres" # Cockroach go 1.13 (off) cockroach: go_version: "1.13" @@ -58,16 +19,5 @@ jobs: go_version: "1.13" GO111MODULE: "off" SODA_DIALECT: "cockroach_ssl" - # MySQL - go 1.13 (off) mysql: - go_version: "1.13" - GO111MODULE: "off" - SODA_DIALECT: "mysql" - MYSQL_PORT: "3307" - # SQLite3 - go 1.13 (off) sqlite: - go_version: "1.13" - GO111MODULE: "off" - SODA_DIALECT: "sqlite" steps: - template: azure-tests.yml \ No newline at end of file diff --git a/database.yml b/database.yml index d18679cc..e7d66b08 100644 --- a/database.yml +++ b/database.yml @@ -9,7 +9,7 @@ mysql: readTimeout: 5s postgres: - url: "postgres://postgres:postgres@localhost:5432/pop_test?sslmode=disable" + url: {{ envOr "POSTGRESQL_URL" "postgres://postgres:postgres@localhost:5432/pop_test?sslmode=disable" }} pool: 25 cockroach: diff --git a/soda/cmd/generate/config_cmd_test.go b/soda/cmd/generate/config_cmd_test.go index bed2d0e2..51f21d7c 100644 --- a/soda/cmd/generate/config_cmd_test.go +++ b/soda/cmd/generate/config_cmd_test.go @@ -3,10 +3,8 @@ package generate import ( "io/ioutil" "os" - "path/filepath" "testing" - "github.com/gobuffalo/envy" "github.com/stretchr/testify/require" ) @@ -15,10 +13,7 @@ func Test_ConfigCmd_NoArg(t *testing.T) { c := ConfigCmd c.SetArgs([]string{}) - gp, err := envy.MustGet("GOPATH") - r.NoError(err) - cpath := filepath.Join(gp, "src", "github.com", "gobuffalo") - tdir, err := ioutil.TempDir(cpath, "testapp") + tdir, err := ioutil.TempDir("", "testapp") r.NoError(err) defer os.RemoveAll(tdir) diff --git a/soda/cmd/generate/fizz_cmd_test.go b/soda/cmd/generate/fizz_cmd_test.go index 826b2456..2594e97c 100644 --- a/soda/cmd/generate/fizz_cmd_test.go +++ b/soda/cmd/generate/fizz_cmd_test.go @@ -3,10 +3,8 @@ package generate import ( "io/ioutil" "os" - "path/filepath" "testing" - "github.com/gobuffalo/envy" "github.com/stretchr/testify/require" ) @@ -15,10 +13,7 @@ func Test_FizzCmd_NoArg(t *testing.T) { c := FizzCmd c.SetArgs([]string{}) - gp, err := envy.MustGet("GOPATH") - r.NoError(err) - cpath := filepath.Join(gp, "src", "github.com", "gobuffalo") - tdir, err := ioutil.TempDir(cpath, "testapp") + tdir, err := ioutil.TempDir("", "testapp") r.NoError(err) defer os.RemoveAll(tdir) diff --git a/soda/cmd/generate/model_cmd_test.go b/soda/cmd/generate/model_cmd_test.go index 0832b8f5..a70bc2e5 100644 --- a/soda/cmd/generate/model_cmd_test.go +++ b/soda/cmd/generate/model_cmd_test.go @@ -6,7 +6,6 @@ import ( "path/filepath" "testing" - "github.com/gobuffalo/envy" "github.com/stretchr/testify/require" ) @@ -15,10 +14,7 @@ func Test_ModelCmd_NoArg(t *testing.T) { c := ModelCmd c.SetArgs([]string{}) - gp, err := envy.MustGet("GOPATH") - r.NoError(err) - cpath := filepath.Join(gp, "src", "github.com", "gobuffalo") - tdir, err := ioutil.TempDir(cpath, "testapp") + tdir, err := ioutil.TempDir("", "testapp") r.NoError(err) defer os.RemoveAll(tdir) @@ -36,10 +32,7 @@ func Test_ModelCmd_NameOnly(t *testing.T) { c := ModelCmd c.SetArgs([]string{"users"}) - gp, err := envy.MustGet("GOPATH") - r.NoError(err) - cpath := filepath.Join(gp, "src", "github.com", "gobuffalo") - tdir, err := ioutil.TempDir(cpath, "testapp") + tdir, err := ioutil.TempDir("", "testapp") r.NoError(err) defer os.RemoveAll(tdir)