Skip to content

Commit 2c5df87

Browse files
authored
Merge pull request #1072 from dhui/dktesting-cleanup
Delete db docker images after tests complete for a few large db docker images
2 parents 87ba13c + f4950c1 commit 2c5df87

File tree

9 files changed

+161
-32
lines changed

9 files changed

+161
-32
lines changed

.github/workflows/ci.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/setup-go@v5
1313
with:
14-
go-version: "1.21.x"
14+
go-version: "1.22.x"
1515
- uses: actions/checkout@v4
1616
- name: golangci-lint
1717
uses: golangci/golangci-lint-action@v3
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
go: ["1.20.x", "1.21.x"]
25+
go: ["1.21.x", "1.22.x"]
2626
steps:
2727
- uses: actions/checkout@v4
2828

@@ -68,7 +68,7 @@ jobs:
6868
ruby-version: 2.7
6969
- uses: actions/setup-go@v5
7070
with:
71-
go-version: "1.21.x"
71+
go-version: "1.22.x"
7272

7373
- uses: docker/setup-qemu-action@v3
7474
- uses: docker/setup-buildx-action@v3

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine3.19 AS builder
1+
FROM golang:1.22-alpine3.19 AS builder
22
ARG VERSION
33

44
RUN apk add --no-cache git gcc musl-dev make

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Coverage Status](https://img.shields.io/coveralls/github/golang-migrate/migrate/master.svg)](https://coveralls.io/github/golang-migrate/migrate?branch=master)
44
[![packagecloud.io](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/golang-migrate/migrate?filter=debs)
55
[![Docker Pulls](https://img.shields.io/docker/pulls/migrate/migrate.svg)](https://hub.docker.com/r/migrate/migrate/)
6-
![Supported Go Versions](https://img.shields.io/badge/Go-1.20%2C%201.21-lightgrey.svg)
6+
![Supported Go Versions](https://img.shields.io/badge/Go-1.21%2C%201.22-lightgrey.svg)
77
[![GitHub Release](https://img.shields.io/github/release/golang-migrate/migrate.svg)](https://github.com/golang-migrate/migrate/releases)
88
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-migrate/migrate/v4)](https://goreportcard.com/report/github.com/golang-migrate/migrate/v4)
99

database/cassandra/cassandra_test.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
6161
}
6262

6363
func Test(t *testing.T) {
64+
t.Run("test", test)
65+
t.Run("testMigrate", testMigrate)
66+
67+
t.Cleanup(func() {
68+
for _, spec := range specs {
69+
t.Log("Cleaning up ", spec.ImageName)
70+
if err := spec.Cleanup(); err != nil {
71+
t.Error("Error removing ", spec.ImageName, "error:", err)
72+
}
73+
}
74+
})
75+
}
76+
77+
func test(t *testing.T) {
6478
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
6579
ip, port, err := c.Port(9042)
6680
if err != nil {
@@ -81,7 +95,7 @@ func Test(t *testing.T) {
8195
})
8296
}
8397

84-
func TestMigrate(t *testing.T) {
98+
func testMigrate(t *testing.T) {
8599
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
86100
ip, port, err := c.Port(9042)
87101
if err != nil {

database/mongodb/mongodb_test.go

+28-3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
7474
}
7575

7676
func Test(t *testing.T) {
77+
t.Run("test", test)
78+
t.Run("testMigrate", testMigrate)
79+
t.Run("testWithAuth", testWithAuth)
80+
t.Run("testLockWorks", testLockWorks)
81+
82+
t.Cleanup(func() {
83+
for _, spec := range specs {
84+
t.Log("Cleaning up ", spec.ImageName)
85+
if err := spec.Cleanup(); err != nil {
86+
t.Error("Error removing ", spec.ImageName, "error:", err)
87+
}
88+
}
89+
})
90+
}
91+
92+
func test(t *testing.T) {
7793
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
7894
ip, port, err := c.FirstPort()
7995
if err != nil {
@@ -99,7 +115,7 @@ func Test(t *testing.T) {
99115
})
100116
}
101117

102-
func TestMigrate(t *testing.T) {
118+
func testMigrate(t *testing.T) {
103119
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
104120
ip, port, err := c.FirstPort()
105121
if err != nil {
@@ -125,7 +141,7 @@ func TestMigrate(t *testing.T) {
125141
})
126142
}
127143

128-
func TestWithAuth(t *testing.T) {
144+
func testWithAuth(t *testing.T) {
129145
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
130146
ip, port, err := c.FirstPort()
131147
if err != nil {
@@ -180,7 +196,7 @@ func TestWithAuth(t *testing.T) {
180196
})
181197
}
182198

183-
func TestLockWorks(t *testing.T) {
199+
func testLockWorks(t *testing.T) {
184200
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
185201
ip, port, err := c.FirstPort()
186202
if err != nil {
@@ -241,6 +257,15 @@ func TestTransaction(t *testing.T) {
241257
{ImageName: "mongo:4", Options: dktest.Options{PortRequired: true, ReadyFunc: isReady,
242258
Cmd: []string{"mongod", "--bind_ip_all", "--replSet", "rs0"}}},
243259
}
260+
t.Cleanup(func() {
261+
for _, spec := range transactionSpecs {
262+
t.Log("Cleaning up ", spec.ImageName)
263+
if err := spec.Cleanup(); err != nil {
264+
t.Error("Error removing ", spec.ImageName, "error:", err)
265+
}
266+
}
267+
})
268+
244269
dktesting.ParallelTest(t, transactionSpecs, func(t *testing.T, c dktest.ContainerInfo) {
245270
ip, port, err := c.FirstPort()
246271
if err != nil {

database/postgres/postgres_test.go

+39-13
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,32 @@ func mustRun(t *testing.T, d database.Driver, statements []string) {
8585
}
8686

8787
func Test(t *testing.T) {
88+
t.Run("test", test)
89+
t.Run("testMigrate", testMigrate)
90+
t.Run("testMultipleStatements", testMultipleStatements)
91+
t.Run("testMultipleStatementsInMultiStatementMode", testMultipleStatementsInMultiStatementMode)
92+
t.Run("testErrorParsing", testErrorParsing)
93+
t.Run("testFilterCustomQuery", testFilterCustomQuery)
94+
t.Run("testWithSchema", testWithSchema)
95+
t.Run("testMigrationTableOption", testMigrationTableOption)
96+
t.Run("testFailToCreateTableWithoutPermissions", testFailToCreateTableWithoutPermissions)
97+
t.Run("testCheckBeforeCreateTable", testCheckBeforeCreateTable)
98+
t.Run("testParallelSchema", testParallelSchema)
99+
t.Run("testPostgresLock", testPostgresLock)
100+
t.Run("testWithInstanceConcurrent", testWithInstanceConcurrent)
101+
t.Run("testWithConnection", testWithConnection)
102+
103+
t.Cleanup(func() {
104+
for _, spec := range specs {
105+
t.Log("Cleaning up ", spec.ImageName)
106+
if err := spec.Cleanup(); err != nil {
107+
t.Error("Error removing ", spec.ImageName, "error:", err)
108+
}
109+
}
110+
})
111+
}
112+
113+
func test(t *testing.T) {
88114
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
89115
ip, port, err := c.FirstPort()
90116
if err != nil {
@@ -106,7 +132,7 @@ func Test(t *testing.T) {
106132
})
107133
}
108134

109-
func TestMigrate(t *testing.T) {
135+
func testMigrate(t *testing.T) {
110136
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
111137
ip, port, err := c.FirstPort()
112138
if err != nil {
@@ -132,7 +158,7 @@ func TestMigrate(t *testing.T) {
132158
})
133159
}
134160

135-
func TestMultipleStatements(t *testing.T) {
161+
func testMultipleStatements(t *testing.T) {
136162
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
137163
ip, port, err := c.FirstPort()
138164
if err != nil {
@@ -165,7 +191,7 @@ func TestMultipleStatements(t *testing.T) {
165191
})
166192
}
167193

168-
func TestMultipleStatementsInMultiStatementMode(t *testing.T) {
194+
func testMultipleStatementsInMultiStatementMode(t *testing.T) {
169195
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
170196
ip, port, err := c.FirstPort()
171197
if err != nil {
@@ -198,7 +224,7 @@ func TestMultipleStatementsInMultiStatementMode(t *testing.T) {
198224
})
199225
}
200226

201-
func TestErrorParsing(t *testing.T) {
227+
func testErrorParsing(t *testing.T) {
202228
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
203229
ip, port, err := c.FirstPort()
204230
if err != nil {
@@ -227,7 +253,7 @@ func TestErrorParsing(t *testing.T) {
227253
})
228254
}
229255

230-
func TestFilterCustomQuery(t *testing.T) {
256+
func testFilterCustomQuery(t *testing.T) {
231257
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
232258
ip, port, err := c.FirstPort()
233259
if err != nil {
@@ -249,7 +275,7 @@ func TestFilterCustomQuery(t *testing.T) {
249275
})
250276
}
251277

252-
func TestWithSchema(t *testing.T) {
278+
func testWithSchema(t *testing.T) {
253279
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
254280
ip, port, err := c.FirstPort()
255281
if err != nil {
@@ -319,7 +345,7 @@ func TestWithSchema(t *testing.T) {
319345
})
320346
}
321347

322-
func TestMigrationTableOption(t *testing.T) {
348+
func testMigrationTableOption(t *testing.T) {
323349
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
324350
ip, port, err := c.FirstPort()
325351
if err != nil {
@@ -387,7 +413,7 @@ func TestMigrationTableOption(t *testing.T) {
387413
})
388414
}
389415

390-
func TestFailToCreateTableWithoutPermissions(t *testing.T) {
416+
func testFailToCreateTableWithoutPermissions(t *testing.T) {
391417
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
392418
ip, port, err := c.FirstPort()
393419
if err != nil {
@@ -457,7 +483,7 @@ func TestFailToCreateTableWithoutPermissions(t *testing.T) {
457483
})
458484
}
459485

460-
func TestCheckBeforeCreateTable(t *testing.T) {
486+
func testCheckBeforeCreateTable(t *testing.T) {
461487
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
462488
ip, port, err := c.FirstPort()
463489
if err != nil {
@@ -534,7 +560,7 @@ func TestCheckBeforeCreateTable(t *testing.T) {
534560
})
535561
}
536562

537-
func TestParallelSchema(t *testing.T) {
563+
func testParallelSchema(t *testing.T) {
538564
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
539565
ip, port, err := c.FirstPort()
540566
if err != nil {
@@ -602,7 +628,7 @@ func TestParallelSchema(t *testing.T) {
602628
})
603629
}
604630

605-
func TestPostgres_Lock(t *testing.T) {
631+
func testPostgresLock(t *testing.T) {
606632
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
607633
ip, port, err := c.FirstPort()
608634
if err != nil {
@@ -642,7 +668,7 @@ func TestPostgres_Lock(t *testing.T) {
642668
})
643669
}
644670

645-
func TestWithInstance_Concurrent(t *testing.T) {
671+
func testWithInstanceConcurrent(t *testing.T) {
646672
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
647673
ip, port, err := c.FirstPort()
648674
if err != nil {
@@ -685,7 +711,7 @@ func TestWithInstance_Concurrent(t *testing.T) {
685711
})
686712
}
687713

688-
func TestWithConnection(t *testing.T) {
714+
func testWithConnection(t *testing.T) {
689715
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
690716
ip, port, err := c.FirstPort()
691717
if err != nil {

database/sqlserver/sqlserver_test.go

+27-7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ func SkipIfUnsupportedArch(t *testing.T, c dktest.ContainerInfo) {
9696
}
9797

9898
func Test(t *testing.T) {
99+
t.Run("test", test)
100+
t.Run("testMigrate", testMigrate)
101+
t.Run("testMultiStatement", testMultiStatement)
102+
t.Run("testErrorParsing", testErrorParsing)
103+
t.Run("testLockWorks", testLockWorks)
104+
t.Run("testMsiTrue", testMsiTrue)
105+
t.Run("testOpenWithPasswordAndMSI", testOpenWithPasswordAndMSI)
106+
t.Run("testMsiFalse", testMsiFalse)
107+
108+
t.Cleanup(func() {
109+
for _, spec := range specs {
110+
t.Log("Cleaning up ", spec.ImageName)
111+
if err := spec.Cleanup(); err != nil {
112+
t.Error("Error removing ", spec.ImageName, "error:", err)
113+
}
114+
}
115+
})
116+
}
117+
118+
func test(t *testing.T) {
99119
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
100120
SkipIfUnsupportedArch(t, c)
101121
ip, port, err := c.Port(defaultPort)
@@ -120,7 +140,7 @@ func Test(t *testing.T) {
120140
})
121141
}
122142

123-
func TestMigrate(t *testing.T) {
143+
func testMigrate(t *testing.T) {
124144
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
125145
SkipIfUnsupportedArch(t, c)
126146
ip, port, err := c.Port(defaultPort)
@@ -149,7 +169,7 @@ func TestMigrate(t *testing.T) {
149169
})
150170
}
151171

152-
func TestMultiStatement(t *testing.T) {
172+
func testMultiStatement(t *testing.T) {
153173
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
154174
SkipIfUnsupportedArch(t, c)
155175
ip, port, err := c.Port(defaultPort)
@@ -183,7 +203,7 @@ func TestMultiStatement(t *testing.T) {
183203
})
184204
}
185205

186-
func TestErrorParsing(t *testing.T) {
206+
func testErrorParsing(t *testing.T) {
187207
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
188208
SkipIfUnsupportedArch(t, c)
189209
ip, port, err := c.Port(defaultPort)
@@ -215,7 +235,7 @@ func TestErrorParsing(t *testing.T) {
215235
})
216236
}
217237

218-
func TestLockWorks(t *testing.T) {
238+
func testLockWorks(t *testing.T) {
219239
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
220240
SkipIfUnsupportedArch(t, c)
221241
ip, port, err := c.Port(defaultPort)
@@ -254,7 +274,7 @@ func TestLockWorks(t *testing.T) {
254274
})
255275
}
256276

257-
func TestMsiTrue(t *testing.T) {
277+
func testMsiTrue(t *testing.T) {
258278
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
259279
SkipIfUnsupportedArch(t, c)
260280
ip, port, err := c.Port(defaultPort)
@@ -271,7 +291,7 @@ func TestMsiTrue(t *testing.T) {
271291
})
272292
}
273293

274-
func TestOpenWithPasswordAndMSI(t *testing.T) {
294+
func testOpenWithPasswordAndMSI(t *testing.T) {
275295
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
276296
SkipIfUnsupportedArch(t, c)
277297
ip, port, err := c.Port(defaultPort)
@@ -303,7 +323,7 @@ func TestOpenWithPasswordAndMSI(t *testing.T) {
303323
})
304324
}
305325

306-
func TestMsiFalse(t *testing.T) {
326+
func testMsiFalse(t *testing.T) {
307327
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
308328
SkipIfUnsupportedArch(t, c)
309329
ip, port, err := c.Port(defaultPort)

0 commit comments

Comments
 (0)