Skip to content

Commit 3ed31f9

Browse files
committed
👷‍♀️ Add CI build
1 parent 4b5b537 commit 3ed31f9

File tree

7 files changed

+1697
-77
lines changed

7 files changed

+1697
-77
lines changed

.github/workflows/test.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- setup-ci # TODO: Remove
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test:
14+
name: Node.js ${{ matrix.node }} + PostgreSQL ${{ matrix.postgres }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
node:
20+
- 16
21+
- 18
22+
- 20
23+
postgres:
24+
- 13
25+
- 14
26+
- 15
27+
- 16
28+
services:
29+
postgres:
30+
image: postgres:${{ matrix.postgres }}
31+
options: >-
32+
--health-cmd pg_isready
33+
--health-interval 10s
34+
--health-timeout 5s
35+
--health-retries 5
36+
ports:
37+
- 5432:5432
38+
timeout-minutes: 10
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node }}
44+
- name: Install
45+
run: npm install
46+
- name: Test
47+
run: npm test

.mocharc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
timeout: 5_000,
3+
bail: true, // TODO: Remove
4+
};

index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PostgresDB.prototype = Object.create(DB.prototype);
1919
PostgresDB.prototype.close = function(callback) {
2020
this.closed = true;
2121
this.pool.end();
22-
22+
2323
if (callback) callback();
2424
};
2525

@@ -44,22 +44,22 @@ PostgresDB.prototype.commit = function(collection, id, op, snapshot, options, ca
4444
return;
4545
}
4646
/*
47-
* This query uses common table expression to upsert the snapshot table
47+
* This query uses common table expression to upsert the snapshot table
4848
* (iff the new version is exactly 1 more than the latest table or if
4949
* the document id does not exists)
5050
*
51-
* It will then insert into the ops table if it is exactly 1 more than the
51+
* It will then insert into the ops table if it is exactly 1 more than the
5252
* latest table or it the first operation and iff the previous insert into
5353
* the snapshot table is successful.
5454
*
5555
* This result of this query the version of the newly inserted operation
5656
* If either the ops or the snapshot insert fails then 0 rows are returned
5757
*
58-
* If 0 zeros are return then the callback must return false
58+
* If 0 zeros are return then the callback must return false
5959
*
6060
* Casting is required as postgres thinks that collection and doc_id are
61-
* not varchar
62-
*/
61+
* not varchar
62+
*/
6363
const query = {
6464
name: 'sdb-commit-op-and-snap',
6565
text: `WITH snapshot_id AS (
@@ -101,13 +101,13 @@ RETURNING version`,
101101
} else if(res.rows.length === 0) {
102102
done(client);
103103
callback(null,false)
104-
}
104+
}
105105
else {
106106
done(client);
107107
callback(null,true)
108108
}
109109
})
110-
110+
111111
})
112112
};
113113

0 commit comments

Comments
 (0)