Usar contrato QA existente e documentar operacao e reversao
This commit is contained in:
@@ -52,7 +52,8 @@ def archive_source(data: bytes, root: Path) -> None:
|
||||
path = (root/item.name).resolve()
|
||||
if not path.is_relative_to(root.resolve()) or not (item.isfile() or item.isdir()):
|
||||
raise RuntimeError('Unsafe source archive entry')
|
||||
if item.name == '.env' or item.name == 'public/hot' or item.name.startswith('storage/app/private/'):
|
||||
if item.name == '.env' or item.name == 'public/hot' or (item.isfile()
|
||||
and item.name.startswith('storage/app/private/') and item.name != 'storage/app/private/.gitignore'):
|
||||
raise RuntimeError('Private/runtime files must not be distributed by Git')
|
||||
# Debian's installed Python predates tarfile extraction filters. Validate
|
||||
# every entry first, then create only ordinary directories/files ourselves.
|
||||
@@ -171,7 +172,7 @@ class Delivery:
|
||||
# Only the newly created, fully identified CI container and its anonymous volumes.
|
||||
self.run(['docker','rm','--force','--volumes',cid], timeout=60)
|
||||
|
||||
def build(self, target: str, release: Path) -> None:
|
||||
def build(self, target: str, release: Path, attach_runtime: bool = True) -> None:
|
||||
data = self.run(['git','--git-dir',self.mirror,'archive','--format=tar',target], timeout=120,log_output=False)
|
||||
# Binary archives must never be appended to text build logs.
|
||||
archive_source(data, release)
|
||||
@@ -193,13 +194,15 @@ class Delivery:
|
||||
# The guard is verified against the actual PostgreSQL identity, not only environment strings.
|
||||
guard = "require 'vendor/autoload.php'; $app=require 'bootstrap/app.php'; $app->make(Illuminate\\Contracts\\Console\\Kernel::class)->bootstrap(); if (!App\\Support\\IsolatedQaDatabase::allowsSchemaChanges()) exit(91);"
|
||||
self.run([self.c['php'],'-r',guard],cwd=release,env=env)
|
||||
self.run([self.c['php'],'artisan','migrate','--force','--no-interaction'],cwd=release,env=env)
|
||||
# The project intentionally gates later schemas behind nominal authenticated
|
||||
# installation. Reuse its accepted isolated baseline lifecycle test instead
|
||||
# of bypassing those guards with a generic migrate of every module.
|
||||
self.run([self.c['php'],'vendor/bin/phpunit','--configuration=phpunit.investmoz.xml','--do-not-cache-result'],cwd=release,env=env)
|
||||
self.run(['npm','ci','--no-audit','--no-fund'],cwd=release,env=env)
|
||||
self.run(['npm','run','build'],cwd=release,env=env)
|
||||
self.run(['npm','run','types:check'],cwd=release,env=env)
|
||||
self.run([self.c['php'],'tools/portal-diagnostics-deployment-guard.php'],cwd=release,env=env)
|
||||
self.run([self.c['php'],'vendor/bin/phpunit','--configuration=phpunit.xml','--testsuite','Unit','--do-not-cache-result'],cwd=release,env=env)
|
||||
self.run([self.c['php'],'vendor/bin/phpunit','--configuration=phpunit.investmoz.xml','--do-not-cache-result'],cwd=release,env=env)
|
||||
tests=sorted((release/'tests/frontend').glob('*.test.mjs'))
|
||||
self.run(['node','--test',*tests],cwd=release,env=env)
|
||||
# Final production vendor from the same lock, before linking any real configuration.
|
||||
@@ -210,6 +213,8 @@ class Delivery:
|
||||
for entry in manifest.values():
|
||||
for path in [entry.get('file'),*entry.get('css',[]),*entry.get('assets',[])]:
|
||||
if path and not (release/'public/build'/path).is_file(): raise RuntimeError('Missing compiled asset')
|
||||
if not attach_runtime:
|
||||
return
|
||||
# Discard only this release's synthetic runtime, retaining it privately outside the served tree.
|
||||
(release/'storage').rename(self.state/'qa-runtime'/release.name)
|
||||
(release/'.env').unlink()
|
||||
|
||||
Reference in New Issue
Block a user