mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-04 03:24:43 -05:00
* ci: select affected checks and share add-on builds Keep validation check identities present while omitting expensive steps when explicit dependency rules prove they are unaffected. Unknown inputs and diff failures retain broad validation. Select add-on package legs on PRs and master without weakening catalog checks or changing release publishing. Manual package runs validate only, including their reusable Sandbox guest image dependency. Share bounded, same-run production fixtures across the five add-on test groups. Verify checkout identity, tools, paths, modes and checksums before using them. Keep instrumented coverage builds separate. Assisted-by: nib:gpt-6.1-sol Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(ci): validate documentation test contracts Documentation is executable input to Tables, recovery, diagnostics, gallery and other add-on tests. Select all domains for docs changes instead of treating the whole directory as inert. Cover known readers, unfamiliar paths and deleted guides in classifier regression fixtures. Assisted-by: nib:gpt-6.1-sol Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(ci): gate affected jobs before allocation Classify each workflow once and gate whole expensive jobs. Limit add-on matrices to affected packages and host groups instead of allocating all runners before deciding whether their steps should run. Select documentation readers explicitly and derive host consumers from local Go imports. Keep unknown source inputs conservative. Preserve coverage, production fixtures, publish locks and manual full validation. Remove the unrequested weekly schedules. Reject classifier failures and unexpected dependency skips in stable aggregate checks. Document required-check migration without claiming access to protected-branch settings. Test actual YAML job and matrix eligibility against representative paths and the original triggers. Assisted-by: nib:gpt-6.1-sol Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(ci): validate executable and fixture seams Include executed fixture binaries and their production imports in host selection. Lexical Go imports alone miss the mock backend started by the UI test server and add-on suites. Rebase restored artifact timestamps only after identity and checksum validation. Preserve the existing stale-source checks across a later consumer checkout and reject subsequent source edits. Validate package plan outputs before allowing dependency skips. Missing or malformed plans must not turn failed publication preparation green. Cover all three review findings with before-fix reproductions and actual workflow eligibility regressions. Assisted-by: nib:gpt-6.1-sol Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(ci): use native workflow path filters Replace calculated dependencies with visible PR and master path lists. Run complete area suites without classifier runners or result plumbing. Restore original packaging validation and publication dependencies. Keep one production fixture build for the five original add-on groups. Verify artifact identity and freshness without changing suite inventories. Document allowlist maintenance and required-check migration limits. Assisted-by: nib:gpt-6.1-sol Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
73 lines
3.6 KiB
Python
73 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MIT
|
|
"""Same-run production fixtures only. Tar retains executable bits and paths."""
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import tarfile
|
|
import time
|
|
|
|
PATHS = ['core/http/react-ui/dist', 'pkg/grpc/proto', 'pkg/motion/proto',
|
|
'tests/e2e/mock-backend/mock-backend', 'tests/e2e-ui/ui-test-server']
|
|
BINARIES = PATHS[-2:]
|
|
|
|
def metadata(root):
|
|
files = {}
|
|
for name in PATHS:
|
|
path = root / name
|
|
assert path.exists(), f'missing fixture: {name}'
|
|
for p in sorted(path.rglob('*')) if path.is_dir() else [path]:
|
|
assert not p.is_symlink(), f'fixture symlink: {p}'
|
|
if p.is_file():
|
|
# tar's data filter removes group/other write bits.
|
|
files[str(p.relative_to(root))] = [hashlib.sha256(p.read_bytes()).hexdigest(), p.stat().st_mode & 0o755]
|
|
for name in BINARIES:
|
|
assert os.access(root / name, os.X_OK), f'not executable: {name}'
|
|
for name in ['core/http/react-ui/dist/index.html', 'pkg/grpc/proto/backend.pb.go',
|
|
'pkg/grpc/proto/backend_grpc.pb.go', 'pkg/motion/proto/motion.pb.go']:
|
|
assert (root / name).stat().st_size > 0, f'missing generated input: {name}'
|
|
return files
|
|
|
|
def transfer(mode, root, archive, sha, tools=None):
|
|
identity = {'sha': sha, 'config': 'ubuntu-24.04-amd64-go1.26-auth-production-v1', 'tools': tools or {}}
|
|
if mode == 'pack':
|
|
manifest = dict(identity, files=metadata(root))
|
|
(root / 'addon-fixtures.json').write_text(json.dumps(manifest, sort_keys=True))
|
|
with tarfile.open(archive, 'w:gz') as tar:
|
|
for name in PATHS + ['addon-fixtures.json']:
|
|
tar.add(root / name, arcname=name)
|
|
assert archive.stat().st_size <= 512 * 1024 * 1024, 'fixture artifact exceeds 512 MiB'
|
|
elif mode == 'unpack':
|
|
with tarfile.open(archive) as tar:
|
|
for member in tar.getmembers():
|
|
name = member.name
|
|
assert any(name == p or name.startswith(p + '/') for p in PATHS + ['addon-fixtures.json']), f'unexpected path: {name}'
|
|
assert '..' not in Path(name).parts and not Path(name).is_absolute()
|
|
assert member.isfile() or member.isdir(), f'unsupported member: {name}'
|
|
tar.extractall(root, filter='data')
|
|
manifest = json.loads((root / 'addon-fixtures.json').read_text())
|
|
for key, value in identity.items():
|
|
assert manifest[key] == value, f'fixture {key} mismatch'
|
|
assert metadata(root) == manifest['files'], 'fixture checksum/mode mismatch'
|
|
# The consumer checks out the same SHA later than the producer. Only
|
|
# after identity and content verification, rebase generated mtimes onto
|
|
# that checkout. Keep the server newer than its embedded dist, and leave
|
|
# all source files untouched so a subsequent edit still fails -nt guards.
|
|
stamp = time.time_ns()
|
|
for name in manifest['files']:
|
|
if name not in BINARIES: os.utime(root / name, ns=(stamp, stamp))
|
|
for offset, name in enumerate(BINARIES, 1):
|
|
os.utime(root / name, ns=(stamp + offset, stamp + offset))
|
|
else:
|
|
raise ValueError(mode)
|
|
|
|
if __name__ == '__main__':
|
|
root = Path.cwd()
|
|
sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
|
|
tools = {name: subprocess.check_output(command, text=True).strip() for name, command in
|
|
{'go': ['go', 'version'], 'node': ['node', '--version'], 'protoc': ['protoc', '--version']}.items()}
|
|
transfer(sys.argv[1], root, Path(os.environ['RUNNER_TEMP']) / 'addon-fixtures.tgz', sha, tools)
|