Skip to content

Commit dcafbc9

Browse files
authored
Introduce CircleCI (#922)
* Introduce CircleCI With this PR, we introduce the CircleCI as a CI pipeline. The old configuration, TravisCI, is removed. A Makefile is also created to allow easier interaction with the different commands available. * Fix all linting issues * Fix goimports version
1 parent 28212d4 commit dcafbc9

18 files changed

+236
-84
lines changed

.circleci/config.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
version: 2.1
2+
3+
"-": &go-versions
4+
[ "1.18.10", "1.19.13", "1.20.14", "1.21.9", "1.22.2" ]
5+
6+
executors:
7+
go_executor:
8+
parameters:
9+
version:
10+
type: string
11+
docker:
12+
- image: cimg/go:<< parameters.version >>
13+
14+
jobs:
15+
test:
16+
parameters:
17+
go_version:
18+
type: string
19+
executor:
20+
name: go_executor
21+
version: << parameters.go_version >>
22+
steps:
23+
- checkout
24+
- restore_cache:
25+
keys:
26+
- go-mod-v4-{{ checksum "go.sum" }}
27+
- run:
28+
name: Install Dependencies
29+
command: go mod download
30+
- save_cache:
31+
key: go-mod-v4-{{ checksum "go.sum" }}
32+
paths:
33+
- "/go/pkg/mod"
34+
- run:
35+
name: Run tests
36+
command: |
37+
mkdir -p /tmp/test-reports
38+
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
39+
- store_test_results:
40+
path: /tmp/test-reports
41+
test-race:
42+
parameters:
43+
go_version:
44+
type: string
45+
executor:
46+
name: go_executor
47+
version: << parameters.go_version >>
48+
steps:
49+
- checkout
50+
- restore_cache:
51+
keys:
52+
- go-mod-v4-{{ checksum "go.sum" }}
53+
- run:
54+
name: Install Dependencies
55+
command: go mod download
56+
- save_cache:
57+
key: go-mod-v4-{{ checksum "go.sum" }}
58+
paths:
59+
- "/go/pkg/mod"
60+
- run:
61+
name: Run tests with race detector
62+
command: make test-race
63+
lint:
64+
parameters:
65+
go_version:
66+
type: string
67+
executor:
68+
name: go_executor
69+
version: << parameters.go_version >>
70+
steps:
71+
- checkout
72+
- restore_cache:
73+
keys:
74+
- go-mod-v4-{{ checksum "go.sum" }}
75+
- run:
76+
name: Install Dependencies
77+
command: go mod download
78+
- run:
79+
name: Install tooling
80+
command: |
81+
make tooling
82+
- save_cache:
83+
key: go-mod-v4-{{ checksum "go.sum" }}
84+
paths:
85+
- "/go/pkg/mod"
86+
- run:
87+
name: Linting
88+
command: make lint
89+
- run:
90+
name: Running vulncheck
91+
command: make vuln-check
92+
fmt:
93+
parameters:
94+
go_version:
95+
type: string
96+
executor:
97+
name: go_executor
98+
version: << parameters.go_version >>
99+
steps:
100+
- checkout
101+
- restore_cache:
102+
keys:
103+
- go-mod-v4-{{ checksum "go.sum" }}
104+
- run:
105+
name: Install Dependencies
106+
command: go mod download
107+
- run:
108+
name: Install tooling
109+
command: |
110+
make tooling
111+
- save_cache:
112+
key: go-mod-v4-{{ checksum "go.sum" }}
113+
paths:
114+
- "/go/pkg/mod"
115+
- run:
116+
name: Running formatting
117+
command: |
118+
make fmt
119+
make has-changes
120+
121+
workflows:
122+
version: 2
123+
build-and-test:
124+
jobs:
125+
- test:
126+
matrix:
127+
parameters:
128+
go_version: *go-versions
129+
- test-race:
130+
matrix:
131+
parameters:
132+
go_version: *go-versions
133+
- lint:
134+
matrix:
135+
parameters:
136+
go_version: *go-versions
137+
- fmt:
138+
matrix:
139+
parameters:
140+
go_version: *go-versions

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.ONESHELL:
2+
SHELL = /bin/sh
3+
.SHELLFLAGS = -ec
4+
5+
BASE_PACKAGE := github.com/jmoiron/sqlx
6+
7+
tooling:
8+
go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
9+
go install golang.org/x/vuln/cmd/govulncheck@v1.0.4
10+
go install golang.org/x/tools/cmd/goimports@v0.20.0
11+
12+
has-changes:
13+
git diff --exit-code --quiet HEAD --
14+
15+
lint:
16+
go vet ./...
17+
staticcheck -checks=all ./...
18+
19+
fmt:
20+
go list -f '{{.Dir}}' ./... | xargs -I {} goimports -local $(BASE_PACKAGE) -w {}
21+
22+
vuln-check:
23+
govulncheck ./...
24+
25+
test-race:
26+
go test -v -race -count=1 ./...
27+
28+
update-dependencies:
29+
go get -u -t -v ./...
30+
go mod tidy

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# sqlx
22

3-
[![Build Status](https://travis-ci.org/jmoiron/sqlx.svg?branch=master)](https://travis-ci.org/jmoiron/sqlx) [![Coverage Status](https://coveralls.io/repos/github/jmoiron/sqlx/badge.svg?branch=master)](https://coveralls.io/github/jmoiron/sqlx?branch=master) [![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/jmoiron/sqlx) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/jmoiron/sqlx/master/LICENSE)
3+
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/jmoiron/sqlx/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/jmoiron/sqlx/tree/master) [![Coverage Status](https://coveralls.io/repos/github/jmoiron/sqlx/badge.svg?branch=master)](https://coveralls.io/github/jmoiron/sqlx?branch=master) [![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/jmoiron/sqlx) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/jmoiron/sqlx/master/LICENSE)
44

55
sqlx is a library which provides a set of extensions on go's standard
66
`database/sql` library. The sqlx versions of `sql.DB`, `sql.TX`, `sql.Stmt`,

doc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
// Additions include scanning into structs, named query support, rebinding
99
// queries for different drivers, convenient shorthands for common error handling
1010
// and more.
11-
//
1211
package sqlx

named.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func bindArgs(names []string, arg interface{}, m *reflectx.Mapper) ([]interface{
174174
arglist := make([]interface{}, 0, len(names))
175175

176176
// grab the indirected value of arg
177-
v := reflect.ValueOf(arg)
177+
var v reflect.Value
178178
for v = reflect.ValueOf(arg); v.Kind() == reflect.Ptr; {
179179
v = v.Elem()
180180
}

named_context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build go1.8
12
// +build go1.8
23

34
package sqlx

named_context_test.go

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

34
package sqlx
@@ -18,12 +19,12 @@ func TestNamedContextQueries(t *testing.T) {
1819
ctx := context.Background()
1920

2021
// Check that invalid preparations fail
21-
ns, err = db.PrepareNamedContext(ctx, "SELECT * FROM person WHERE first_name=:first:name")
22+
_, err = db.PrepareNamedContext(ctx, "SELECT * FROM person WHERE first_name=:first:name")
2223
if err == nil {
2324
t.Error("Expected an error with invalid prepared statement.")
2425
}
2526

26-
ns, err = db.PrepareNamedContext(ctx, "invalid sql")
27+
_, err = db.PrepareNamedContext(ctx, "invalid sql")
2728
if err == nil {
2829
t.Error("Expected an error with invalid prepared statement.")
2930
}

named_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ func TestNamedQueries(t *testing.T) {
139139
var err error
140140

141141
// Check that invalid preparations fail
142-
ns, err = db.PrepareNamed("SELECT * FROM person WHERE first_name=:first:name")
142+
_, err = db.PrepareNamed("SELECT * FROM person WHERE first_name=:first:name")
143143
if err == nil {
144144
t.Error("Expected an error with invalid prepared statement.")
145145
}
146146

147-
ns, err = db.PrepareNamed("invalid sql")
147+
_, err = db.PrepareNamed("invalid sql")
148148
if err == nil {
149149
t.Error("Expected an error with invalid prepared statement.")
150150
}

reflectx/reflect.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// allows for Go-compatible named attribute access, including accessing embedded
44
// struct attributes and the ability to use functions and struct tags to
55
// customize field names.
6-
//
76
package reflectx
87

98
import (

0 commit comments

Comments
 (0)