Skip to content

Commit cf0b73c

Browse files
authored
chore: Introduce CI Pipeline
1 parent 332aaac commit cf0b73c

File tree

7 files changed

+95
-30
lines changed

7 files changed

+95
-30
lines changed

.github/workflows/test.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Code-Testing
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
services:
12+
postgres:
13+
image: postgres
14+
ports:
15+
- 5432:5432
16+
env:
17+
POSTGRES_USER: postgres
18+
POSTGRES_DB: sqlxtest
19+
POSTGRES_PASSWORD: postgres
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
mysql:
26+
image: mysql
27+
ports:
28+
- 3306:3306
29+
env:
30+
MYSQL_USER: mysql
31+
MYSQL_DATABASE: sqlxtest
32+
MYSQL_PASSWORD: mysql
33+
MYSQL_ROOT_PASSWORD: mysql
34+
options: >-
35+
--health-cmd="mysqladmin ping"
36+
--health-interval=10s
37+
--health-timeout=5s
38+
--health-retries=3
39+
40+
steps:
41+
- name: "Checkout Code"
42+
uses: actions/checkout@v2
43+
44+
- name: "Install Golang"
45+
uses: actions/setup-go@v4
46+
with:
47+
go-version: "^1.20"
48+
49+
- name: "Install all dependencies"
50+
run: |
51+
go mod download
52+
53+
- name: "Install Gotestsum"
54+
run: |
55+
go install gotest.tools/gotestsum@latest
56+
57+
- name: "Run Tests"
58+
env:
59+
SQLX_POSTGRES_DSN: "postgres://postgres:postgres@127.0.0.1:5432/sqlxtest?sslmode=disable"
60+
SQLX_MYSQL_DSN: ""
61+
SQLX_SQLITE_DSN: "./sqlxtest.sqlite"
62+
run: |
63+
gotestsum --format testname ./...

bind.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"sync"
1111

12-
"github.com/jmoiron/sqlx/reflectx"
12+
"github.com/go-sqlx/sqlx/reflectx"
1313
)
1414

1515
// Bindvar types supported by Rebind, BindMap and BindStruct.

named.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"strconv"
2222
"unicode"
2323

24-
"github.com/jmoiron/sqlx/reflectx"
24+
"github.com/go-sqlx/sqlx/reflectx"
2525
)
2626

2727
// NamedStmt is a prepared statement that executes named queries. Prepare it

