fix: stabilize page data release gate scenarios
Memind CI / Test, build, and release guards (push) Successful in 1m58s
Memind CI / Test, build, and release guards (push) Successful in 1m58s
This commit is contained in:
@@ -10,15 +10,27 @@ import {
|
||||
|
||||
const root = path.resolve(new URL('..', import.meta.url).pathname);
|
||||
const runtimeRoot = path.join(root, '.runtime', 'portal');
|
||||
const scenarioIds = [
|
||||
const allScenarioIds = [
|
||||
'ai-usage-survey',
|
||||
'customer-order-system',
|
||||
'supplier-data-report',
|
||||
'tkmind-feature-survey',
|
||||
];
|
||||
const requestedScenarioIds = String(process.env.RELEASE_GATE_SCENARIO_IDS ?? '').trim();
|
||||
const scenarioIds = requestedScenarioIds
|
||||
? requestedScenarioIds.split(',').map((value) => value.trim()).filter((value) => allScenarioIds.includes(value))
|
||||
: [...allScenarioIds];
|
||||
const scenarioAccounts = {
|
||||
'ai-usage-survey': 'gateai',
|
||||
'customer-order-system': 'gateorder',
|
||||
'supplier-data-report': 'gatesupplier',
|
||||
'tkmind-feature-survey': 'gatetkmind',
|
||||
};
|
||||
const concurrency = Math.max(
|
||||
1,
|
||||
Math.min(scenarioIds.length, Number(process.env.RELEASE_GATE_SCENARIO_CONCURRENCY ?? 4) || 4),
|
||||
// The backend provider is stateful across tool rounds. Keep the default
|
||||
// deterministic; operators can opt into bounded parallelism explicitly.
|
||||
Math.min(scenarioIds.length, Number(process.env.RELEASE_GATE_SCENARIO_CONCURRENCY ?? 1) || 1),
|
||||
);
|
||||
const childTimeoutMs = Math.max(
|
||||
30_000,
|
||||
@@ -29,7 +41,7 @@ const stepTimeoutMs = Math.max(
|
||||
Number(process.env.RELEASE_GATE_SCENARIO_TIMEOUT_MS ?? 300_000) || 300_000,
|
||||
);
|
||||
|
||||
async function runScenario(scenarioId, port) {
|
||||
async function runScenario(scenarioId, port, scenarioRoot) {
|
||||
const startedAt = Date.now();
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
const child = spawn(
|
||||
@@ -40,6 +52,11 @@ async function runScenario(scenarioId, port) {
|
||||
env: {
|
||||
...process.env,
|
||||
JOHN_PASSWORD: '888888',
|
||||
RELEASE_GATE_SCENARIO_USERNAME: scenarioAccounts[scenarioId],
|
||||
RELEASE_GATE_ALLOW_LOOPBACK_REPLY: '1',
|
||||
// Inspect the isolated Portal sandbox, not repository-level
|
||||
// MindSpace pages that may belong to a developer session.
|
||||
MEMIND_SCENARIO_H5_ROOT: scenarioRoot,
|
||||
RELEASE_GATE_SCENARIO_TIMEOUT_MS: String(stepTimeoutMs),
|
||||
},
|
||||
stdio: 'inherit',
|
||||
@@ -96,14 +113,30 @@ async function register(username) {
|
||||
}
|
||||
|
||||
try {
|
||||
for (const username of ['john', 'john4']) await register(username);
|
||||
let nextIndex = 0;
|
||||
for (const username of Object.values(scenarioAccounts)) await register(username);
|
||||
const claimed = new Set();
|
||||
const activeAccounts = new Set();
|
||||
const results = [];
|
||||
async function worker() {
|
||||
while (nextIndex < scenarioIds.length) {
|
||||
const scenarioId = scenarioIds[nextIndex];
|
||||
nextIndex += 1;
|
||||
results.push(await runScenario(scenarioId, new URL(stack.baseUrl).port));
|
||||
while (true) {
|
||||
const availableIndex = scenarioIds.findIndex((scenarioId, index) => (
|
||||
!claimed.has(scenarioId) && !activeAccounts.has(scenarioAccounts[scenarioId])
|
||||
));
|
||||
if (availableIndex < 0) {
|
||||
if (claimed.size >= scenarioIds.length) return;
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
continue;
|
||||
}
|
||||
const scenarioId = scenarioIds[availableIndex];
|
||||
claimed.add(scenarioId);
|
||||
const account = scenarioAccounts[scenarioId];
|
||||
activeAccounts.add(account);
|
||||
results.push(await runScenario(
|
||||
scenarioId,
|
||||
new URL(stack.baseUrl).port,
|
||||
stack.sandboxRoot,
|
||||
));
|
||||
activeAccounts.delete(account);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user