@@ -9,12 +9,17 @@ import { createServer } from 'node:net';
|
||||
const id = crypto.randomBytes(6).toString('hex');
|
||||
const workspace = path.resolve('C:/laragon/www/compras');
|
||||
const standaloneOnly = process.argv.includes('--standalone-runtime-only');
|
||||
const standaloneBusiness = process.argv.includes('--standalone-business-only');
|
||||
if (standaloneOnly && process.argv.slice(2).some(flag => flag !== '--standalone-runtime-only')) throw Error('Standalone composition requires its own isolated invocation');
|
||||
if (standaloneBusiness && process.argv.slice(2).some(flag => flag !== '--standalone-business-only')) throw Error('Standalone business regression requires its own isolated invocation');
|
||||
const standaloneRoot = path.join(workspace, 'storage/framework/testing/compras-standalone-3320fac5a70fe44e');
|
||||
const standalonePin = '3320fac5a70fe44ed54e11af90385b5da6b204ef854984cd934882a4378211e1';
|
||||
const standaloneArchivePin = 'a544d5930feb916c4d4941ed8ef0b453985c1629720e9d0224bdbf0d322fb536';
|
||||
const financePreview = process.argv.includes('--standalone-finance-preview');
|
||||
const componentProfile = process.argv.includes('--standalone-component-profile');
|
||||
if (componentProfile && (!standaloneOnly || financePreview)) throw Error('Component profile requires its own standalone invocation');
|
||||
if (financePreview && !standaloneOnly) throw Error('Finance preview requires the isolated standalone runtime');
|
||||
const standaloneUpgrade = process.argv.includes('--standalone-upgrade-only');
|
||||
const standaloneBusiness = process.argv.includes('--standalone-business-only') || standaloneUpgrade;
|
||||
if (standaloneOnly && process.argv.slice(2).some(flag => !['--standalone-runtime-only', '--standalone-finance-preview', '--standalone-component-profile'].includes(flag))) throw Error('Standalone composition requires its own isolated invocation');
|
||||
if (standaloneBusiness && process.argv.slice(2).some(flag => flag !== (standaloneUpgrade ? '--standalone-upgrade-only' : '--standalone-business-only'))) throw Error('Standalone business regression requires its own isolated invocation');
|
||||
const standaloneRoot = path.join(workspace, 'storage/framework/testing/compras-standalone-80483320a54af6f1');
|
||||
const standalonePin = '80483320a54af6f123498e43c1435a20922455f65860be88bd259e90efcbc0b7';
|
||||
const standaloneArchivePin = 'bbc1d953061d5a297d4336a3cb746a11af5d6930c6fc7d0b5d64b5bff3046e76';
|
||||
const reviewDurationArgs = process.argv.filter(flag => flag.startsWith('--review-minutes='));
|
||||
const reviewDurationMinutes = reviewDurationArgs.length === 0 ? 20 : Number(reviewDurationArgs[0].slice('--review-minutes='.length));
|
||||
if (reviewDurationArgs.length > 1 || !Number.isInteger(reviewDurationMinutes) || reviewDurationMinutes < 1 || reviewDurationMinutes > 60 || (reviewDurationArgs.length > 0 && !process.argv.includes('--native-review'))) throw Error('Native review duration must be one explicit value from1to60minutes');
|
||||
@@ -132,12 +137,19 @@ try {
|
||||
if (fs.lstatSync(archive).isSymbolicLink() || crypto.createHash('sha256').update(fs.readFileSync(archive)).digest('hex') !== standaloneArchivePin) throw Error('Pinned standalone archive mismatch');
|
||||
activeStandaloneRoot = path.join(root, 'runtime');
|
||||
fs.mkdirSync(activeStandaloneRoot);
|
||||
const code = '$z=new ZipArchive; if($z->open($argv[1])!==true||$z->numFiles!==67||!$z->extractTo($argv[2]))throw new LogicException("Owned candidate extraction failed");$z->close();echo "extracted";';
|
||||
const code = '$z=new ZipArchive; if($z->open($argv[1])!==true||$z->numFiles!==68||!$z->extractTo($argv[2]))throw new LogicException("Owned candidate extraction failed");$z->close();echo "extracted";';
|
||||
const extracted = spawnSync('php', ['-r', code, archive, activeStandaloneRoot], { windowsHide: true, encoding: 'utf8' });
|
||||
if (extracted.status !== 0 || extracted.stdout !== 'extracted') throw Error('Owned standalone extraction failed');
|
||||
verifyPrivateRuntime(activeStandaloneRoot, standalonePin, 66);
|
||||
verifyPrivateRuntime(activeStandaloneRoot, standalonePin, 67);
|
||||
const uiTest = spawnSync(process.execPath, ['--test', 'tests/Support/financial-preparation.test.mjs'], {
|
||||
cwd: workspace, windowsHide: true, encoding: 'utf8',
|
||||
env: { ...process.env, COMPRAS_FINANCE_UI_PACKAGE_ROOT: activeStandaloneRoot },
|
||||
});
|
||||
if (uiTest.status !== 0) throw Error('Pinned financial preparation UI regression failed: '+(uiTest.stdout || uiTest.stderr || ''));
|
||||
console.log(JSON.stringify({ pinned_financial_preparation_tests: 10, result: 'passed', extracted_runtime: true }));
|
||||
|
||||
}
|
||||
const environment = { ...process.env, APP_ENV: 'testing', APP_DEBUG: 'false', APP_KEY: 'base64:'+crypto.randomBytes(32).toString('base64'), DB_CONNECTION: 'pgsql', DB_URL: '', DB_HOST: '127.0.0.1', DB_PORT: '55439',
|
||||
const environment = { ...process.env, APP_ENV: 'testing', APP_DEBUG: 'false', COMPRAS_RUNTIME_ENABLED: 'false', COMPRAS_RUNTIME_PREPARE_ONLY: 'false', COMPRAS_RUNTIME_SYNTHETIC_ONLY: 'true', APP_KEY: 'base64:'+crypto.randomBytes(32).toString('base64'), DB_CONNECTION: 'pgsql', DB_URL: '', DB_HOST: '127.0.0.1', DB_PORT: '55439',
|
||||
DB_DATABASE: database, DB_USERNAME: role, DB_PASSWORD: password, CACHE_STORE: 'array', SESSION_DRIVER: 'array',
|
||||
MAIL_MAILER: 'array', QUEUE_CONNECTION: 'sync', BROADCAST_CONNECTION: 'null',
|
||||
COMMON_BUDGET_PATH: standaloneOnly || standaloneBusiness ? path.join(activeStandaloneRoot, 'budget-control') : frozenRuntime ? path.join(budgetRoot, 'budget-control') : 'C:/laragon/www/sgf-tempo/packages/budget-control',
|
||||
@@ -160,12 +172,14 @@ try {
|
||||
delete environment.COMMON_FINANCE_BUNDLE_SHA256;
|
||||
if (standaloneOnly || standaloneBusiness) {
|
||||
environment.COMPRAS_RUNTIME_ENABLED = 'false';
|
||||
environment.COMPRAS_RUNTIME_PREPARE_ONLY = 'true';
|
||||
environment.COMMON_PAYABLES_PATH = path.join(activeStandaloneRoot, 'payables');
|
||||
environment.COMMON_PURCHASING_PATH = path.join(activeStandaloneRoot, 'purchasing');
|
||||
environment.COMPRAS_RUNTIME_ROOT = activeStandaloneRoot;
|
||||
environment.COMPRAS_RUNTIME_SHA256 = standalonePin;
|
||||
environment.COMPRAS_RUNTIME_INSTALLATION_ID = crypto.randomUUID();
|
||||
environment.COMPRAS_STANDALONE_BUSINESS_QA = standaloneBusiness ? '1' : '0';
|
||||
environment.COMPRAS_STANDALONE_UPGRADE_QA = standaloneUpgrade ? '1' : '0';
|
||||
}
|
||||
if (frozenRuntime) {
|
||||
environment.COMMON_FINANCE_BUNDLE_ROOT = financeRoot;
|
||||
@@ -220,15 +234,23 @@ try {
|
||||
if (setupOnly || !frozenRuntime || !process.argv.includes('--integrated-schema')) throw Error('Expiry history regression requires the complete pinned isolated composition');
|
||||
args.splice(0, args.length, 'vendor/bin/pest', '--compact', 'tests/Feature/RequisitionBudgetCyclesTest.php', '--filter=native expiry returns the same request');
|
||||
}
|
||||
if (standaloneBusiness) args.splice(0, args.length, 'vendor/bin/pest', '--compact', 'tests/Feature/StandaloneBusinessCompositionTest.php');
|
||||
if (standaloneBusiness) args.splice(0, args.length, 'vendor/bin/pest', '--compact', standaloneUpgrade ? 'tests/Feature/StandaloneComponentUpgradeTest.php' : 'tests/Feature/StandaloneBusinessCompositionTest.php');
|
||||
const result = spawnSync('php', args, {
|
||||
cwd: process.cwd(), windowsHide: true, encoding: 'utf8', maxBuffer: 1024 * 1024, env: environment,
|
||||
});
|
||||
if (!setupOnly || result.status !== 0) process.stdout.write((result.stdout || '').replaceAll(password, '[private]'));
|
||||
process.stderr.write((result.stderr || '').replaceAll(password, '[private]'));
|
||||
process.exitCode = result.status === 0 ? 0 : 1;
|
||||
if (result.status === 0 && standaloneOnly) {
|
||||
const standaloneEnvironment = { ...environment, APP_ENV: 'standalone-qa',
|
||||
if (result.status === 0 && componentProfile) {
|
||||
const profile = spawnSync('php', ['tests/Support/standalone-runtime-worker.php', database, 'prepare-component-profile'], {
|
||||
cwd: workspace, windowsHide: true, encoding: 'utf8', env: { ...environment, APP_ENV: 'standalone-qa', SGC_STANDALONE_QA_ROOT: root },
|
||||
});
|
||||
process.stdout.write(profile.stdout || '');
|
||||
process.stderr.write(profile.stderr || '');
|
||||
if (profile.status !== 0 || !(profile.stdout || '').includes('synthetic_canonical_component_profiles')) throw Error('Canonical component profile fixture failed');
|
||||
}
|
||||
if (result.status === 0 && standaloneOnly && !componentProfile) {
|
||||
const standaloneEnvironment = { ...environment, APP_ENV: 'standalone-qa', COMPRAS_RUNTIME_PREPARE_ONLY: 'false',
|
||||
COMPRAS_RUNTIME_ROOT: activeStandaloneRoot, COMPRAS_RUNTIME_SHA256: standalonePin,
|
||||
COMPRAS_RUNTIME_INSTALLATION_ID: crypto.randomUUID(), SGC_STANDALONE_QA_ROOT: root,
|
||||
PAYABLE_SOURCE_INSTANCE: `standalone-synthetic-${id}`,
|
||||
@@ -238,11 +260,11 @@ try {
|
||||
for (const feature of ['BUDGET_DISTRIBUTIONS', 'REQUISITION_ACCOUNTS', 'REQUISITION_EXPIRY', 'EXPENSE_ALLOCATIONS',
|
||||
'AGREEMENT_LIMITS', 'ORDER_PARTS', 'IMPORT_TARIFFS', 'IMPORT_LEGAL', 'IMPORT_DOSSIER', 'IMPORT_BANK_SUPPORT',
|
||||
'IMPORT_READINESS', 'IMPORT_ESTIMATES', 'IMPORT_LANDED_COSTS', 'SUPPLIER_PAYABLES', 'GENERAL_LEDGER',
|
||||
'SUPPLIER_SETTLEMENTS', 'GENERAL_LEDGER_CYCLE']) standaloneEnvironment[`COMPRAS_${feature}_ENABLED`] = 'true';
|
||||
'SUPPLIER_SETTLEMENTS', 'GENERAL_LEDGER_CYCLE', 'FINANCE_CONFIGURATION']) standaloneEnvironment[`COMPRAS_${feature}_ENABLED`] = 'true';
|
||||
for (const mode of ['prepare', 'verify']) {
|
||||
const check = spawnSync('php', ['tests/Support/standalone-runtime-worker.php', database, mode], {
|
||||
cwd: workspace, windowsHide: true, encoding: 'utf8', maxBuffer: 1024 * 1024,
|
||||
env: { ...standaloneEnvironment, COMPRAS_RUNTIME_ENABLED: mode === 'verify' ? 'true' : 'false' },
|
||||
env: { ...standaloneEnvironment, COMPRAS_RUNTIME_ENABLED: mode === 'verify' ? 'true' : 'false', COMPRAS_RUNTIME_PREPARE_ONLY: mode === 'prepare' ? 'true' : 'false' },
|
||||
});
|
||||
process.stdout.write((check.stdout || '').replaceAll(password, '[private]'));
|
||||
process.stderr.write((check.stderr || '').replaceAll(password, '[private]'));
|
||||
@@ -252,9 +274,10 @@ try {
|
||||
if (check.status !== 0 || receipt?.[expected] !== true) { process.exitCode = 1; break; }
|
||||
}
|
||||
if (process.exitCode === 0) {
|
||||
for (const mode of ['reject-foreign', 'reject-pin', 'reject-dependency', 'reject-old']) {
|
||||
for (const mode of ['reject-foreign', 'reject-pin', 'reject-prepare-pin', 'reject-dependency', 'reject-old']) {
|
||||
const invalid = { ...standaloneEnvironment, COMPRAS_RUNTIME_ENABLED: 'true' };
|
||||
if (mode === 'reject-pin') invalid.COMPRAS_RUNTIME_SHA256 = '0'.repeat(64);
|
||||
if (mode === 'reject-prepare-pin') { invalid.COMPRAS_RUNTIME_ENABLED = 'false'; invalid.COMPRAS_RUNTIME_PREPARE_ONLY = 'true'; }
|
||||
if (mode === 'reject-pin' || mode === 'reject-prepare-pin') invalid.COMPRAS_RUNTIME_SHA256 = '0'.repeat(64);
|
||||
if (mode === 'reject-dependency') invalid.COMPRAS_IMPORT_DOSSIER_ENABLED = 'false';
|
||||
if (mode === 'reject-old') {
|
||||
invalid.COMPRAS_RUNTIME_ROOT = path.join(workspace, 'storage/framework/testing/compras-standalone-730845de0bddd000');
|
||||
@@ -289,7 +312,7 @@ try {
|
||||
if (mode === 'rebind') restored.COMPRAS_RUNTIME_INSTALLATION_ID = crypto.randomUUID();
|
||||
const check = spawnSync('php', ['tests/Support/standalone-runtime-worker.php', restoreDatabase, mode], {
|
||||
cwd: workspace, windowsHide: true, encoding: 'utf8', maxBuffer: 1024 * 1024,
|
||||
env: { ...restored, COMPRAS_RUNTIME_ENABLED: mode === 'rebind' ? 'false' : 'true' },
|
||||
env: { ...restored, COMPRAS_RUNTIME_ENABLED: mode === 'rebind' ? 'false' : 'true', COMPRAS_RUNTIME_PREPARE_ONLY: mode === 'rebind' ? 'true' : 'false' },
|
||||
});
|
||||
process.stdout.write((check.stdout || '').replaceAll(restoredPassword, '[private]'));
|
||||
process.stderr.write((check.stderr || '').replaceAll(restoredPassword, '[private]'));
|
||||
@@ -299,6 +322,17 @@ try {
|
||||
if (check.status !== 0 || receipt?.[expected] !== true) { process.exitCode = 1; break; }
|
||||
}
|
||||
}
|
||||
if (process.exitCode === 0) {
|
||||
const { verifyConfigurationConcurrency } = await import('./standalone-configuration-race.mjs');
|
||||
await verifyConfigurationConcurrency(workspace, root, database, { ...standaloneEnvironment, COMPRAS_RUNTIME_ENABLED: 'true' });
|
||||
}
|
||||
if (process.exitCode === 0 && financePreview) {
|
||||
const { reviewStandaloneFinance } = await import('./standalone-finance-preview.mjs');
|
||||
await reviewStandaloneFinance({ workspace, root, database,
|
||||
environment: { ...standaloneEnvironment, COMPRAS_RUNTIME_ENABLED: 'true' },
|
||||
assets: path.join(privateParent, 'sgc-standalone-finance-help-qa-20261129'),
|
||||
manifestPin: '8653c147ab863447b523ddc03111265e3e6510bdddc31341777d6a3bdc46ce5b' });
|
||||
}
|
||||
}
|
||||
if (result.status === 0 && raceOnly) {
|
||||
const race = spawnSync('php', ['tests/Concurrency/requisition-account-worker.php', database, 'race'], {
|
||||
|
||||
Reference in New Issue
Block a user