reflectx/reflect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func TestMustBe(t *testing.T) {
850850
t.Error("expected panic with *reflect.ValueError")
851851
return
852852
}
853-
if valueErr.Method != "github.com/jmoiron/sqlx/reflectx.TestMustBe" {
853+
if valueErr.Method != "github.com/go-sqlx/sqlx/reflectx.TestMustBe" {
854854
}
855855
if valueErr.Kind != reflect.String {
856856
t.Errorf("unexpected Kind: %s", valueErr.Kind)

sqlx.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"strings"
1313
"sync"
1414

15-
"github.com/jmoiron/sqlx/reflectx"
15+
"github.com/go-sqlx/sqlx/reflectx"
1616
)
1717

1818
// Although the NameMapper is convenient, in practice it should not
@@ -51,9 +51,9 @@ func mapper() *reflectx.Mapper {
5151

5252
// isScannable takes the reflect.Type and the actual dest value and returns
5353
// whether or not it's Scannable. Something is scannable if:
54-
// * it is not a struct
55-
// * it implements sql.Scanner
56-
// * it has no exported fields
54+
// - it is not a struct
55+
// - it implements sql.Scanner
56+
// - it has no exported fields
5757
func isScannable(t reflect.Type) bool {
5858
if reflect.PtrTo(t).Implements(_scannerInterface) {
5959
return true
@@ -884,9 +884,9 @@ func structOnlyError(t reflect.Type) error {
884884
// then each row must only have one column which can scan into that type. This
885885
// allows you to do something like:
886886
//
887-
// rows, _ := db.Query("select id from people;")
888-
// var ids []int
889-
// scanAll(rows, &ids, false)
887+
// rows, _ := db.Query("select id from people;")
888+
// var ids []int
889+
// scanAll(rows, &ids, false)
890890
//
891891
// and ids will be a list of the id results. I realize that this is a desirable
892892
// interface to expose to users, but for now it will only be exposed via changes

sqlx_context_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
//go:build go1.8
12
// +build go1.8
23

34
// The following environment variables, if set, will be used:
45
//
5-
// * SQLX_SQLITE_DSN
6-
// * SQLX_POSTGRES_DSN
7-
// * SQLX_MYSQL_DSN
6+
// - SQLX_SQLITE_DSN
7+
// - SQLX_POSTGRES_DSN
8+
// - SQLX_MYSQL_DSN
89
//
910
// Set any of these variables to 'skip' to skip them. Note that for MySQL,
1011
// the string '?parseTime=True' will be appended to the DSN if it's not there
1112
// already.
12-
//
1313
package sqlx
1414

1515
import (
@@ -23,7 +23,7 @@ import (
2323
"time"
2424

2525
_ "github.com/go-sql-driver/mysql"
26-
"github.com/jmoiron/sqlx/reflectx"
26+
"github.com/go-sqlx/sqlx/reflectx"
2727
_ "github.com/lib/pq"
2828
_ "github.com/mattn/go-sqlite3"
2929
)

sqlx_test.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// The following environment variables, if set, will be used:
22
//
3-
// * SQLX_SQLITE_DSN
4-
// * SQLX_POSTGRES_DSN
5-
// * SQLX_MYSQL_DSN
3+
// - SQLX_SQLITE_DSN
4+
// - SQLX_POSTGRES_DSN
5+
// - SQLX_MYSQL_DSN
66
//
77
// Set any of these variables to 'skip' to skip them. Note that for MySQL,
88
// the string '?parseTime=True' will be appended to the DSN if it's not there
99
// already.
10-
//
1110
package sqlx
1211

1312
import (
@@ -23,7 +22,7 @@ import (
2322
"time"
2423

2524
_ "github.com/go-sql-driver/mysql"
26-
"github.com/jmoiron/sqlx/reflectx"
25+
"github.com/go-sqlx/sqlx/reflectx"
2726
_ "github.com/lib/pq"
2827
_ "github.com/mattn/go-sqlite3"
2928
)
@@ -62,34 +61,37 @@ func ConnectAll() {
6261
mydsn += "?parseTime=true"
6362
}
6463

64+
var didRunTests bool = false
6565
if TestPostgres {
6666
pgdb, err = Connect("postgres", pgdsn)
6767
if err != nil {
6868
fmt.Printf("Disabling PG tests:\n %v\n", err)
6969
TestPostgres = false
70+
} else {
71+
didRunTests = true
7072
}
71-
} else {
72-
fmt.Println("Disabling Postgres tests.")
7373
}
74-
7574
if TestMysql {
7675
mysqldb, err = Connect("mysql", mydsn)
7776
if err != nil {
78-
fmt.Printf("Disabling MySQL tests:\n %v", err)
77+
fmt.Printf("Disabling MySQL tests:\n %v\n", err)
7978
TestMysql = false
79+
} else {
80+
didRunTests = true
8081
}
81-
} else {
82-
fmt.Println("Disabling MySQL tests.")
8382
}
84-
8583
if TestSqlite {
8684
sldb, err = Connect("sqlite3", sqdsn)
8785
if err != nil {
88-
fmt.Printf("Disabling SQLite:\n %v", err)
86+
fmt.Printf("Disabling SQLite:\n %v\n", err)
8987
TestSqlite = false
88+
} else {
89+
didRunTests = true
9090
}
91-
} else {
92-
fmt.Println("Disabling SQLite tests.")
91+
}
92+
93+
if didRunTests == false {
94+
panic("No Database connected to")
9395
}
9496
}
9597

0 commit comments

Comments
 (0)