Skip to content

Commit 53f253d

Browse files
authored
test: redo cockroachdb to service-container GHA and update its version to latest (24) (typeorm#11190)
1 parent af603ae commit 53f253d

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
node-version: [16.x, 18.x, 20.x] #, 22.x]
19+
node-container: ["node:16", "node:18", "node:20"] #, "node:22"]
2020
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
container: ${{ matrix.node-container }}
23+
services:
24+
crdb:
25+
image: cockroachdb/cockroach
26+
env:
27+
COCKROACH_ARGS: 'start-single-node --insecure --cache=1GB --store=type=mem,size=4GB'
2128

2229
steps:
23-
- uses: actions/setup-node@v4
24-
with:
25-
node-version: ${{matrix.node-version}}
2630
- uses: actions/checkout@v4
27-
- run: docker compose -f .github/workflows/test/cockroachdb.docker-compose up -d
2831
- run: npm i
32+
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
2933
- run: cp .github/workflows/test/cockroachdb.ormconfig.json ormconfig.json
3034
- run: npm test
3135

.github/workflows/test/cockroachdb.docker-compose

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

.github/workflows/test/cockroachdb.ormconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"skip": false,
44
"name": "cockroachdb",
55
"type": "cockroachdb",
6-
"host": "localhost",
6+
"host": "crdb",
77
"port": 26257,
88
"username": "root",
99
"password": "",
10-
"database": "defaultdb"
10+
"database": "defaultdb",
11+
"logging": false
1112
},
1213

1314
{

src/driver/cockroachdb/CockroachQueryRunner.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ export class CockroachQueryRunner
225225
} else {
226226
this.storeQueries = false
227227
this.transactionDepth -= 1
228-
await this.query("RELEASE SAVEPOINT cockroach_restart")
228+
// This was disabled because it failed tests after update to CRDB 24.2
229+
// https://github.com/typeorm/typeorm/pull/11190
230+
// await this.query("RELEASE SAVEPOINT cockroach_restart")
229231
await this.query("COMMIT")
230232
this.queries = []
231233
this.isTransactionActive = false
@@ -1019,7 +1021,7 @@ export class CockroachQueryRunner
10191021
const enumColumns = newTable.columns.filter(
10201022
(column) => column.type === "enum" || column.type === "simple-enum",
10211023
)
1022-
for (let column of enumColumns) {
1024+
for (const column of enumColumns) {
10231025
// skip renaming for user-defined enum name
10241026
if (column.enumName) continue
10251027

@@ -3903,7 +3905,7 @@ export class CockroachQueryRunner
39033905
table: Table,
39043906
indexOrName: TableIndex | TableUnique | string,
39053907
): Query {
3906-
let indexName =
3908+
const indexName =
39073909
InstanceChecker.isTableIndex(indexOrName) ||
39083910
InstanceChecker.isTableUnique(indexOrName)
39093911
? indexOrName.name

test/functional/query-builder/locking/query-builder-locking.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,10 @@ describe("query builder > locking", () => {
975975
.createQueryBuilder(Post, "post")
976976
.leftJoin("post.author", "user")
977977
.setLock("pessimistic_write")
978-
.getOne(),
978+
.getOne()
979+
.should.be.rejectedWith(
980+
"FOR UPDATE cannot be applied to the nullable side of an outer join",
981+
),
979982
])
980983
})
981984
}

test/functional/repository/find-options-locking/find-options-locking.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,17 @@ describe("repository > find options > locking", () => {
638638
tables: ["post"],
639639
},
640640
}),
641-
entityManager.getRepository(Post).findOne({
642-
where: { id: 1 },
643-
relations: { author: true },
644-
lock: { mode: "pessimistic_write" },
645-
}),
641+
entityManager
642+
.getRepository(Post)
643+
.findOne({
644+
where: { id: 1 },
645+
relations: { author: true },
646+
lock: { mode: "pessimistic_write" },
647+
})
648+
.should.be.rejectedWith(
649+
"FOR UPDATE cannot be applied to the nullable side of an outer join",
650+
),
651+
,
646652
])
647653
})
648654
}

0 commit comments

Comments
 (0)