commit compras1 3011
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-30 09:33:36 +02:00
parent 96b30368bc
commit 47649bd46c
163 changed files with 9419 additions and 145 deletions
+50
View File
@@ -0,0 +1,50 @@
"""Apply the existing local functional capabilities to the same public product."""
from pathlib import Path
import json
import os
import shutil
import subprocess
root = Path('/var/www/compras-deploy/current').resolve()
assert root == Path('/var/www/compras-deploy/releases/presentation-20261129')
snapshot = json.loads(subprocess.check_output(['/usr/bin/php', str(root/'scripts/compare-compras-installation.php'), '--public-read-only']))
assert all(snapshot['history_schema'].values()) and len(snapshot['features']) == 24 and all(snapshot['features'].values())
env = (root/'.env').resolve()
assert env == Path('/var/www/compras-deploy/demonstration-20261129/.env')
backup = Path('/var/backups/compras-presentation-20261129/unified-functional-flags')
backup.mkdir(mode=0o700, exist_ok=False)
shutil.copy2(env, backup/'selected.env.private')
(backup/'selected.env.private').chmod(0o600)
updates = {'COMMON_PAYABLES_ENABLED': 'true', 'COMMON_PAYABLES_HISTORY_ENABLED': 'true', 'SGC_GEOGRAPHY_ENABLED': 'true',
'SGC_PROCUREMENT_FINANCE_SEARCH_ENABLED': 'true', 'SGC_REQUISITION_APPROVAL_LEVELS_ENABLED': 'true',
'SGC_PUBLIC_NAVIGATION': 'false'}
lines = env.read_text().splitlines()
for key, value in updates.items():
matches = [i for i, line in enumerate(lines) if line.startswith(key+'=')]
assert len(matches) <= 1
if matches:
lines[matches[0]] = key+'='+value
else:
lines.append(key+'='+value)
temp = env.with_name(env.name+'.functional-next')
temp.write_text('\n'.join(lines)+'\n')
attrs = env.stat()
temp.chmod(attrs.st_mode & 0o777)
os.chown(temp, attrs.st_uid, attrs.st_gid)
os.replace(temp, env)
try:
subprocess.run(['runuser', '-u', 'www-data', '--', '/usr/bin/php', 'artisan', 'config:cache'], cwd=root, check=True)
after = json.loads(subprocess.check_output(['/usr/bin/php', str(root/'scripts/compare-compras-installation.php'), '--public-read-only']))
for key in ['common-payables.enabled', 'common-payables.history_enabled', 'geography.enabled',
'procurement_search.finance_metadata_enabled', 'requisition_approval.enabled']:
assert after['deployment_flags'][key] is True
assert after['deployment_flags']['public_navigation.enabled'] is False
except BaseException:
shutil.copyfile(backup/'selected.env.private', env)
subprocess.run(['runuser', '-u', 'www-data', '--', '/usr/bin/php', 'artisan', 'config:cache'], cwd=root, check=True)
raise
proof = {'state': 'passed', 'settings_aligned': updates, 'company_rules_and_permissions_changed': False,
'business_data_changed': False, 'original_archives_and_runtime_components_preserved': True,
'backup': str(backup), 'anonymous_business_pages': 'normal authenticated application access'}
(backup/'result.json').write_text(json.dumps(proof, indent=2)+'\n')
print(json.dumps(proof))