Skip to content

Commit

Permalink
Merge branch 'deploy/hammer' into hammer/demo-tasks
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Jun 3, 2024
2 parents eb9aeda + 38d5869 commit ebd5f19
Show file tree
Hide file tree
Showing 131 changed files with 5,140 additions and 2,629 deletions.
2 changes: 1 addition & 1 deletion .github/actions/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
steps:
- uses: pnpm/[email protected]
with:
version: 'latest'
version: '8.15.7'
- uses: actions/setup-node@v2
with:
node-version: '16'
Expand Down
21 changes: 0 additions & 21 deletions .github/actions/overlay/action.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/api-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ jobs:
uses: ./.github/actions/bootstrap
with:
package: api-server
- name: overlay
uses: ./.github/actions/overlay
- name: tests
run: |
. /rmf_demos_ws/install/setup.bash
. ~/hammer_overlay_ws/install/setup.bash
pnpm run lint
pnpm run test:cov
pipenv run python -m coverage xml
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/dashboard-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@
# with:
# package: rmf-dashboard-e2e
# skip-build: true
# # Somehow this step is not needed
# # - name: overlay
# # uses: ./.github/actions/overlay
# - name: test
# uses: nick-fields/retry@v2
# with:
# timeout_minutes: 20
# max_attempts: 3
# command: |
# . /rmf_demos_ws/install/setup.bash
# . ~/hammer_overlay_ws/install/setup.bash
# cd packages/dashboard-e2e
# pnpm test
# shell: bash
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ jobs:
with:
package: rmf-dashboard
skip-build: true
- name: overlay
uses: ./.github/actions/overlay
- name: unit test
run: . /rmf_demos_ws/install/setup.bash && . ~/hammer_overlay_ws/install/setup.bash && pnpm run test:coverage
run: . /rmf_demos_ws/install/setup.bash && pnpm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ jobs:
uses: ./.github/actions/bootstrap
with:
package: api-server
- name: overlay
uses: ./.github/actions/overlay
- name: Extract docs
run: |
. /rmf_demos_ws/install/setup.bash
. ~/hammer_overlay_ws/install/setup.bash
pipenv run python3 scripts/extract_docs.py -o docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ jobs:
# with:
# package: rmf-dashboard-e2e
# skip-build: true
# - name: overlay
# uses: ./.github/actions/overlay
# - name: test
# uses: nick-fields/retry@v2
# with:
# timeout_minutes: 20
# max_attempts: 3
# command: |
# . /rmf_demos_ws/install/setup.bash
# . ~/hammer_overlay_ws/install/setup.bash
# cd packages/dashboard-e2e
# pnpm test
# shell: bash
Expand Down
1,502 changes: 830 additions & 672 deletions Pipfile.lock

Large diffs are not rendered by default.

30 changes: 4 additions & 26 deletions packages/api-client/lib/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,9 @@ describe('subscriptions', () => {
spyOn(sioClient.sio, 'emit');
});

it('multiplexes subscriptions', () => {
const s1 = sioClient.subscribe('test', () => {
// empty
});
const s2 = sioClient.subscribe('test', () => {
// empty
});
expect(sioClient.sio.emit).toHaveBeenCalledOnceWith('subscribe', jasmine.anything());
(sioClient.sio.emit as jasmine.Spy).calls.reset();

sioClient.unsubscribe(s1);
sioClient.unsubscribe(s2);
expect(sioClient.sio.emit).toHaveBeenCalledOnceWith('unsubscribe', jasmine.anything());
});

it('does not unsubscribe early when there are multiple subscriptions with the same listener', () => {
const listener = jasmine.createSpy();
const s1 = sioClient.subscribe('test', listener);
const s2 = sioClient.subscribe('test', listener);
expect(sioClient.sio.emit).toHaveBeenCalledOnceWith('subscribe', jasmine.anything());
(sioClient.sio.emit as jasmine.Spy).calls.reset();

sioClient.unsubscribe(s1);
expect(sioClient.sio.emit).not.toHaveBeenCalled();
sioClient.unsubscribe(s2);
expect(sioClient.sio.emit).toHaveBeenCalledOnceWith('unsubscribe', jasmine.anything());
it('dummy', () => {
// Dummy test to ci passes.
// #940 removed multiplexing in order to support resubscribe on reconnect.
// With it gone, there is no more tests and ci fails as a result.
});
});
36 changes: 10 additions & 26 deletions packages/api-client/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
DispenserState,
DoorHealth,
DoorState,
ApiServerModelsRmfApiFleetStateFleetState,
FireAlarmTriggerState,
FleetState,
IngestorHealth,
IngestorState,
LiftHealth,
Expand All @@ -19,7 +20,6 @@ import {
} from './openapi';

type Alert = ApiServerModelsTortoiseModelsAlertsAlertLeaf;
type FleetState = ApiServerModelsRmfApiFleetStateFleetState;

const debug = Debug('rmf-client');

Expand All @@ -32,41 +32,21 @@ export interface Subscription {

export class SioClient {
public sio: Socket;
private _subscriptions: Record<string, number> = {};

constructor(...args: Parameters<typeof io>) {
this.sio = io(...args);
}

subscribe<T>(room: string, listener: Listener<T>): Subscription {
const subs = this._subscriptions[room] || 0;
if (subs === 0) {
this.sio.emit('subscribe', { room });
debug(`subscribed to ${room}`);
} else {
debug(`reusing previous subscription to ${room}`);
}
this.sio.emit('subscribe', { room });
debug(`subscribed to ${room}`);
this.sio.on(room, listener);
this._subscriptions[room] = subs + 1;
return { room, listener };
}

unsubscribe(sub: Subscription): void {
const subCount = this._subscriptions[sub.room] || 0;
if (!subCount) {
debug(`tried to unsubscribe from ${sub.room}, but no subscriptions exist`);
// continue regardless
}
if (subCount <= 1) {
this.sio.emit('unsubscribe', { room: sub.room });
delete this._subscriptions[sub.room];
debug(`unsubscribed to ${sub.room}`);
} else {
this._subscriptions[sub.room] = subCount - 1;
debug(
`skipping unsubscribe to ${sub.room} because there are still ${subCount - 1} subscribers`,
);
}
this.sio.emit('unsubscribe', { room: sub.room });
debug(`unsubscribed to ${sub.room}`);
this.sio.off(sub.room, sub.listener);
}

Expand Down Expand Up @@ -129,6 +109,10 @@ export class SioClient {
subscribeDeliveryAlerts(listener: Listener<DeliveryAlert>): Subscription {
return this.subscribe<DeliveryAlert>(`/delivery_alerts`, listener);
}

subscribeFireAlarmTrigger(listener: Listener<FireAlarmTriggerState>): Subscription {
return this.subscribe<FireAlarmTriggerState>('/fire_alarm_trigger', listener);
}
}

export * from './openapi';
Loading

0 comments on commit ebd5f19

Please sign in to comment.