Skip to content

Commit

Permalink
Move tests to GitHub actions (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislas-m authored Dec 7, 2019
1 parent 75bc832 commit ce5cc01
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 72 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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 ./...
50 changes: 0 additions & 50 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
2 changes: 1 addition & 1 deletion database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 1 addition & 6 deletions soda/cmd/generate/config_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package generate
import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/gobuffalo/envy"
"github.com/stretchr/testify/require"
)

Expand All @@ -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)

Expand Down
7 changes: 1 addition & 6 deletions soda/cmd/generate/fizz_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package generate
import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/gobuffalo/envy"
"github.com/stretchr/testify/require"
)

Expand All @@ -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)

Expand Down
11 changes: 2 additions & 9 deletions soda/cmd/generate/model_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"path/filepath"
"testing"

"github.com/gobuffalo/envy"
"github.com/stretchr/testify/require"
)

Expand All @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit ce5cc01

Please sign in to comment.