Skip to content

Commit

Permalink
test: redo cockroachdb to service-container GHA and update its versio…
Browse files Browse the repository at this point in the history
…n to latest (24) (typeorm#11190)
  • Loading branch information
OSA413 authored Dec 16, 2024
1 parent af603ae commit 53f253d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x] #, 22.x]
node-container: ["node:16", "node:18", "node:20"] #, "node:22"]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

container: ${{ matrix.node-container }}
services:
crdb:
image: cockroachdb/cockroach
env:
COCKROACH_ARGS: 'start-single-node --insecure --cache=1GB --store=type=mem,size=4GB'

steps:
- uses: actions/setup-node@v4
with:
node-version: ${{matrix.node-version}}
- uses: actions/checkout@v4
- run: docker compose -f .github/workflows/test/cockroachdb.docker-compose up -d
- run: npm i
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
- run: cp .github/workflows/test/cockroachdb.ormconfig.json ormconfig.json
- run: npm test

Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/test/cockroachdb.docker-compose

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/test/cockroachdb.ormconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"skip": false,
"name": "cockroachdb",
"type": "cockroachdb",
"host": "localhost",
"host": "crdb",
"port": 26257,
"username": "root",
"password": "",
"database": "defaultdb"
"database": "defaultdb",
"logging": false
},

{
Expand Down
8 changes: 5 additions & 3 deletions src/driver/cockroachdb/CockroachQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ export class CockroachQueryRunner
} else {
this.storeQueries = false
this.transactionDepth -= 1
await this.query("RELEASE SAVEPOINT cockroach_restart")
// This was disabled because it failed tests after update to CRDB 24.2
// https://github.com/typeorm/typeorm/pull/11190
// await this.query("RELEASE SAVEPOINT cockroach_restart")
await this.query("COMMIT")
this.queries = []
this.isTransactionActive = false
Expand Down Expand Up @@ -1019,7 +1021,7 @@ export class CockroachQueryRunner
const enumColumns = newTable.columns.filter(
(column) => column.type === "enum" || column.type === "simple-enum",
)
for (let column of enumColumns) {
for (const column of enumColumns) {
// skip renaming for user-defined enum name
if (column.enumName) continue

Expand Down Expand Up @@ -3903,7 +3905,7 @@ export class CockroachQueryRunner
table: Table,
indexOrName: TableIndex | TableUnique | string,
): Query {
let indexName =
const indexName =
InstanceChecker.isTableIndex(indexOrName) ||
InstanceChecker.isTableUnique(indexOrName)
? indexOrName.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,10 @@ describe("query builder > locking", () => {
.createQueryBuilder(Post, "post")
.leftJoin("post.author", "user")
.setLock("pessimistic_write")
.getOne(),
.getOne()
.should.be.rejectedWith(
"FOR UPDATE cannot be applied to the nullable side of an outer join",
),
])
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,17 @@ describe("repository > find options > locking", () => {
tables: ["post"],
},
}),
entityManager.getRepository(Post).findOne({
where: { id: 1 },
relations: { author: true },
lock: { mode: "pessimistic_write" },
}),
entityManager
.getRepository(Post)
.findOne({
where: { id: 1 },
relations: { author: true },
lock: { mode: "pessimistic_write" },
})
.should.be.rejectedWith(
"FOR UPDATE cannot be applied to the nullable side of an outer join",
),
,
])
})
}
Expand Down

0 comments on commit 53f253d

Please sign in to comment.