Repository navigation
150 lines (143 loc) · 5.17 KB
/
Copy pathci.yml
File metadata and controls
150 lines (143 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: CI
on:
push:
branches:
- master
- release/*
pull_request:
branches:
- master
- release/*
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
- name: Root module requires no other module
# The database drivers belong to the dbtest module only; a requirement
# here would reach every consumer's module graph.
run: |
out="$(go list -m all)"
if [ "$out" != "$(go list -m)" ]; then echo "go.mod requires:"; echo "$out"; exit 1; fi
- name: go vet
run: |
go vet ./...
(cd dbtest && go vet ./...)
- name: staticcheck
# v0.8.1 cannot read Go 1.27.2 export data ("export data version 5 is greater than maximum
# supported version 4"). This master build from 2026-10-09 can; pin a tagged release again
# once one is published.
run: |
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0-0.dev.0.20261009230814-452d5bb86b45 -checks=all ./...
(cd dbtest && go run honnef.co/go/tools/cmd/staticcheck@v0.7.0-0.dev.0.20261009230814-452d5bb86b45 -checks=all ./...)
- name: goimports
run: |
out="$(go run golang.org/x/tools/cmd/goimports@v0.52.0 -l -local "$(go list -m)" .)"
if [ -n "$out" ]; then echo "goimports would change:"; echo "$out"; exit 1; fi
- name: govulncheck
run: |
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
(cd dbtest && go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...)
test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
go:
- "1.24.x"
- "1.25.x"
- oldstable
- stable
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: sqlx
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 20
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: sqlx
MYSQL_DATABASE: sqlx
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 -psqlx"
--health-interval 5s
--health-timeout 5s
--health-retries 30
env:
CGO_ENABLED: "1"
SQLX_POSTGRES_DSN: postgres://postgres:sqlx@localhost:5432/postgres?sslmode=disable
SQLX_MYSQL_DSN: root:sqlx@tcp(127.0.0.1:3306)/sqlx
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go }}
- name: Unit tests with the race detector
run: go test -race -count=1 ./...
- name: Database tests with the race detector against Postgres, MySQL and SQLite
working-directory: dbtest
env:
SQLX_SQLITE_DSN: ${{ runner.temp }}/sqlx.db
run: |
go test -race -count=1 -v ./... 2>&1 | tee ../test.log
test "${PIPESTATUS[0]}" -eq 0
- name: Fail if a database was skipped
# init() prints "Disabling ..." and the schema tests then run zero rounds for that database.
run: |
if grep -n "Disabling" test.log; then exit 1; fi
apidiff:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
- name: Export the v1.4.0 API under the fork's module path
# The export is written and read in this same job, with one toolchain,
# because export data is bound to the Go version that produced it.
run: |
git worktree add "${{ runner.temp }}/v1.4.0" v1.4.0
cd "${{ runner.temp }}/v1.4.0"
sed -i 's#github.com/jmoiron/sqlx#github.com/secondwindoss/sqlx#g' go.mod $(git ls-files '*.go')
go run golang.org/x/exp/cmd/apidiff@v0.0.0-20261009195045-ca0d7ba23607 -m -w "${{ runner.temp }}/v1.4.0.export" github.com/secondwindoss/sqlx
- name: Fail on any incompatible change since v1.4.0
run: |
out="$(go run golang.org/x/exp/cmd/apidiff@v0.0.0-20261009195045-ca0d7ba23607 -m -incompatible "${{ runner.temp }}/v1.4.0.export" github.com/secondwindoss/sqlx)"
if [ -n "$out" ]; then echo "$out"; exit 1; fi
go run golang.org/x/exp/cmd/apidiff@v0.0.0-20261009195045-ca0d7ba23607 -m "${{ runner.temp }}/v1.4.0.export" github.com/secondwindoss/sqlx
ci-ok:
if: always()
needs:
- lint
- test
- apidiff
runs-on: ubuntu-latest
steps:
- name: Check required jobs
if: >-
contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
run: exit 1