chore: merge master

This commit is contained in:
Kamil Myśliwiec committed 2026-05-13 14:24:58 +02:00
commit f0c95c8d8a
102 files changed
+2902 -522

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
/**
* Cross-platform wrapper that forwards arguments to whichever Docker Compose
* implementation is available on the host:
*
* 1. `docker compose` (Compose V2 plugin, shipped with modern Docker Desktop)
* 2. `docker-compose` (legacy standalone V1 binary)
*
* This exists because contributors run a mix of both and neither is guaranteed
* to be installed. The wrapper prefers V2 when available and transparently
* falls back to V1, so npm scripts like `test:docker:up` work everywhere.
*/
import { spawnSync } from 'node:child_process';
const forwardedArgs = process.argv.slice(2);
const isWindows = process.platform === 'win32';
function hasComposeV2() {
const result = spawnSync('docker', ['compose', 'version'], {
stdio: 'ignore',
shell: isWindows,
});
return result.status === 0;
}
function hasComposeV1() {
const probe = isWindows ? 'where' : 'which';
const result = spawnSync(probe, ['docker-compose'], {
stdio: 'ignore',
shell: isWindows,
});
return result.status === 0;
}
function run(command, args) {
const result = spawnSync(command, args, {
stdio: 'inherit',
shell: isWindows,
});
if (result.error) {
console.error(
`[docker-compose] Failed to execute: ${result.error.message}`,
);
process.exit(1);
}
process.exit(result.status == null ? 1 : result.status);
}
if (hasComposeV2()) {
run('docker', ['compose', ...forwardedArgs]);
} else if (hasComposeV1()) {
run('docker-compose', forwardedArgs);
} else {
console.error(
"[docker-compose] Neither 'docker compose' (V2) nor 'docker-compose' (V1) was found on PATH.\n" +
'Install Docker Desktop or the Docker Compose plugin and try again.',
);
process.exit(1);
}
+4 -1
View File
@@ -2,4 +2,7 @@
npm run build &>/dev/null
# 2. Start docker containers to perform integration tests
npm run test:docker:up
npm run test:docker:up
# 3. Wait for RabbitMQ to accept AMQP connections
npm run test:docker:wait:rmq
+5 -2
View File
@@ -4,5 +4,8 @@ npm run build &>/dev/null
# 2. Start docker containers to perform integration tests
npm run test:docker:up
# 3. Run integration tests
npm run test:integration
# 3. Wait for RabbitMQ to accept AMQP connections
npm run test:docker:wait:rmq
# 4. Run integration tests
npm run test:integration
+46
View File
@@ -0,0 +1,46 @@
import amqp from 'amqplib';
const url = process.env.RABBITMQ_URL || 'amqp://localhost:5672';
const readPositiveInteger = (value, fallback) => {
const parsed = Number.parseInt(value, 10);
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
};
const timeoutMs = readPositiveInteger(
process.env.RABBITMQ_WAIT_TIMEOUT_MS,
60000,
);
const intervalMs = readPositiveInteger(
process.env.RABBITMQ_WAIT_INTERVAL_MS,
1000,
);
const startedAt = Date.now();
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
async function waitForRabbitMQ() {
let lastError;
while (Date.now() - startedAt < timeoutMs) {
try {
const connection = await amqp.connect(url);
await connection.close();
console.log(`[rabbitmq] Ready at ${url}`);
return;
} catch (err) {
lastError = err;
console.log(`[rabbitmq] Waiting for ${url}...`);
await sleep(intervalMs);
}
}
console.error(
`[rabbitmq] Timed out waiting for ${url} after ${timeoutMs}ms.`,
);
if (lastError) {
console.error(lastError);
}
process.exit(1);
}
void waitForRabbitMQ();