Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
permissions:
contents: read
steps:
Expand Down
28 changes: 21 additions & 7 deletions src/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ export const legacyUrl = () =>
export const subductionUrl = () =>
process.env.PUSHWORK_SUBDUCTION_SERVER || DEFAULT_SUBDUCTION;

function withFlushingShutdown(repo: Repo): Repo {
const shutdown = repo.shutdown.bind(repo);
repo.shutdown = async () => {
try {
await repo.flush();
} finally {
await shutdown();
}
};
return repo;
}

export async function openRepo(
backend: Backend,
storageDir: string,
Expand All @@ -29,23 +41,25 @@ export async function openRepo(
await initSubduction();
const storage = new NodeFSStorageAdapter(storageDir);
if (opts.offline) {
return new Repo({ storage, network: [] });
return withFlushingShutdown(new Repo({ storage, network: [] }));
}
if (backend === "legacy") {
const endpoint = legacyUrl();
dlog("legacy ws endpoint=%s", endpoint);
const adapter = new WebSocketClientAdapter(
endpoint,
) as unknown as NetworkAdapterInterface;
return new Repo({ storage, network: [adapter] });
return withFlushingShutdown(new Repo({ storage, network: [adapter] }));
}
const endpoint = subductionUrl();
dlog("subduction ws endpoint=%s", endpoint);
return new Repo({
storage,
network: [],
subductionWebsocketEndpoints: [endpoint],
});
return withFlushingShutdown(
new Repo({
storage,
network: [],
subductionWebsocketEndpoints: [endpoint],
}),
);
}

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
Expand Down
3 changes: 2 additions & 1 deletion test/integration/local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

const execFileP = promisify(execFile);
const CLI = path.join(__dirname, "..", "..", "dist", "cli.js");
const PNPM = process.platform === "win32" ? "pnpm.cmd" : "pnpm";

const TEST_TIMEOUT = 60_000;

Expand Down Expand Up @@ -46,7 +47,7 @@
}

beforeAll(async () => {
await execFileP("pnpm", ["build"], {
await execFileP(PNPM, ["build"], {

Check failure on line 50 in test/integration/local.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/integration/local.test.ts

Error: spawn EINVAL ❯ test/integration/local.test.ts:50:8 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -4071, code: 'EINVAL', syscall: 'spawn' }

Check failure on line 50 in test/integration/local.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/integration/local.test.ts

Error: spawn EINVAL ❯ test/integration/local.test.ts:50:8 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -4071, code: 'EINVAL', syscall: 'spawn' }
cwd: path.join(__dirname, "..", ".."),
timeout: 120_000,
});
Expand Down
3 changes: 2 additions & 1 deletion test/integration/pushwork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const execFileP = promisify(execFile);
const CLI = path.join(__dirname, "..", "..", "dist", "cli.js");
const PNPM = process.platform === "win32" ? "pnpm.cmd" : "pnpm";

const TEST_TIMEOUT = 120_000;

Expand Down Expand Up @@ -52,7 +53,7 @@
]
.filter(Boolean)
.join("\n");
throw new Error(detail);

Check failure on line 56 in test/integration/pushwork.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

test/integration/pushwork.test.ts > pushwork — 'legacy' backend > end-to-end session > supports a realistic two-user collaboration session

Error: pushwork clone --legacy automerge:VZQwLTdcxCuoPH5wC8NdduqZ7Gi /tmp/tmp-2438-Rk5TPZFgH8PT/bob failed (cwd=/home/runner/work/pushwork/pushwork) Command failed: node /home/runner/work/pushwork/pushwork/dist/cli.js clone --legacy automerge:VZQwLTdcxCuoPH5wC8NdduqZ7Gi /tmp/tmp-2438-Rk5TPZFgH8PT/bob error: Document VZQwLTdcxCuoPH5wC8NdduqZ7Gi is unavailable stdout: Connecting to sync server (19ms) stderr: error: Document VZQwLTdcxCuoPH5wC8NdduqZ7Gi is unavailable ❯ pushwork test/integration/pushwork.test.ts:56:9 ❯ test/integration/pushwork.test.ts:600:5

Check failure on line 56 in test/integration/pushwork.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

test/integration/pushwork.test.ts > pushwork — 'legacy' backend > default exclusions > does not sync .git or node_modules to a clone

Error: pushwork clone --legacy automerge:TVu4MYBL9H759JydSpuHBF6r9Pb /tmp/tmp-2438-BUITdMIgK1PH/b failed (cwd=/home/runner/work/pushwork/pushwork) Command failed: node /home/runner/work/pushwork/pushwork/dist/cli.js clone --legacy automerge:TVu4MYBL9H759JydSpuHBF6r9Pb /tmp/tmp-2438-BUITdMIgK1PH/b error: Document TVu4MYBL9H759JydSpuHBF6r9Pb is unavailable stdout: Connecting to sync server (18ms) stderr: error: Document TVu4MYBL9H759JydSpuHBF6r9Pb is unavailable ❯ pushwork test/integration/pushwork.test.ts:56:9 ❯ test/integration/pushwork.test.ts:575:5
}
}

Expand Down Expand Up @@ -125,7 +126,7 @@

beforeAll(async () => {
// Build once for the entire suite.
await execFileP("pnpm", ["build"], {
await execFileP(PNPM, ["build"], {

Check failure on line 129 in test/integration/pushwork.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/integration/pushwork.test.ts

Error: spawn EINVAL ❯ test/integration/pushwork.test.ts:129:8 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -4071, code: 'EINVAL', syscall: 'spawn' }

Check failure on line 129 in test/integration/pushwork.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/integration/pushwork.test.ts

Error: spawn EINVAL ❯ test/integration/pushwork.test.ts:129:8 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -4071, code: 'EINVAL', syscall: 'spawn' }
cwd: path.join(__dirname, "..", ".."),
timeout: 120_000,
});
Expand Down
3 changes: 2 additions & 1 deletion test/integration/shard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
const execFileP = promisify(execFile);
const REPO_ROOT = path.join(__dirname, "..", "..");
const FIXTURE = path.join(__dirname, "fixtures", "shard-roundtrip.ts");
const PNPM = process.platform === "win32" ? "pnpm.cmd" : "pnpm";

beforeAll(async () => {
await execFileP("pnpm", ["build"], { cwd: REPO_ROOT, timeout: 120_000 });
await execFileP(PNPM, ["build"], { cwd: REPO_ROOT, timeout: 120_000 });

Check failure on line 22 in test/integration/shard.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/integration/shard.test.ts

Error: spawn EINVAL ❯ test/integration/shard.test.ts:22:8 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -4071, code: 'EINVAL', syscall: 'spawn' }

Check failure on line 22 in test/integration/shard.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest)

test/integration/shard.test.ts

Error: spawn EINVAL ❯ test/integration/shard.test.ts:22:8 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -4071, code: 'EINVAL', syscall: 'spawn' }
}, 120_000);

describe("shard parallel ingest/clone", () => {
Expand Down
Loading