Skip to content

Commit

Permalink
ci/integration: update integration executor (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m authored Feb 27, 2021
1 parent dbebc47 commit aa7fd69
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 69 deletions.
85 changes: 67 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,78 @@
version: 2
version: 2.1

aliases:
- &mktestdir
run:
name: Create results directory
command: mkdir -p ~/test-results

- &storetestdir
store_test_results:
path: ~/test-results

orbs:
go: circleci/[email protected]

commands:
getmods:
steps:
- go/load-cache
- go/mod-download
- go/save-cache

jobs:
unit:
lint:
docker:
- image: circleci/golang:1.16
working_directory: /go/src/github.com/a8m/rql
- image: golangci/golangci-lint:v1.28-alpine
steps:
- checkout
- *mktestdir
- run:
name: Run linters
command: golangci-lint run --timeout 5m --out-format junit-xml > ~/test-results/lint.xml
- *storetestdir
unit:
executor:
name: go/default
tag: '1.16'
steps:
- checkout
- run: go get -v -t -d ./...
- run: go test -v

- *mktestdir
- getmods
- run:
name: Unit tests
command: gotestsum -f short-verbose --junitfile ~/test-results/rql.xml
working_directory: .
- *storetestdir
integration:
machine:
image: circleci/classic:201808-01
working_directory: /home/circleci/.go_workspace/src/github.com/a8m/rql
environment:
GOPATH: /home/circleci/.go_workspace
docker: &integration-docker
- image: circleci/golang:1.16
environment:
MYSQL_DSN: root:pass@tcp(localhost:3306)/test
- image: circleci/mysql
environment:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
steps:
- checkout
- run: make -C integration test
- checkout
- run: &integration-wait
name: Wait for databases
command: >-
dockerize -timeout 2m
-wait tcp://localhost:3306
- *mktestdir
- getmods
- run:
name: Run integration tests
working_directory: integration
command: gotestsum -f short-verbose --junitfile ~/test-results/integration.xml -- -race .
- *storetestdir

workflows:
version: 2
version: 2.1
all:
jobs:
- lint
- unit
- integration:
requires:
- unit
- integration

14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

16 changes: 13 additions & 3 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var p = MustNewParser(Config{

func BenchmarkLargeQuery(b *testing.B) {
for i := 0; i < b.N; i++ {
p.Parse([]byte(`{
_, err := p.Parse([]byte(`{
"filter": {
"admin": true,
"name": "foo",
Expand All @@ -64,12 +64,15 @@ func BenchmarkLargeQuery(b *testing.B) {
"offset": 100,
"limit": 10
}`))
if err != nil {
b.Error(err)
}
}
}

func BenchmarkMediumQuery(b *testing.B) {
for i := 0; i < b.N; i++ {
p.Parse([]byte(`{
_, err := p.Parse([]byte(`{
"filter": {
"name": "foo",
"address.name": "bar",
Expand All @@ -83,18 +86,25 @@ func BenchmarkMediumQuery(b *testing.B) {
"offset": 100,
"limit": 10
}`))
if err != nil {
b.Error(err)
}

}
}

func BenchmarkSmallQuery(b *testing.B) {
for i := 0; i < b.N; i++ {
p.Parse([]byte(`{
_, err := p.Parse([]byte(`{
"filter": {
"address.name": "TLV",
"admin": true
},
"offset": 25,
"limit": 10
}`))
if err != nil {
b.Error(err)
}
}
}
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module github.com/a8m/rql

require github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329
require (
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/jinzhu/gorm v1.9.16 // indirect
github.com/mailru/easyjson v0.7.7
)

go 1.13
go 1.16
30 changes: 30 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
5 changes: 0 additions & 5 deletions integration/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions integration/Makefile

This file was deleted.

20 changes: 0 additions & 20 deletions integration/docker-compose.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions integration/rql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
CreateTime, _ = time.Parse(time.RFC3339, "2000-05-16T16:00:00.000Z")
MySQLConn = os.Getenv("CONN_STRING")
MySQLConn = os.Getenv("MYSQL_DSN")
QueryParser = rql.MustNewParser(rql.Config{
Model: User{},
FieldSep: ".",
Expand Down Expand Up @@ -117,7 +117,7 @@ func AssertSelect(t *testing.T, db *gorm.DB, expected []string, query string) {

func Connect(t *testing.T) *gorm.DB {
if MySQLConn == "" {
t.Fatal("missing database connection string")
t.Skip("missing database connection string")
}
for i := 1; i <= 5; i++ {
db, err := gorm.Open("mysql", MySQLConn)
Expand Down

0 comments on commit aa7fd69

Please sign in to comment.