Skip to content

Commit 3b08183

Browse files
authored
Merge pull request #4 from jsonjoy-com/improvements
Improvements
2 parents 22e9738 + a7c9ab0 commit 3b08183

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1687
-1135
lines changed

.github/workflows/pr.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- run: yarn lint
4141
- run: yarn prettier:check
4242
- run: yarn typedoc
43-
e2e-rx-rpc:
43+
e2e-sample-api-http1:
4444
runs-on: ubuntu-latest
4545
strategy:
4646
matrix:
@@ -53,4 +53,46 @@ jobs:
5353
node-version: ${{ matrix.node-version }}
5454
cache: yarn
5555
- run: yarn install --frozen-lockfile
56-
- run: yarn test:e2e
56+
- run: yarn test:e2e --server http1 --suite sample-api
57+
e2e-sample-api-uws:
58+
runs-on: ubuntu-latest
59+
strategy:
60+
matrix:
61+
node-version: [20.x]
62+
steps:
63+
- uses: actions/checkout@v4
64+
- name: Use Node.js ${{ matrix.node-version }}
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: ${{ matrix.node-version }}
68+
cache: yarn
69+
- run: yarn install --frozen-lockfile
70+
- run: yarn test:e2e --server uws --suite sample-api
71+
e2e-json-crdt-server-http1:
72+
runs-on: ubuntu-latest
73+
strategy:
74+
matrix:
75+
node-version: [20.x]
76+
steps:
77+
- uses: actions/checkout@v4
78+
- name: Use Node.js ${{ matrix.node-version }}
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: ${{ matrix.node-version }}
82+
cache: yarn
83+
- run: yarn install --frozen-lockfile
84+
- run: yarn test:e2e --server http1 --suite json-crdt-server
85+
e2e-json-crdt-server-uws:
86+
runs-on: ubuntu-latest
87+
strategy:
88+
matrix:
89+
node-version: [20.x]
90+
steps:
91+
- uses: actions/checkout@v4
92+
- name: Use Node.js ${{ matrix.node-version }}
93+
uses: actions/setup-node@v4
94+
with:
95+
node-version: ${{ matrix.node-version }}
96+
cache: yarn
97+
- run: yarn install --frozen-lockfile
98+
- run: yarn test:e2e --server uws --suite json-crdt-server

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ jobs:
2323
- run: yarn prettier:check
2424
- run: yarn lint
2525
- run: yarn test:ci --ci
26-
- run: yarn test:e2e
26+
- run: yarn test:e2e --server http1 --suite sample-api
27+
- run: yarn test:e2e --server uws --suite sample-api
28+
- run: yarn test:e2e --server http1 --suite json-crdt-server
29+
- run: yarn test:e2e --server uws --suite json-crdt-server
2730
- run: yarn build
2831
- name: Semantic Release
2932
uses: cycjimmy/semantic-release-action@v4

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@
4949
"test": "jest --maxWorkers 7",
5050
"test:ci": "yarn jest --maxWorkers 3 --no-cache",
5151
"test:e2e": "node -r ts-node/register/transpile-only src/__tests__/e2e/run.ts",
52-
"test:e2e:jest": "TEST_E2E=1 jest --maxWorkers 1 --no-cache src/__tests__/e2e/",
53-
"demo:e2e:server": "ts-node src/__demos__/server.ts",
52+
"test:e2e:jest:sample-api": "TEST_E2E=1 jest --maxWorkers 1 --no-cache src/__tests__/e2e/sample-api/",
53+
"test:e2e:jest:json-crdt-server": "TEST_E2E=1 jest --maxWorkers 1 --no-cache src/__tests__/e2e/json-crdt-server/",
54+
"demo:e2e:sample-api:http1": "ts-node src/__demos__/sample-api/main-http1.ts",
55+
"demo:e2e:sample-api:uws": "ts-node src/__demos__/sample-api/main-uws.ts",
56+
"demo:e2e:json-crdt-server:http1": "ts-node src/__demos__/json-crdt-server/main-http1.ts",
57+
"demo:e2e:json-crdt-server:uws": "ts-node src/__demos__/json-crdt-server/main-uws.ts",
5458
"coverage": "yarn test --collectCoverage",
5559
"typedoc": "typedoc",
5660
"build:pages": "rimraf gh-pages && mkdir -p gh-pages && cp -r typedocs/* gh-pages && cp -r coverage gh-pages/coverage",
@@ -71,7 +75,8 @@
7175
"@jsonjoy.com/json-pack": "^1.0.2",
7276
"@jsonjoy.com/util": "^1.0.0",
7377
"json-joy": "^14.2.0",
74-
"memfs": "^4.8.1"
78+
"memfs": "^4.8.1",
79+
"sonic-forest": "^1.0.0"
7580
},
7681
"devDependencies": {
7782
"@types/benchmark": "^2.1.5",

src/json-crdt-server/__bench__/ping.bench.ts renamed to src/__demos__/json-crdt-server/__bench__/ping.bench.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/* tslint:disable no-console */
44

55
import {Suite} from 'benchmark';
6-
import {RpcPersistentClient, WebSocketChannel} from '../../common';
6+
import {RpcPersistentClient, WebSocketChannel} from '../../../common';
77
import {Writer} from '@jsonjoy.com/util/lib/buffers/Writer';
8-
import {CompactRpcMessageCodec} from '../../common/codec/compact';
8+
import {CompactRpcMessageCodec} from '../../../common/codec/compact';
99
import {JsonJsonValueCodec} from '@jsonjoy.com/json-pack/lib/codecs/json';
10-
import {RpcCodec} from '../../common/codec/RpcCodec';
10+
import {RpcCodec} from '../../../common/codec/RpcCodec';
1111
import {WebSocket} from 'ws';
1212

1313
const main = async () => {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {setup} from './setup';
2+
import {runBlockTests} from '../../../__tests__/json-crdt-server/block';
3+
import type {ApiTestSetup} from '../../../common/rpc/__tests__/runApiTests';
4+
5+
runBlockTests(setup as ApiTestSetup);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {runPresenceTests} from '../../../__tests__/json-crdt-server/presence';
2+
import {setup} from './setup';
3+
import type {ApiTestSetup} from '../../../common/rpc/__tests__/runApiTests';
4+
5+
runPresenceTests(setup as ApiTestSetup);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {runPubsubTests} from '../../../__tests__/json-crdt-server/pubsub';
2+
import {setup} from './setup';
3+
import type {ApiTestSetup} from '../../../common/rpc/__tests__/runApiTests';
4+
5+
runPubsubTests(setup as ApiTestSetup);

src/json-crdt-server/__tests__/setup.ts renamed to src/__demos__/json-crdt-server/__tests__/setup.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {buildE2eClient} from '../../common/testing/buildE2eClient';
1+
import {buildE2eClient} from '../../../common/testing/buildE2eClient';
22
import {createCaller} from '../routes';
33
import {Services} from '../services/Services';
44

5-
export const setup = () => {
5+
export const setup = async () => {
66
const services = new Services();
77
const {caller} = createCaller(services);
88
const {client} = buildE2eClient(caller, {
@@ -14,5 +14,8 @@ export const setup = () => {
1414
});
1515
const call = client.call.bind(client);
1616
const call$ = client.call$.bind(client);
17-
return {services, caller, client, call, call$};
17+
const stop = () => {};
18+
return {call, call$, stop};
1819
};
20+
21+
export type JsonCrdtTestSetup = typeof setup;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {runUtilTests} from '../../../__tests__/json-crdt-server/util';
2+
import {setup} from './setup';
3+
import type {ApiTestSetup} from '../../../common/rpc/__tests__/runApiTests';
4+
5+
runUtilTests(setup as ApiTestSetup);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {createCaller} from './routes';
2+
3+
export {createCaller} from './routes';
4+
export type JsonJoyDemoRpcCaller = ReturnType<typeof createCaller>['caller'];

0 commit comments

Comments
 (0)